githubstats 2.0.0 → 3.0.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
- SHA1:
3
- metadata.gz: c24647a4f63470021797a9309535a4438a830c1b
4
- data.tar.gz: 7c42bba5c6566f54cab50f0e8873e0e1c3506a44
2
+ SHA256:
3
+ metadata.gz: b7e43001571c1bb4b2d76b82925a2a3a7421822e66cc0f59cc8d1ad9925621ca
4
+ data.tar.gz: 1402a5f8d73b405a3bc7dcbb331a6cf8cfb00e8722ba9ccac16ec5e023a4040e
5
5
  SHA512:
6
- metadata.gz: ca040015df256cea023906e5504f59b38ca5fe552e2b3f4e44956e8faf9793be060896afa655252699e1f7d84d84673b3ebce091b8a53aac5ab7466ba9a787bb
7
- data.tar.gz: 5cff21515fdd91ebba43d39cdb9fb6a3c95122f95a9f5fb2e1d205e98f0dc7ad72b64628a52bfeacc86d6721ff5af82109f2d7e952b1291fb162477802ce7085
6
+ metadata.gz: 418dff84a32e2aefa9282ff636f3bb18540058cff3e3c542fbb485382021734351e593c26fb56c29a0a4e995b4e29a74153c1f253cc9a1f833d1af4ba50b6047
7
+ data.tar.gz: 9b3077bd88e29ae5074220960c2748a53261117d478125e2a4d6e9419b53f1f02231f76caeeff5132b216d19e5e66821ea83ae32d5adf202ab6f78e3d3013a5f
@@ -1,3 +1,3 @@
1
- 2.4.2
2
- 2.3.5
3
- 2.2.8
1
+ 2.5.1
2
+ 2.4.4
3
+ 2.3.7
@@ -1,25 +1,11 @@
1
- Prospectus.extra_dep('file', 'prospectus_circleci')
2
-
3
1
  my_slug = 'akerl/githubstats'
4
2
 
3
+ Prospectus.extra_dep('file', 'prospectus_circleci')
4
+ Prospectus.extra_dep('file', 'prospectus_gems')
5
+
5
6
  item do
6
7
  noop
7
8
 
8
- deps do
9
- item do
10
- name 'gems'
11
-
12
- expected do
13
- static
14
- set 'green'
15
- end
16
-
17
- actual do
18
- gemnasium
19
- slug my_slug
20
- end
21
- end
22
- end
23
-
9
+ extend ProspectusGems::Gemspec.new
24
10
  extend ProspectusCircleci::Build.new(my_slug)
25
11
  end
@@ -1,3 +1,10 @@
1
+ # 3.0.0 / 2018-07-18
2
+
3
+ * [BUGFIX] Update to work with recent GitHub changes for historic streak lookup API
4
+ * [FEATURE] Historic GitHub streaks now show actual stats instead of `-1` placeholders
5
+ * [FEATURE] It is now possible to convert a datapoint back to its original format with `.to_a`
6
+ * [FEATURE] Added `.start_date` and `.end_date` to Data object
7
+
1
8
  # 2.0.0 / 2017-09-29
2
9
 
3
10
  * [BUGFIX] Fail cleanly if Github responds with a bad HTTP code
@@ -1,5 +1,5 @@
1
1
  require 'English'
2
- $LOAD_PATH.unshift File.expand_path('../lib/', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
3
3
  require 'githubstats/version'
4
4
 
5
5
  Gem::Specification.new do |s|
@@ -18,15 +18,15 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files spec/*`.split
19
19
  s.executables = ['githubstats']
20
20
 
21
- s.add_runtime_dependency 'curb', '~> 0.9.0'
22
21
  s.add_runtime_dependency 'basiccache', '~> 1.0.0'
22
+ s.add_runtime_dependency 'curb', '~> 0.9.0'
23
23
  s.add_runtime_dependency 'nokogiri', '~> 1.8.0'
24
24
 
25
- s.add_development_dependency 'timecop', '~> 0.9.0'
26
- s.add_development_dependency 'rubocop', '~> 0.50.0'
27
- s.add_development_dependency 'goodcop', '~> 0.1.0'
28
- s.add_development_dependency 'rake', '~> 12.1.0'
29
25
  s.add_development_dependency 'codecov', '~> 0.1.1'
30
- s.add_development_dependency 'rspec', '~> 3.6.0'
31
- s.add_development_dependency 'fuubar', '~> 2.2.0'
26
+ s.add_development_dependency 'fuubar', '~> 2.3.0'
27
+ s.add_development_dependency 'goodcop', '~> 0.5.0'
28
+ s.add_development_dependency 'rake', '~> 12.3.0'
29
+ s.add_development_dependency 'rspec', '~> 3.7.0'
30
+ s.add_development_dependency 'rubocop', '~> 0.58.0'
31
+ s.add_development_dependency 'timecop', '~> 0.9.0'
32
32
  end
@@ -51,8 +51,7 @@ module GithubStats
51
51
  @name = params[:name] || guess_user
52
52
  @url = (params[:url] || DEFAULT_URL) % @name
53
53
  @last_updated = nil
54
- enable_caching %i[streak longest_streak streaks real_streak
55
- real_streak_start]
54
+ enable_caching %i[streak longest_streak streaks]
56
55
  end
57
56
 
58
57
  ##
@@ -118,33 +117,31 @@ module GithubStats
118
117
 
119
118
  def load_data
120
119
  @data = GithubStats::Data.new download
121
- @last_updated = DateTime.now
120
+ @last_updated = Time.now
122
121
  end
123
122
 
124
123
  ##
125
- # Set a custom longest_streak that takes into account GitHub,
126
- # which reports full length but only gives data for a year
127
-
128
- def real_streak_start(chart_start)
129
- res = GithubStats::Data.new download(chart_start.strftime('%Y-%m-%d'))
130
- last_streak_start = res.streaks.last.first.date
131
- new_chart_start = res.raw.first.date
132
- return last_streak_start unless last_streak_start == new_chart_start
133
- real_streak_start(new_chart_start)
124
+ # Set a custom longest_streak that takes into account GitHub's
125
+ # historical records
126
+
127
+ def real_streak_rewind(partial_streak)
128
+ new_data = download(partial_streak.first.date - 1)
129
+ old_data = partial_streak.map(&:to_a)
130
+ new_stats = GithubStats::Data.new(new_data + old_data)
131
+ partial_streak = new_stats.streaks.last
132
+ return partial_streak if partial_streak.first.date != new_stats.start_date
133
+ real_streak_rewind partial_streak
134
134
  end
135
135
 
136
136
  def real_streak
137
- existing = data.streaks.last
138
- first_date = existing.first.date
139
- extra_size = (first_date - real_streak_start(first_date))
140
- [-1] * extra_size + existing
137
+ @real_streak ||= real_streak_rewind(data.streaks.last)
141
138
  end
142
139
 
143
140
  ##
144
141
  # Downloads new data from Github
145
142
 
146
- def download(from = nil)
147
- url = from ? @url + "?from=#{from}" : @url
143
+ def download(to_date = nil)
144
+ url = to_date ? @url + "?to=#{to_date.strftime('%Y-%m-%d')}" : @url
148
145
  res = Curl::Easy.perform(url)
149
146
  code = res.response_code
150
147
  raise("Failed loading data from GitHub: #{url} #{code}") if code != 200
@@ -12,7 +12,11 @@ module GithubStats
12
12
  ##
13
13
  # Helper struct for defining datapoints
14
14
 
15
- Datapoint = Struct.new(:date, :score)
15
+ Datapoint = Struct.new(:date, :score) do
16
+ def to_a
17
+ [date.strftime('%Y-%m-%d'), score.to_s]
18
+ end
19
+ end
16
20
 
17
21
  ##
18
22
  # Data class for calculations
@@ -31,7 +35,8 @@ module GithubStats
31
35
  def initialize(data)
32
36
  @raw = data.map { |d, s| Datapoint.new(Date.parse(d), s.to_i) }
33
37
  enable_caching %i[to_h today streaks longest_streak streak max mean
34
- std_var quartile_boundaries quartiles]
38
+ std_var quartile_boundaries quartiles start_date
39
+ end_date]
35
40
  end
36
41
 
37
42
  ##
@@ -43,6 +48,19 @@ module GithubStats
43
48
  end
44
49
  end
45
50
 
51
+ ##
52
+ # The start of the dataset
53
+
54
+ def start_date
55
+ @raw.first.date
56
+ end
57
+
58
+ ##
59
+ # The end of the dataset
60
+ def end_date
61
+ @raw.last.date
62
+ end
63
+
46
64
  ##
47
65
  # The score for today
48
66
 
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Define the version
5
5
  module GithubStats
6
- VERSION = '2.0.0'.freeze
6
+ VERSION = '3.0.0'.freeze
7
7
  end
@@ -7,8 +7,8 @@ describe GithubStats do
7
7
  end
8
8
 
9
9
  it 'defines a Datapoint object' do
10
- a = GithubStats::Datapoint.new(DateTime.now, 4)
11
- expect(a.date).to be_an_instance_of DateTime
10
+ a = GithubStats::Datapoint.new(Time.now, 4)
11
+ expect(a.date).to be_an_instance_of Time
12
12
  expect(a.score).to eql 4
13
13
  end
14
14
 
@@ -39,7 +39,7 @@ describe GithubStats do
39
39
  expect(named_user.last_updated).to be_nil
40
40
  named_user.data
41
41
  expect(named_user.instance_variables).to include(:@data)
42
- expect(named_user.last_updated).to be_an_instance_of DateTime
42
+ expect(named_user.last_updated).to be_an_instance_of Time
43
43
  end
44
44
 
45
45
  it 'raises an exception if it cannot load data' do
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.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: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: curb
14
+ name: basiccache
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: basiccache
28
+ name: curb
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 0.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: 0.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,103 +53,103 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: timecop
56
+ name: codecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.0
61
+ version: 0.1.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.0
68
+ version: 0.1.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: fuubar
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.50.0
75
+ version: 2.3.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.50.0
82
+ version: 2.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: goodcop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.1.0
89
+ version: 0.5.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.1.0
96
+ version: 0.5.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 12.1.0
103
+ version: 12.3.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 12.1.0
110
+ version: 12.3.0
111
111
  - !ruby/object:Gem::Dependency
112
- name: codecov
112
+ name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.1.1
117
+ version: 3.7.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.1.1
124
+ version: 3.7.0
125
125
  - !ruby/object:Gem::Dependency
126
- name: rspec
126
+ name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.6.0
131
+ version: 0.58.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.6.0
138
+ version: 0.58.0
139
139
  - !ruby/object:Gem::Dependency
140
- name: fuubar
140
+ name: timecop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 2.2.0
145
+ version: 0.9.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 2.2.0
152
+ version: 0.9.0
153
153
  description: Pulls the statistics from Github's user contribution chart and provides
154
154
  an interface for analyzing that data
155
155
  email: me@lesaker.org
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.6.13
208
+ rubygems_version: 2.7.6
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Present Github contributions stats in a consumable format