github-calendar 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/github/calendar.rb +18 -23
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf50a1eafa4c9bc2d866e025534f0d01ee71ba5
|
4
|
+
data.tar.gz: 4d734ac9bf923934cca3d082f422ba1e01ba1d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275737388b653d3f376f3693c1cb504e4aa9777588b8c28253e8c0a2da4f0bedbc3c23111c25672ff5eff9542c77bc0d52973fc9896b65f5176e9ed89b026294
|
7
|
+
data.tar.gz: 1c24863ea5beb5276cf4c11d78952055aebbfca58de6539428acc57f48f4656a42242a51ceb98e841fa5651fc88a8573c93c27fc76295941dfca4d55bb4b8cbe
|
data/CHANGELOG.md
CHANGED
data/lib/github/calendar.rb
CHANGED
@@ -10,7 +10,7 @@ module GitHub
|
|
10
10
|
|
11
11
|
# Gets the total number of contributions for the past year.
|
12
12
|
# @param user [String] The username to get this data for.
|
13
|
-
# @return [
|
13
|
+
# @return [Integer] An integer value of their total contributions this year.
|
14
14
|
def get_total_year(user)
|
15
15
|
source = get_page_source(user)
|
16
16
|
string = source.css('span.contrib-number')[0].text
|
@@ -19,7 +19,7 @@ module GitHub
|
|
19
19
|
|
20
20
|
# Gets the longest contribution streak (in days) that the user has had.
|
21
21
|
# @param user [String] See #get_total_year
|
22
|
-
# @return [
|
22
|
+
# @return [Integer] The user's longest contribution streak in days.
|
23
23
|
def get_longest_streak(user)
|
24
24
|
source = get_page_source(user)
|
25
25
|
string = source.css('span.contrib-number')[1].text
|
@@ -28,7 +28,7 @@ module GitHub
|
|
28
28
|
|
29
29
|
# Gets the current contribution streak (in days) that the user is in.
|
30
30
|
# @param user [String] See #get_total_year
|
31
|
-
# @return [
|
31
|
+
# @return [Integer] The user's current contribution streak in days.
|
32
32
|
def get_current_streak(user)
|
33
33
|
source = get_page_source(user)
|
34
34
|
string = source.css('span.contrib-number')[2].text
|
@@ -37,15 +37,14 @@ module GitHub
|
|
37
37
|
|
38
38
|
# Gets the weekly contribution count for the past year.
|
39
39
|
# @param user [String] See #get_total_year
|
40
|
-
# @return [Hash] How many contributions they have done each week. Example:
|
41
|
-
# { 0: 0, 1: 8, etc. }
|
40
|
+
# @return [Hash] How many contributions they have done each week. Example: { 0: 0, 1: 8, etc. }
|
42
41
|
def get_weekly(user)
|
43
42
|
weeks = get_calendar(user)
|
44
43
|
ret = {}
|
45
44
|
count = 0
|
46
45
|
weeks[1..-1].each do |k|
|
47
46
|
data = 0
|
48
|
-
capture = k.to_s.scan(/data-count
|
47
|
+
capture = k.to_s.scan(/data-count="(.*?)"/)
|
49
48
|
capture[1..-1].each do |ints|
|
50
49
|
data += ints[0].to_i
|
51
50
|
end
|
@@ -57,14 +56,13 @@ module GitHub
|
|
57
56
|
|
58
57
|
# Gets the daily contribution count for the past year.
|
59
58
|
# @param user [String] See #get_total_year
|
60
|
-
# @return [Hash] How many contributions they have performed each day. See
|
61
|
-
# #get_weekly
|
59
|
+
# @return [Hash] How many contributions they have performed each day. See #get_weekly
|
62
60
|
def get_daily(user)
|
63
61
|
weeks = get_calendar(user)
|
64
62
|
ret = {}
|
65
63
|
count = 0
|
66
64
|
weeks[1..-1].each do |k|
|
67
|
-
capture = k.to_s.scan(/data-count
|
65
|
+
capture = k.to_s.scan(/data-count="(.*?)"/)
|
68
66
|
capture[1..-1].each do |i|
|
69
67
|
ret[count] = i[0].to_i
|
70
68
|
count += 1
|
@@ -75,9 +73,8 @@ module GitHub
|
|
75
73
|
|
76
74
|
# Gets the monthly contribution count for the past year.
|
77
75
|
# @param user [String] See #get_total_year
|
78
|
-
# @return [Hash] How many contributions they have performed each month.
|
79
|
-
#
|
80
|
-
# 12 is December.
|
76
|
+
# @return [Hash] How many contributions they have performed each month. Months are listed as their string integers,
|
77
|
+
# e.g., 01 is January and 12 is December.
|
81
78
|
def get_monthly(user)
|
82
79
|
weeks = get_calendar(user)
|
83
80
|
ret = {
|
@@ -95,8 +92,8 @@ module GitHub
|
|
95
92
|
'12' => 0
|
96
93
|
}
|
97
94
|
weeks[1..-1].each do |k|
|
98
|
-
date = k.to_s.scan(/data-date
|
99
|
-
capture = k.to_s.scan(/data-count
|
95
|
+
date = k.to_s.scan(/data-date=".*-(.*?)-/)
|
96
|
+
capture = k.to_s.scan(/data-count="(.*?)"/)
|
100
97
|
capture[1..-1].each do |i|
|
101
98
|
ret[date[0][0]] += i[0].to_i
|
102
99
|
end
|
@@ -106,7 +103,7 @@ module GitHub
|
|
106
103
|
|
107
104
|
# Gets the average weekly number of contributions by the user.
|
108
105
|
# @param user [String] See #get_total_year
|
109
|
-
# @return [
|
106
|
+
# @return [Integer] The average number of contributions.
|
110
107
|
def get_average_week(user)
|
111
108
|
weekly = get_weekly(user)
|
112
109
|
get_average(weekly)
|
@@ -114,7 +111,7 @@ module GitHub
|
|
114
111
|
|
115
112
|
# Gets the average daily number of contributions by the user.
|
116
113
|
# @param user [String] See #get_total_year
|
117
|
-
# @return [
|
114
|
+
# @return [Integer] See #get_average_week
|
118
115
|
def get_average_day(user)
|
119
116
|
daily = get_daily(user)
|
120
117
|
get_average(daily)
|
@@ -122,7 +119,7 @@ module GitHub
|
|
122
119
|
|
123
120
|
# Gets the average monthly number of contributions by the user.
|
124
121
|
# @param user [String] See #get_total_year
|
125
|
-
# @return [
|
122
|
+
# @return [Integer] See #get_average_week
|
126
123
|
def get_average_month(user)
|
127
124
|
monthly = get_monthly(user)
|
128
125
|
get_average(monthly)
|
@@ -144,18 +141,16 @@ module GitHub
|
|
144
141
|
|
145
142
|
# Gets the parsed calendar HTML source for the user profile.
|
146
143
|
# @param user [String] See #get_total_year
|
147
|
-
# @return [Nokogiri::XML::NodeSet] The NodeSet for all the g's in the
|
148
|
-
#
|
149
|
-
# you will probably want to skip the first, as it is the total yearly.
|
150
|
-
# @return [Nil] See #get_total_year
|
144
|
+
# @return [Nokogiri::XML::NodeSet] The NodeSet for all the g's in the calendar. Consider this as an array of all
|
145
|
+
# the weeks. In iteration, you will probably want to skip the first, as it is the total yearly.
|
151
146
|
def get_calendar(user)
|
152
147
|
source = get_page_source(user)
|
153
148
|
source.css('svg.js-calendar-graph-svg g')
|
154
149
|
end
|
155
150
|
|
156
151
|
# Gets an average for all the integer values in a hash.
|
157
|
-
# @param [Hash] The hash to get the average for.
|
158
|
-
# @return [
|
152
|
+
# @param hash [Hash] The hash to get the average for.
|
153
|
+
# @return [Integer] The average of the values.
|
159
154
|
def get_average(hash)
|
160
155
|
hash_max = hash.length
|
161
156
|
hash_total = 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.6.
|
19
|
+
version: 1.6.7.2
|
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: 1.6.
|
26
|
+
version: 1.6.7.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: string-utility
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.7.1
|
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: 2.
|
40
|
+
version: 2.7.1
|
41
41
|
description: A library that allows for quick HTML parsing of GitHub user profile contribution
|
42
42
|
calendars. This project is part of the GitHub User Language Statistics project.
|
43
43
|
email: elifosterwy@gmail.com
|
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
62
|
+
version: 2.3.0
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
@@ -67,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.5.1
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: Getting GitHub user profile calendar data through HTML parsing.
|
74
74
|
test_files: []
|
75
|
-
has_rdoc:
|