@@ -62,40 +62,58 @@ def contributors_url
62
62
end
63
63
64
64
def contributors
65
- JSON . parse ( open ( contributors_url ) . read )
65
+ begin
66
+ JSON . parse ( open ( contributors_url ) . read )
67
+ rescue OpenURI ::HTTPError => the_error
68
+ puts "Whoops got a bad status code from github: #{ the_error . message } "
69
+ nil
70
+ end
66
71
end
67
72
68
73
def commits
69
- JSON . parse ( open ( commits_url ) . read )
74
+ begin
75
+ JSON . parse ( open ( commits_url ) . read )
76
+ rescue OpenURI ::HTTPError => the_error
77
+ puts "Whoops got a bad status code from github: #{ the_error . message } "
78
+ nil
79
+ end
70
80
end
71
81
72
82
def get_authors
73
- commits . map do |x |
83
+ if commits
84
+ commits . map do |x |
74
85
{
75
86
:name => x [ 'author' ] [ 'login' ] ,
76
87
:avatar => x [ 'author' ] [ 'avatar_url' ] ,
77
88
:url => x [ 'author' ] [ 'html_url' ]
78
89
}
79
- end . uniq . flatten . group_by { |x | x [ :name ] }
90
+ end . uniq . flatten . group_by { |x | x [ :name ] }
91
+ end
80
92
end
81
93
82
94
def get_activity
83
- commits . map do |x |
84
- {
85
- :author_name => x [ 'author' ] [ 'login' ] ,
86
- :merge_date => Time . parse ( x [ 'commit' ] [ 'author' ] [ 'date' ] ) . strftime ( "%d-%B-%Y" ) ,
87
- :commit_message => x [ 'commit' ] [ 'message' ] ,
88
- :commit_url => "https://github.com/sinatra/sinatra-recipes/commit/#{ x [ 'sha' ] } "
89
- }
90
- end . group_by { |x | x [ :merge_date ] }
95
+ if commits
96
+ commits . map do |x |
97
+ {
98
+ :author_name => x [ 'author' ] [ 'login' ] ,
99
+ :merge_date => Time . parse ( x [ 'commit' ] [ 'author' ] [ 'date' ] ) . strftime ( "%d-%B-%Y" ) ,
100
+ :commit_message => x [ 'commit' ] [ 'message' ] ,
101
+ :commit_url => "https://github.com/sinatra/sinatra-recipes/commit/#{ x [ 'sha' ] } "
102
+ }
103
+ end . group_by { |x | x [ :merge_date ] }
104
+ else
105
+ nil
106
+ end
91
107
end
92
108
93
109
def get_activity_by_author
94
- get_activity . map do |k , v |
95
- {
96
- :date => k ,
97
- :activity_by_author => v . group_by { |z | z [ :author_name ] }
98
- }
110
+ if get_activity
111
+ get_activity . map do |k , v |
112
+ {
113
+ :date => k ,
114
+ :activity_by_author => v . group_by { |z | z [ :author_name ] }
115
+ }
116
+ end
99
117
end
100
118
end
101
119
end
@@ -130,7 +148,11 @@ def get_activity_by_author
130
148
pass if params [ :topic ] == '..'
131
149
@authors = get_authors
132
150
@activity = get_activity_by_author
133
- markdown :'activity/README'
151
+ if @authors && @activity
152
+ markdown :'activity/README'
153
+ else
154
+ "Not available at this time."
155
+ end
134
156
end
135
157
136
158
get '/style.css' do
@@ -224,7 +246,7 @@ def get_activity_by_author
224
246
p
225
247
| These recipes are provided by the following outstanding members of the Sinatra
226
248
| community:
227
- dl id="contributors"
249
+ dl id="contributors"
228
250
- @contributors.each do |contributor|
229
251
dt
230
252
a href="http://github.com/#{contributor["login"]}"
0 commit comments