githubstats 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbc52fb43a7ea21f49af181e9fceac0aaa61953ee1d2891029ba0678cdc50e38
4
- data.tar.gz: 91cb1ba5ca68c13dd6b451ed20c1bf1d484fa52633b76c4ab8ef11c045bc98ce
3
+ metadata.gz: 63d1760b40fbefddd2aa5c8fba01de7eb8b9d4924ba16c3e6e32030265d1a4a7
4
+ data.tar.gz: b7c45953695c48422332f089338443e9d622d4c25991676a32e6ed28b9e7402d
5
5
  SHA512:
6
- metadata.gz: 3ff5c12de669ffdc4ef973d7301a513364a56ac41e923bf41e7d77a029c63240709363de30ca43d684d9fd13ebd72e67222c7e16a45d62e9dd1497dc9332909e
7
- data.tar.gz: 0ca40694b1d8f656697128a9b2b49a3f3a796eb68e4226e9e8bc57cb83b46cdf70edfc5d0562950d9f114f76058a2be789f4f9a90746cb6eb64d5cde3586587a
6
+ metadata.gz: ed67ab09a4247ed69c8a12d597010ca7dd1e7f76add17553834d54fa350a3bd93fc402575fdf202ee05bf486ca2c1c386d8f8800daff3b1c8bf17b3704fc6ab5
7
+ data.tar.gz: 0154bdd9747143f0974313aff0a53b03d8252fab6e104af13ebade18d20057cbd8a62c0057032ccef9e9a60d3a441f66d1521a9cac1bd9efe700b87b3fe014f3
@@ -1,3 +1,7 @@
1
+ # 3.1.0 / 2020-10-06
2
+
3
+ * [FEATURE] Remove curb dependency, which allows githubstats to work on Windows systems. Thanks @ajmeese7!
4
+
1
5
  # 3.0.1 / 2018-08-19
2
6
 
3
7
  * [BUGFIX] Fix cap used to decide when to use real_streak GitHub polling
data/README.md CHANGED
@@ -4,7 +4,6 @@ GithubStats
4
4
  [![Gem Version](https://img.shields.io/gem/v/githubstats.svg)](https://rubygems.org/gems/githubstats)
5
5
  [![Build Status](https://img.shields.io/travis/com/akerl/githubstats.svg)](https://travis-ci.com/akerl/githubstats)
6
6
  [![Coverage Status](https://img.shields.io/codecov/c/github/akerl/githubstats.svg)](https://codecov.io/github/akerl/githubstats)
7
- [![Code Quality](https://img.shields.io/codacy/d25d2521df3f4a6b8369edd419438d97.svg)](https://www.codacy.com/app/akerl/githubstats)
8
7
  [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
9
8
 
10
9
  Grabs Github contribution statistics and presents it in an easily consumable format.
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.executables = ['githubstats']
20
20
 
21
21
  s.add_runtime_dependency 'basiccache', '~> 1.0.0'
22
- s.add_runtime_dependency 'curb', '~> 0.9.0'
23
22
  s.add_runtime_dependency 'nokogiri', '~> 1.10.8'
24
23
 
25
24
  s.add_development_dependency 'codecov', '~> 0.1.1'
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'curb'
4
3
  require 'json'
5
4
  require 'nokogiri'
5
+ require 'net/http'
6
6
  require 'date'
7
7
  require 'basiccache'
8
8
 
@@ -141,16 +141,24 @@ module GithubStats
141
141
  # Downloads new data from Github
142
142
 
143
143
  def download(to_date = nil)
144
- url = to_date ? @url + "?to=#{to_date.strftime('%Y-%m-%d')}" : @url
145
- res = Curl::Easy.perform(url)
146
- code = res.response_code
147
- raise("Failed loading data from GitHub: #{url} #{code}") if code != 200
148
- html = Nokogiri::HTML(res.body_str)
144
+ resp = request(to_date)
145
+ html = Nokogiri::HTML(resp)
149
146
  html.css('.day').map do |x|
150
147
  x.attributes.values_at('data-date', 'data-count').map(&:value)
151
148
  end
152
149
  end
153
150
 
151
+ def request(to_date = nil)
152
+ url = to_date ? @url + "?to=#{to_date.strftime('%Y-%m-%d')}" : @url
153
+ # https://stackoverflow.com/a/5786863/6456163
154
+ resp = Net::HTTP.get_response(URI(url))
155
+ code = resp.code
156
+ raise("Failed loading data from GitHub: #{url} #{code}") if code != '200'
157
+ resp.body
158
+ rescue SocketError
159
+ raise RuntimeError
160
+ end
161
+
154
162
  def method_missing(sym, *args, &block)
155
163
  load_data if @last_updated.nil?
156
164
  return super unless @data.respond_to? sym
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Define the version
5
5
  module GithubStats
6
- VERSION = '3.0.2'
6
+ VERSION = '3.1.0'
7
7
  end
@@ -10,7 +10,9 @@ describe GithubStats do
10
10
  describe GithubStats::User do
11
11
  let(:named_user) { GithubStats::User.new 'akerl' }
12
12
  let(:unnamed_user) { GithubStats::User.new }
13
- let(:hash_user) { GithubStats::User.new(name: 'fly', url: 'URL-FOR-%s') }
13
+ let(:hash_user) do
14
+ GithubStats::User.new(name: 'fly', url: 'https://URL-%s')
15
+ end
14
16
 
15
17
  context 'when created with a string' do
16
18
  it 'uses that string as the username' do
@@ -30,7 +32,7 @@ describe GithubStats do
30
32
  expect(hash_user.name).to eql 'fly'
31
33
  end
32
34
  it 'uses the URL from the hash' do
33
- expect(hash_user.url).to eql 'URL-FOR-fly'
35
+ expect(hash_user.url).to eql 'https://URL-fly'
34
36
  end
35
37
  end
36
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: basiccache
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: curb
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.9.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.9.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: nokogiri
43
29
  requirement: !ruby/object:Gem::Requirement