github_streak_check 0.1.1 → 0.2.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
2
  SHA1:
3
- metadata.gz: 211bb95c653fc218ff2df2b580498358a9e29e63
4
- data.tar.gz: 742c3140e01e0fb1ee53c3a1d16916b64c354538
3
+ metadata.gz: 0a8141f39ba61254d1a2810b0a12322fd071457d
4
+ data.tar.gz: d99f569e09186bc4ac64db60de9d1641f25f2cb0
5
5
  SHA512:
6
- metadata.gz: d22c372291759035e239257240212842d3f3ca4cd118b786f924e909328b64f168bea2d6633bd1ab9093d9d6aa80f7308807d69991fcc19431c7e6884d3abcca
7
- data.tar.gz: 93127b83905dd879be2c4ec36164639599eed9b090e99e1d4d73ecc6cd21332735ba17a0ab0fbaa0aa2a22143f84a7a712f010b69003537929b82e6944d43749
6
+ metadata.gz: 51be5fffcdb3f891f58d297ed876c0ef568152f194cd6a68fcde1e8cfb92ad1023f2cfbe752534cebe783f7ec6194288dff82c942b3d6ed0ecf602a19b6d3ce7
7
+ data.tar.gz: dcc15822459c9cc2f62c298bfe828ac8249be49978b427533d6275bf8b780812638dbc50bb0477929bed4b45cfc097db925fd8e053509bbd57704d0d4ba65d99
@@ -1,3 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
+
5
+ notifications:
6
+ email:
7
+ on_success: change
8
+ on_failure: always
@@ -30,11 +30,29 @@ class GithubStreakCheck
30
30
  end
31
31
 
32
32
  def commited_today?
33
- events = JSON.parse(open("https://api.github.com/users/#{@opts[:username]}/events?per_page=300").read)
33
+ events = JSON.parse(get_status)
34
34
  return false if events.length == 0
35
35
 
36
36
  return events.any?{|event|
37
37
  Time.parse(event["created_at"]).in_time_zone(@pst).to_date == @pst.today
38
38
  }
39
39
  end
40
+
41
+ MAX_TRY = 5
42
+ def get_status
43
+ try = 1
44
+ begin
45
+ open("https://api.github.com/users/#{@opts[:username]}/events?per_page=300").read
46
+ rescue OpenURI::HTTPError => ex
47
+ if try == MAX_TRY
48
+ raise
49
+ else
50
+ puts "#{ex.message} (#{ex.class})"
51
+ sleep 30
52
+
53
+ try += 1
54
+ retry
55
+ end
56
+ end
57
+ end
40
58
  end
@@ -1,3 +1,3 @@
1
1
  class GithubStreakCheck
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -70,4 +70,22 @@ describe GithubStreakCheck do
70
70
  end
71
71
  end
72
72
  end
73
+
74
+ describe "#get_status" do
75
+ before do
76
+ @max_try = GithubStreakCheck::MAX_TRY
77
+ @checker.stub(:puts)
78
+ end
79
+
80
+ it "raises error after MAX_TRY" do
81
+ @checker.should_receive(:open).exactly(@max_try).times {
82
+ raise OpenURI::HTTPError.new(:dummy, :dummy)
83
+ }
84
+ @checker.should_receive(:sleep).exactly(@max_try-1).times
85
+
86
+ expect {
87
+ @checker.get_status
88
+ }.to raise_error(OpenURI::HTTPError)
89
+ end
90
+ end
73
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_streak_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka HARA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-12 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pony