module Hub::GitHubAPI::HttpMethods::ResponseMethods
Decorator for Net::HTTPResponse
Decorator for Net::HTTPResponse
Public Instance Methods
data()
click to toggle source
# File lib/hub/github_api.rb, line 176 def data() @data ||= JSON.parse(body) end
data?()
click to toggle source
# File lib/hub/github_api.rb, line 175 def data?() content_type =~ /\bjson\b/ end
error_message()
click to toggle source
# File lib/hub/github_api.rb, line 178 def error_message() error_sentences || data['message'] end
error_message?()
click to toggle source
# File lib/hub/github_api.rb, line 177 def error_message?() data? and data['errors'] || data['message'] end
error_sentences()
click to toggle source
# File lib/hub/github_api.rb, line 180 def error_sentences data['errors'].map do |err| case err['code'] when 'custom' then err['message'] when 'missing_field' %Q(Missing field: "%s") % err['field'] when 'already_exists' %Q(Duplicate value for "%s") % err['field'] when 'invalid' %Q(Invalid value for "%s": "%s") % [ err['field'], err['value'] ] when 'unauthorized' %Q(Not allowed to change field "%s") % err['field'] end end.compact if data['errors'] end
links()
click to toggle source
# File lib/hub/github_api.rb, line 195 def links @links ||= self['link'].to_s.scan(/<(.+?)>; rel="(.+?)"/).inject({}) do |map, (url, rel)| map.update(rel.to_sym => URI.parse(url)) end end
next_url()
click to toggle source
# File lib/hub/github_api.rb, line 200 def next_url() links[:next] end
status()
click to toggle source
# File lib/hub/github_api.rb, line 174 def status() code.to_i end
success?()
click to toggle source
# File lib/hub/github_api.rb, line 179 def success?() Net::HTTPSuccess === self end