githubstats 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +0 -1
- data/githubstats.gemspec +0 -1
- data/lib/githubstats.rb +14 -6
- data/lib/githubstats/version.rb +1 -1
- data/spec/githubstats_spec.rb +4 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d1760b40fbefddd2aa5c8fba01de7eb8b9d4924ba16c3e6e32030265d1a4a7
|
4
|
+
data.tar.gz: b7c45953695c48422332f089338443e9d622d4c25991676a32e6ed28b9e7402d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed67ab09a4247ed69c8a12d597010ca7dd1e7f76add17553834d54fa350a3bd93fc402575fdf202ee05bf486ca2c1c386d8f8800daff3b1c8bf17b3704fc6ab5
|
7
|
+
data.tar.gz: 0154bdd9747143f0974313aff0a53b03d8252fab6e104af13ebade18d20057cbd8a62c0057032ccef9e9a60d3a441f66d1521a9cac1bd9efe700b87b3fe014f3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,6 @@ GithubStats
|
|
4
4
|
[](https://rubygems.org/gems/githubstats)
|
5
5
|
[](https://travis-ci.com/akerl/githubstats)
|
6
6
|
[](https://codecov.io/github/akerl/githubstats)
|
7
|
-
[](https://www.codacy.com/app/akerl/githubstats)
|
8
7
|
[](https://tldrlegal.com/license/mit-license)
|
9
8
|
|
10
9
|
Grabs Github contribution statistics and presents it in an easily consumable format.
|
data/githubstats.gemspec
CHANGED
@@ -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'
|
data/lib/githubstats.rb
CHANGED
@@ -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
|
-
|
145
|
-
|
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
|
data/lib/githubstats/version.rb
CHANGED
data/spec/githubstats_spec.rb
CHANGED
@@ -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)
|
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-
|
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
|
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-
|
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
|