diff options
Diffstat (limited to 'lib/github/response.rb')
-rw-r--r-- | lib/github/response.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/github/response.rb b/lib/github/response.rb new file mode 100644 index 00000000000..c34b69aa4ea --- /dev/null +++ b/lib/github/response.rb @@ -0,0 +1,22 @@ +module Github + class Response + attr_reader :raw, :headers, :body, :status + + def initialize(response) + @raw = response + @headers = response.headers + @body = response.body + @status = response.status + 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 |