Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
00912ed9
Commit
00912ed9
authored
Apr 13, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Github response
parent
4a3b895d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
lib/github/client.rb
lib/github/client.rb
+2
-3
lib/github/response.rb
lib/github/response.rb
+9
-5
No files found.
lib/github/client.rb
View file @
00912ed9
...
@@ -2,7 +2,7 @@ module Github
...
@@ -2,7 +2,7 @@ module Github
class
Client
class
Client
attr_reader
:connection
attr_reader
:connection
def
initialize
(
token
)
def
initialize
(
token
=
'881a01d03026458e51285a4c7038c9fe4daa5561'
)
@connection
=
Faraday
.
new
(
url:
'https://api.github.com'
)
do
|
faraday
|
@connection
=
Faraday
.
new
(
url:
'https://api.github.com'
)
do
|
faraday
|
faraday
.
authorization
'token'
,
token
faraday
.
authorization
'token'
,
token
faraday
.
adapter
:net_http
faraday
.
adapter
:net_http
...
@@ -13,8 +13,7 @@ module Github
...
@@ -13,8 +13,7 @@ module Github
rate_limit
=
RateLimit
.
new
(
connection
)
rate_limit
=
RateLimit
.
new
(
connection
)
sleep
rate_limit
.
reset_in
if
rate_limit
.
exceed?
sleep
rate_limit
.
reset_in
if
rate_limit
.
exceed?
response
=
connection
.
get
(
url
,
query
)
Github
::
Response
.
new
(
connection
.
get
(
url
,
query
))
Github
::
Response
.
new
(
response
.
headers
,
response
.
body
,
response
.
status
)
end
end
end
end
end
end
lib/github/response.rb
View file @
00912ed9
module
Github
module
Github
class
Response
class
Response
attr_reader
:
headers
,
:body
,
:status
attr_reader
:
raw
,
:headers
,
:status
def
initialize
(
headers
,
body
,
status
)
def
initialize
(
response
)
@headers
=
headers
@raw
=
response
@body
=
Oj
.
load
(
body
,
class_cache:
false
,
mode: :compat
)
@headers
=
response
.
headers
@status
=
status
@status
=
response
.
status
end
def
body
@body
||=
Oj
.
load
(
raw
.
body
,
class_cache:
false
,
mode: :compat
)
end
end
def
rels
def
rels
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment