summaryrefslogtreecommitdiff
path: root/lib/github/response.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-04-11 22:33:54 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-04-24 16:17:52 -0300
commitfc42f3dffa364a360c76ff2785813d74f42016c7 (patch)
tree1bf7e3a340e910756ddde22bd4b8bdb1b6429048 /lib/github/response.rb
parent7030eb3286613be919e12daf95c43061b49aa5f5 (diff)
downloadgitlab-ce-fc42f3dffa364a360c76ff2785813d74f42016c7.tar.gz
Add basic client for the GitHub API
Diffstat (limited to 'lib/github/response.rb')
-rw-r--r--lib/github/response.rb22
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