gitlab-org--gitlab-foss/lib/github/response.rb

22 lines
463 B
Ruby
Raw Normal View History

2017-04-12 01:33:54 +00:00
module Github
class Response
attr_reader :headers, :body, :status
2017-04-12 01:33:54 +00:00
def initialize(headers, body, status)
@headers = headers
@body = Oj.load(body, class_cache: false, mode: :compat)
@status = status
2017-04-12 01:33:54 +00:00
end
def rels
links = headers['Link'].to_s.split(', ').map do |link|
href, name = link.match(/<(.*?)>; rel="(\w+)"/).captures
[name.to_sym, href]
end
Hash[*links.flatten]
end
end
end