github-calendar 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/lib/github/calendar.rb +12 -25
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1db860b32f94ff0185c51d5f4119ab119a6e03d1
4
- data.tar.gz: 8dc772acfeb8f04a8d5c3d5ec6c416a41fe33da3
3
+ metadata.gz: 8f957567e6a6d0f70e7f4d7f404f770d509db617
4
+ data.tar.gz: 17cc29b533c8f6fcc038a2d9bf6e96c265127bbb
5
5
  SHA512:
6
- metadata.gz: ee7910378e381f8cd798c52fe73473d57d6fa9bf101e8f004df01f4df68d33e22ae58ef99e35a4f16c431d759229c8558135fc3c6280d5b883a22f2cb64e6dc7
7
- data.tar.gz: 68073efde1c5b1a84bcef4ceed875f4d311443e161a19076469248fbb1817fa56c4e9fa41ddc045448f073bc628acdc507720a45b5aea190a53b6183a7c0b8e7
6
+ metadata.gz: ad42265694f9f24fb8bf6b9b055a9bae7ab446bf19255d822e660a0349e54a8d62e16e5bfab5fe0a1b5bc80cb2f3d44019647840215dd5946be58cae73921019
7
+ data.tar.gz: b71748ccc7fe3416df45fd1df132d851edb987c32a25af52b1f9328181d71eb73f2c699865694f294f94dcb1b59154876b5735ac0240cf2214782dd17596a2d6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
  ## Version 1
3
+ ### Version 1.3.0
4
+ * Update for latest GitHub contribution graph changes (#6).
5
+ * The methods relating to contribution streaks have been removed, as GitHub has removed that data.
6
+ * get_total_year is slightly slower, as there is no longer a specific class for the yearly contributions and as a
7
+ result we now have to iterate over all of the level 3 headers until we find that specific one using regex.
8
+ * Fix leftover OpenURI rescuing, which prevented the UserNotFoundException from ever being raised.
9
+
3
10
  ### Version 1.2.1
4
11
  * Pessimistic version requirements. Bump dependencies.
5
12
  * License as MIT.
@@ -13,26 +13,15 @@ module GitHub
13
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
- string = source.css('span.contrib-number')[0].text
17
- string.to_i_separated
18
- end
19
-
20
- # Gets the longest contribution streak (in days) that the user has had.
21
- # @param user [String] See #get_total_year
22
- # @return [Integer] The user's longest contribution streak in days.
23
- def get_longest_streak(user)
24
- source = get_page_source(user)
25
- string = source.css('span.contrib-number')[1].text
26
- string.to_i_separated
27
- end
28
-
29
- # Gets the current contribution streak (in days) that the user is in.
30
- # @param user [String] See #get_total_year
31
- # @return [Integer] The user's current contribution streak in days.
32
- def get_current_streak(user)
33
- source = get_page_source(user)
34
- string = source.css('span.contrib-number')[2].text
35
- string.to_i_separated
16
+ headers = source.css('h3')
17
+ string = nil
18
+ headers.each do |i|
19
+ if /contributions in the last year/ =~ i.text
20
+ string = i.text.to_i_separated
21
+ break
22
+ end
23
+ end
24
+ string || 0
36
25
  end
37
26
 
38
27
  # Gets the weekly contribution count for the past year.
@@ -131,11 +120,9 @@ module GitHub
131
120
  # @return [Nokogiri::HTML::Document] The parsed HTML for the user page
132
121
  # @raise [UserNotFoundException] If the user is not found.
133
122
  def get_page_source(user)
134
- begin
135
- Nokogiri::HTML(Curl.get("https://github.com/#{user}").body_str, &:noblanks)
136
- rescue OpenURI::HTTPError
137
- raise GitHub::Exceptions::UserNotFoundException.new(user)
138
- end
123
+ response = Curl.get("https://github.com/#{user}").body_str
124
+ fail GitHub::Exceptions::UserNotFoundException.new(user) if /Not Found/ =~ response
125
+ Nokogiri::HTML(response, &:noblanks)
139
126
  end
140
127
 
141
128
  # Gets the parsed calendar HTML source for the user profile.
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.2.1
4
+ version: 1.3.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: 2016-04-16 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.5.1
85
+ rubygems_version: 2.6.4
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Getting GitHub user profile calendar data through HTML parsing.