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 +4 -4
- data/.travis.yml +5 -0
- data/lib/github_streak_check.rb +19 -1
- data/lib/github_streak_check/version.rb +1 -1
- data/spec/github_streak_check_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8141f39ba61254d1a2810b0a12322fd071457d
|
4
|
+
data.tar.gz: d99f569e09186bc4ac64db60de9d1641f25f2cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51be5fffcdb3f891f58d297ed876c0ef568152f194cd6a68fcde1e8cfb92ad1023f2cfbe752534cebe783f7ec6194288dff82c942b3d6ed0ecf602a19b6d3ce7
|
7
|
+
data.tar.gz: dcc15822459c9cc2f62c298bfe828ac8249be49978b427533d6275bf8b780812638dbc50bb0477929bed4b45cfc097db925fd8e053509bbd57704d0d4ba65d99
|
data/.travis.yml
CHANGED
data/lib/github_streak_check.rb
CHANGED
@@ -30,11 +30,29 @@ class GithubStreakCheck
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def commited_today?
|
33
|
-
events = JSON.parse(
|
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
|
@@ -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.
|
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-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pony
|