githubstats 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circle-ruby +3 -0
- data/CHANGELOG.md +4 -0
- data/circle.yml +2 -8
- data/githubstats.gemspec +4 -4
- data/lib/githubstats.rb +52 -3
- data/lib/githubstats/data.rb +2 -2
- data/lib/githubstats/version.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18eb056e846349fdd755a7724f69c8040a037070
|
4
|
+
data.tar.gz: ece0a53aa1a7941694120ffd26fc9ddbe0b4a0ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86677eae394cae76f19d9064d3451b14b8a914ae2d4a3447b8f6dbd8f71f42cb2cc0baef6e30f90e37f8bfff3d34bc118afa274266c8f118ce27b4c8980dd07e
|
7
|
+
data.tar.gz: 92a2b5adab28a47d958213824a38340d0540b684f1ca81e1be12282cb7e66344a7506b4e7eb8a690295512d41dff2020878e39c19621c44c1edae5b7dbd3f75a
|
data/.circle-ruby
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 1.3.0 / 2016-09-14
|
2
|
+
|
3
|
+
* [FEATURE] Re-adds support for streak lookups longer than 366 days from GitHub, now that they've brought back older commit info
|
4
|
+
|
1
5
|
# 1.2.0 / 2016-05-19
|
2
6
|
|
3
7
|
* [BUGFIX] Remove support for streak lookup longer than 366 days from GitHub, since they removed display of longer streaks. :(
|
data/circle.yml
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
dependencies:
|
2
2
|
override:
|
3
|
-
|
4
|
-
- 'rvm-exec 2.0.0-p645 bundle install'
|
5
|
-
- 'rvm-exec 2.1.6 bundle install'
|
6
|
-
- 'rvm-exec 2.2.2 bundle install'
|
3
|
+
- 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle install || exit 1 ; done'
|
7
4
|
test:
|
8
5
|
override:
|
9
|
-
|
10
|
-
- 'rvm-exec 2.0.0-p645 bundle exec rake'
|
11
|
-
- 'rvm-exec 2.1.6 bundle exec rake'
|
12
|
-
- 'rvm-exec 2.2.2 bundle exec rake'
|
6
|
+
- 'for i in $(cat .circle-ruby) ; do rvm-exec $i bundle exec rake || exit 1 ; done'
|
data/githubstats.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_runtime_dependency 'nokogiri', '~> 1.6.5'
|
23
23
|
|
24
24
|
s.add_development_dependency 'timecop', '~> 0.8.0'
|
25
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
26
|
-
s.add_development_dependency 'rake', '~> 11.
|
25
|
+
s.add_development_dependency 'rubocop', '~> 0.42.0'
|
26
|
+
s.add_development_dependency 'rake', '~> 11.2.0'
|
27
27
|
s.add_development_dependency 'codecov', '~> 0.1.1'
|
28
|
-
s.add_development_dependency 'rspec', '~> 3.
|
29
|
-
s.add_development_dependency 'fuubar', '~> 2.
|
28
|
+
s.add_development_dependency 'rspec', '~> 3.5.0'
|
29
|
+
s.add_development_dependency 'fuubar', '~> 2.2.0'
|
30
30
|
end
|
data/lib/githubstats.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'curb'
|
3
3
|
require 'json'
|
4
4
|
require 'nokogiri'
|
5
|
+
require 'date'
|
6
|
+
require 'basiccache'
|
5
7
|
|
6
8
|
##
|
7
9
|
# Rugged is used if available to look up the user's Github username
|
@@ -36,6 +38,8 @@ module GithubStats
|
|
36
38
|
##
|
37
39
|
# User object
|
38
40
|
class User
|
41
|
+
include MethodCacher
|
42
|
+
|
39
43
|
attr_reader :name, :url, :data, :last_updated
|
40
44
|
|
41
45
|
##
|
@@ -46,6 +50,8 @@ module GithubStats
|
|
46
50
|
@name = params[:name] || guess_user
|
47
51
|
@url = (params[:url] || DEFAULT_URL) % @name
|
48
52
|
@last_updated = nil
|
53
|
+
enable_caching [:streak, :longest_streak, :streaks, :real_streak,
|
54
|
+
:real_streak_start]
|
49
55
|
end
|
50
56
|
|
51
57
|
##
|
@@ -56,6 +62,29 @@ module GithubStats
|
|
56
62
|
end
|
57
63
|
alias inspect to_s
|
58
64
|
|
65
|
+
##
|
66
|
+
# Set a custom streaks value that takes into account GitHub,
|
67
|
+
# which makes available streak data for longer than a year
|
68
|
+
|
69
|
+
def streak
|
70
|
+
return [] if streaks.empty?
|
71
|
+
streaks.last.last.date >= Date.today - 1 ? streaks.last : []
|
72
|
+
end
|
73
|
+
|
74
|
+
def streaks
|
75
|
+
naive = data.streaks
|
76
|
+
return naive if naive.last.size < 365
|
77
|
+
[real_streak]
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Set a custom longest_streak to account for the overriden streak
|
82
|
+
|
83
|
+
def longest_streak
|
84
|
+
return data.longest_streak if data.longest_streak.size < 365
|
85
|
+
streak
|
86
|
+
end
|
87
|
+
|
59
88
|
##
|
60
89
|
# Lazy loader for data
|
61
90
|
|
@@ -67,7 +96,7 @@ module GithubStats
|
|
67
96
|
##
|
68
97
|
# Adjust respond_to? to properly respond with patched method_missing
|
69
98
|
|
70
|
-
def
|
99
|
+
def respond_to_missing?(method, include_private = false)
|
71
100
|
load_data if @last_updated.nil?
|
72
101
|
super || @data.respond_to?(method, include_private)
|
73
102
|
end
|
@@ -91,11 +120,31 @@ module GithubStats
|
|
91
120
|
@last_updated = DateTime.now
|
92
121
|
end
|
93
122
|
|
123
|
+
##
|
124
|
+
# Set a custom longest_streak that takes into account GitHub,
|
125
|
+
# which reports full length but only gives data for a year
|
126
|
+
|
127
|
+
def real_streak_start(chart_start)
|
128
|
+
res = GithubStats::Data.new download(chart_start.strftime('%Y-%m-%d'))
|
129
|
+
last_streak_start = res.streaks.last.first.date
|
130
|
+
new_chart_start = res.raw.first.date
|
131
|
+
return last_streak_start unless last_streak_start == new_chart_start
|
132
|
+
real_streak_start(new_chart_start)
|
133
|
+
end
|
134
|
+
|
135
|
+
def real_streak
|
136
|
+
existing = data.streaks.last
|
137
|
+
first_date = existing.first.date
|
138
|
+
extra_size = (first_date - real_streak_start(first_date))
|
139
|
+
[-1] * extra_size + existing
|
140
|
+
end
|
141
|
+
|
94
142
|
##
|
95
143
|
# Downloads new data from Github
|
96
144
|
|
97
|
-
def download
|
98
|
-
|
145
|
+
def download(from = nil)
|
146
|
+
url = from ? @url + "?from=#{from}" : @url
|
147
|
+
svg = Curl::Easy.perform(url).body_str
|
99
148
|
html = Nokogiri::HTML(svg)
|
100
149
|
html.css('.day').map do |x|
|
101
150
|
x.attributes.values_at('data-date', 'data-count').map(&:value)
|
data/lib/githubstats/data.rb
CHANGED
@@ -67,7 +67,7 @@ module GithubStats
|
|
67
67
|
|
68
68
|
def streaks
|
69
69
|
streaks = @raw.each_with_object(Array.new(1, [])) do |point, acc|
|
70
|
-
point.score
|
70
|
+
point.score.zero? ? acc << [] : acc.last << point
|
71
71
|
end
|
72
72
|
streaks.reject!(&:empty?)
|
73
73
|
streaks
|
@@ -124,7 +124,7 @@ module GithubStats
|
|
124
124
|
# They only consider the first 3 or 1, based on the mean and max of the set
|
125
125
|
|
126
126
|
def gh_outliers
|
127
|
-
outliers.take(
|
127
|
+
outliers.take(6 > max.score - mean || 15 > max.score ? 1 : 3)
|
128
128
|
end
|
129
129
|
|
130
130
|
##
|
data/lib/githubstats/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.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: 2016-
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.42.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.
|
82
|
+
version: 0.42.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 11.
|
89
|
+
version: 11.2.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: 11.
|
96
|
+
version: 11.2.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: codecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
117
|
+
version: 3.5.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: 3.
|
124
|
+
version: 3.5.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: fuubar
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
131
|
+
version: 2.2.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: 2.
|
138
|
+
version: 2.2.0
|
139
139
|
description: Pulls the statistics from Github's user contribution chart and provides
|
140
140
|
an interface for analyzing that data
|
141
141
|
email: me@lesaker.org
|
@@ -144,6 +144,7 @@ executables:
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
+
- ".circle-ruby"
|
147
148
|
- ".gitignore"
|
148
149
|
- ".prospectus"
|
149
150
|
- ".rspec"
|