github_api 0.8.11 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +21 -14
- data/features/activity/notifications.feature +15 -0
- data/features/cassettes/activity/notifications/list_user.yml +54 -0
- data/features/step_definitions/common_steps.rb +8 -9
- data/lib/github_api.rb +3 -4
- data/lib/github_api/activity.rb +8 -13
- data/lib/github_api/activity/events.rb +0 -5
- data/lib/github_api/activity/notifications.rb +0 -5
- data/lib/github_api/api.rb +27 -22
- data/lib/github_api/api_factory.rb +13 -12
- data/lib/github_api/authorizations.rb +0 -5
- data/lib/github_api/client.rb +33 -33
- data/lib/github_api/configuration.rb +10 -2
- data/lib/github_api/connection.rb +2 -3
- data/lib/github_api/constants.rb +0 -3
- data/lib/github_api/gists.rb +2 -7
- data/lib/github_api/git_data.rb +10 -15
- data/lib/github_api/git_data/blobs.rb +0 -5
- data/lib/github_api/git_data/commits.rb +0 -5
- data/lib/github_api/git_data/references.rb +3 -7
- data/lib/github_api/git_data/tags.rb +0 -5
- data/lib/github_api/git_data/trees.rb +0 -5
- data/lib/github_api/gitignore.rb +0 -5
- data/lib/github_api/issues.rb +10 -15
- data/lib/github_api/issues/comments.rb +0 -5
- data/lib/github_api/issues/events.rb +0 -5
- data/lib/github_api/issues/labels.rb +0 -5
- data/lib/github_api/issues/milestones.rb +0 -5
- data/lib/github_api/markdown.rb +0 -5
- data/lib/github_api/meta.rb +0 -5
- data/lib/github_api/orgs.rb +4 -9
- data/lib/github_api/page_iterator.rb +44 -29
- data/lib/github_api/paged_request.rb +12 -12
- data/lib/github_api/{result.rb → pagination.rb} +19 -86
- data/lib/github_api/params_hash.rb +1 -1
- data/lib/github_api/pull_requests.rb +2 -7
- data/lib/github_api/repos.rb +22 -27
- data/lib/github_api/request.rb +7 -4
- data/lib/github_api/response/header.rb +76 -0
- data/lib/github_api/response_wrapper.rb +126 -0
- data/lib/github_api/scopes.rb +1 -1
- data/lib/github_api/search.rb +0 -5
- data/lib/github_api/users.rb +6 -11
- data/lib/github_api/version.rb +2 -2
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/starring/starred_spec.rb +1 -1
- data/spec/github/activity/watching/watched_spec.rb +1 -1
- data/spec/github/api_factory_spec.rb +7 -8
- data/spec/github/api_spec.rb +0 -7
- data/spec/github/authorization_spec.rb +22 -32
- data/spec/github/authorizations/create_spec.rb +49 -0
- data/spec/github/authorizations/delete_spec.rb +39 -0
- data/spec/github/authorizations/get_spec.rb +49 -0
- data/spec/github/authorizations/list_spec.rb +55 -0
- data/spec/github/authorizations/update_spec.rb +50 -0
- data/spec/github/authorizations_spec.rb +2 -236
- data/spec/github/gists/comments/create_spec.rb +1 -1
- data/spec/github/gists/comments/edit_spec.rb +1 -1
- data/spec/github/gists/comments/get_spec.rb +1 -1
- data/spec/github/gists/create_spec.rb +1 -1
- data/spec/github/gists/edit_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +1 -1
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +1 -1
- data/spec/github/git_data/commits/get_spec.rb +1 -1
- data/spec/github/git_data/references/create_spec.rb +2 -2
- data/spec/github/git_data/references/get_spec.rb +1 -1
- data/spec/github/git_data/references/list_spec.rb +16 -6
- data/spec/github/git_data/tags/create_spec.rb +1 -1
- data/spec/github/git_data/tags/get_spec.rb +1 -1
- data/spec/github/git_data/trees/create_spec.rb +1 -1
- data/spec/github/git_data/trees/get_spec.rb +4 -4
- data/spec/github/issues/comments/create_spec.rb +1 -1
- data/spec/github/issues/comments/edit_spec.rb +1 -1
- data/spec/github/issues/comments/get_spec.rb +1 -1
- data/spec/github/issues/create_spec.rb +1 -1
- data/spec/github/issues/edit_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +1 -1
- data/spec/github/issues/get_spec.rb +1 -1
- data/spec/github/issues/labels/create_spec.rb +1 -1
- data/spec/github/issues/labels/get_spec.rb +1 -1
- data/spec/github/issues/labels/update_spec.rb +1 -1
- data/spec/github/issues/milestones/create_spec.rb +1 -1
- data/spec/github/issues/milestones/delete_spec.rb +1 -1
- data/spec/github/issues/milestones/get_spec.rb +1 -1
- data/spec/github/issues/milestones/update_spec.rb +1 -1
- data/spec/github/orgs/edit_spec.rb +1 -1
- data/spec/github/orgs/get_spec.rb +1 -1
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/paged_request_spec.rb +34 -29
- data/spec/github/pagination/iterator/number_spec.rb +118 -0
- data/spec/github/pagination/iterator/sha_spec.rb +67 -0
- data/spec/github/pull_requests/comments/create_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +1 -1
- data/spec/github/pull_requests/comments/get_spec.rb +1 -1
- data/spec/github/pull_requests/create_spec.rb +1 -1
- data/spec/github/pull_requests/get_spec.rb +1 -1
- data/spec/github/pull_requests/update_spec.rb +1 -1
- data/spec/github/repos/branch_spec.rb +1 -1
- data/spec/github/repos/comments/create_spec.rb +1 -1
- data/spec/github/repos/comments/get_spec.rb +1 -1
- data/spec/github/repos/comments/update_spec.rb +1 -1
- data/spec/github/repos/commits/get_spec.rb +1 -1
- data/spec/github/repos/create_spec.rb +1 -1
- data/spec/github/repos/downloads/create_spec.rb +1 -1
- data/spec/github/repos/downloads/get_spec.rb +1 -1
- data/spec/github/repos/edit_spec.rb +1 -1
- data/spec/github/repos/forks/create_spec.rb +1 -1
- data/spec/github/repos/get_spec.rb +1 -1
- data/spec/github/repos/hooks/create_spec.rb +1 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/hooks/get_spec.rb +1 -1
- data/spec/github/repos/languages_spec.rb +1 -1
- data/spec/github/repos/merging/merge_spec.rb +1 -1
- data/spec/github/repos/statuses/create_spec.rb +1 -1
- data/spec/github/repos/tags_spec.rb +1 -1
- data/spec/github/repos/teams_spec.rb +1 -1
- data/spec/github/request/endpoint_spec.rb +24 -0
- data/spec/github/request/request_spec.rb +38 -0
- data/spec/github/{result_spec.rb → response_wrapper_spec.rb} +14 -13
- data/spec/github/users/emails/list_spec.rb +1 -1
- data/spec/github/users/get_spec.rb +2 -7
- data/spec/github/users/keys/create_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/github_spec.rb +1 -6
- data/spec/{github/activity → integration}/activity_spec.rb +0 -0
- data/spec/{github/gists → integration}/gists_spec.rb +2 -0
- data/spec/{github/git_data → integration}/git_data_spec.rb +0 -0
- data/spec/{github/issues → integration}/issues_spec.rb +2 -0
- data/spec/integration/options_spec.rb +103 -23
- data/spec/{github/orgs → integration}/orgs_spec.rb +0 -0
- data/spec/{github/pull_requests → integration}/pull_requests_spec.rb +0 -0
- data/spec/{github → integration}/repos_spec.rb +2 -0
- data/spec/{github/users → integration}/users_spec.rb +0 -0
- data/spec/shared/array_of_resources_behaviour.rb +1 -1
- metadata +55 -46
- data/lib/github_api/page_uri_processor.rb +0 -25
- data/lib/github_api/response/helpers.rb +0 -21
- data/spec/github/page_iterator_spec.rb +0 -260
- data/spec/github/response/helpers_spec.rb +0 -16
|
@@ -74,7 +74,13 @@ module Github
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def self.extended(base)
|
|
77
|
-
base.
|
|
77
|
+
base.reset!
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class << self
|
|
81
|
+
def keys
|
|
82
|
+
VALID_OPTIONS_KEYS
|
|
83
|
+
end
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
def options
|
|
@@ -83,7 +89,9 @@ module Github
|
|
|
83
89
|
options
|
|
84
90
|
end
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
# Reset configuration options to their defaults
|
|
93
|
+
#
|
|
94
|
+
def reset!
|
|
87
95
|
self.adapter = DEFAULT_ADAPTER
|
|
88
96
|
self.client_id = DEFAULT_CLIENT_ID
|
|
89
97
|
self.client_secret = DEFAULT_CLIENT_SECRET
|
|
@@ -4,8 +4,8 @@ require 'faraday'
|
|
|
4
4
|
require 'github_api/response'
|
|
5
5
|
require 'github_api/response/mashify'
|
|
6
6
|
require 'github_api/response/jsonize'
|
|
7
|
-
require 'github_api/response/helpers'
|
|
8
7
|
require 'github_api/response/raise_error'
|
|
8
|
+
require 'github_api/response/header'
|
|
9
9
|
require 'github_api/request/oauth2'
|
|
10
10
|
require 'github_api/request/basic_auth'
|
|
11
11
|
require 'github_api/request/jsonize'
|
|
@@ -51,7 +51,6 @@ module Github
|
|
|
51
51
|
builder.use Github::Request::BasicAuth, authentication if basic_authed?
|
|
52
52
|
|
|
53
53
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
|
54
|
-
builder.use Github::Response::Helpers
|
|
55
54
|
unless options[:raw]
|
|
56
55
|
builder.use Github::Response::Mashify
|
|
57
56
|
builder.use Github::Response::Jsonize
|
|
@@ -88,7 +87,7 @@ module Github
|
|
|
88
87
|
|
|
89
88
|
# Returns a Fraday::Connection object
|
|
90
89
|
#
|
|
91
|
-
def connection(options
|
|
90
|
+
def connection(options={})
|
|
92
91
|
conn_options = default_options(options)
|
|
93
92
|
clear_cache unless options.empty?
|
|
94
93
|
puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG']
|
data/lib/github_api/constants.rb
CHANGED
data/lib/github_api/gists.rb
CHANGED
|
@@ -14,14 +14,9 @@ module Github
|
|
|
14
14
|
content
|
|
15
15
|
].freeze
|
|
16
16
|
|
|
17
|
-
# Creates new Gists API
|
|
18
|
-
def initialize(options = {})
|
|
19
|
-
super(options)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
17
|
# Access to Gists::Comments API
|
|
23
|
-
def comments
|
|
24
|
-
@comments ||= ApiFactory.new
|
|
18
|
+
def comments(options={}, &block)
|
|
19
|
+
@comments ||= ApiFactory.new('Gists::Comments', current_options.merge(options), &block)
|
|
25
20
|
end
|
|
26
21
|
|
|
27
22
|
# List a user's gists.
|
data/lib/github_api/git_data.rb
CHANGED
|
@@ -11,34 +11,29 @@ module Github
|
|
|
11
11
|
:Tags => 'tags',
|
|
12
12
|
:Trees => 'trees'
|
|
13
13
|
|
|
14
|
-
# Creates new GitData API
|
|
15
|
-
def initialize(options = {})
|
|
16
|
-
super(options)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
14
|
# Access to GitData::Blobs API
|
|
20
|
-
def blobs
|
|
21
|
-
@blobs ||= ApiFactory.new
|
|
15
|
+
def blobs(options={}, &block)
|
|
16
|
+
@blobs ||= ApiFactory.new('GitData::Blobs', current_options.merge(options), &block)
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
# Access to GitData::Commits API
|
|
25
|
-
def commits
|
|
26
|
-
@commits ||= ApiFactory.new
|
|
20
|
+
def commits(options={}, &block)
|
|
21
|
+
@commits ||= ApiFactory.new('GitData::Commits', current_options.merge(options), &block)
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
# Access to GitData::References API
|
|
30
|
-
def references
|
|
31
|
-
@references ||= ApiFactory.new
|
|
25
|
+
def references(options={}, &block)
|
|
26
|
+
@references ||= ApiFactory.new('GitData::References', current_options.merge(options), &block)
|
|
32
27
|
end
|
|
33
28
|
|
|
34
29
|
# Access to GitData::Tags API
|
|
35
|
-
def tags
|
|
36
|
-
@tags ||= ApiFactory.new
|
|
30
|
+
def tags(options={}, &block)
|
|
31
|
+
@tags ||= ApiFactory.new('GitData::Tags', current_options.merge(options), &block)
|
|
37
32
|
end
|
|
38
33
|
|
|
39
34
|
# Access to GitData::Tags API
|
|
40
|
-
def trees
|
|
41
|
-
@trees ||= ApiFactory.new
|
|
35
|
+
def trees(options={}, &block)
|
|
36
|
+
@trees ||= ApiFactory.new('GitData::Trees', current_options.merge(options), &block)
|
|
42
37
|
end
|
|
43
38
|
|
|
44
39
|
end # GitData
|
|
@@ -9,11 +9,6 @@ module Github
|
|
|
9
9
|
'ref' => %r{^refs\/\w+(\/\w+)*} # test fully qualified reference
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
# Creates new GitData::References API
|
|
13
|
-
def initialize(options = {})
|
|
14
|
-
super(options)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
12
|
# Get all references
|
|
18
13
|
#
|
|
19
14
|
# This will return an array of all the references on the system,
|
|
@@ -130,8 +125,9 @@ module Github
|
|
|
130
125
|
|
|
131
126
|
private
|
|
132
127
|
|
|
133
|
-
def validate_reference
|
|
134
|
-
refs = ref
|
|
128
|
+
def validate_reference(ref)
|
|
129
|
+
refs = (ref =~ (/^(\/)?refs.*/) ? ref : "refs/#{ref}").gsub(/(\/)+/, '/')
|
|
130
|
+
refs.gsub!(/^\//, '')
|
|
135
131
|
unless VALID_REF_PARAM_VALUES['ref'] =~ refs
|
|
136
132
|
raise ArgumentError, "Provided 'reference' is invalid"
|
|
137
133
|
end
|
data/lib/github_api/gitignore.rb
CHANGED
|
@@ -6,11 +6,6 @@ module Github
|
|
|
6
6
|
# .gitignore template to apply to the repository upon creation.
|
|
7
7
|
class Gitignore < API
|
|
8
8
|
|
|
9
|
-
# Creates new Gitignore API
|
|
10
|
-
def initialize(options = {})
|
|
11
|
-
super(options)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
9
|
# List all templates available to pass as an option when creating a repository.
|
|
15
10
|
#
|
|
16
11
|
# = Examples
|
data/lib/github_api/issues.rb
CHANGED
|
@@ -36,34 +36,29 @@ module Github
|
|
|
36
36
|
'since' => %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
# Creates new Issues API
|
|
40
|
-
def initialize(options = {})
|
|
41
|
-
super(options)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
39
|
# Access to Issues::Assignees API
|
|
45
|
-
def assignees
|
|
46
|
-
@assignees ||= ApiFactory.new
|
|
40
|
+
def assignees(options={}, &block)
|
|
41
|
+
@assignees ||= ApiFactory.new('Issues::Assignees', current_options.merge(options), &block)
|
|
47
42
|
end
|
|
48
43
|
|
|
49
44
|
# Access to Issues::Comments API
|
|
50
|
-
def comments
|
|
51
|
-
@comments ||= ApiFactory.new
|
|
45
|
+
def comments(options={}, &block)
|
|
46
|
+
@comments ||= ApiFactory.new('Issues::Comments', current_options.merge(options), &block)
|
|
52
47
|
end
|
|
53
48
|
|
|
54
49
|
# Access to Issues::Events API
|
|
55
|
-
def events
|
|
56
|
-
@events ||= ApiFactory.new
|
|
50
|
+
def events(options={}, &block)
|
|
51
|
+
@events ||= ApiFactory.new('Issues::Events', current_options.merge(options), &block)
|
|
57
52
|
end
|
|
58
53
|
|
|
59
54
|
# Access to Issues::Comments API
|
|
60
|
-
def labels
|
|
61
|
-
@labels ||= ApiFactory.new
|
|
55
|
+
def labels(options={}, &block)
|
|
56
|
+
@labels ||= ApiFactory.new('Issues::Labels', current_options.merge(options), &block)
|
|
62
57
|
end
|
|
63
58
|
|
|
64
59
|
# Access to Issues::Comments API
|
|
65
|
-
def milestones
|
|
66
|
-
@milestones ||= ApiFactory.new
|
|
60
|
+
def milestones(options={}, &block)
|
|
61
|
+
@milestones ||= ApiFactory.new('Issues::Milestones', current_options.merge(options), &block)
|
|
67
62
|
end
|
|
68
63
|
|
|
69
64
|
# List your issues
|
data/lib/github_api/markdown.rb
CHANGED
data/lib/github_api/meta.rb
CHANGED
data/lib/github_api/orgs.rb
CHANGED
|
@@ -16,19 +16,14 @@ module Github
|
|
|
16
16
|
name
|
|
17
17
|
].freeze
|
|
18
18
|
|
|
19
|
-
# Creates new Orgs API
|
|
20
|
-
def initialize(options = {})
|
|
21
|
-
super(options)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
19
|
# Access to Orgs::Members API
|
|
25
|
-
def members
|
|
26
|
-
@members ||= ApiFactory.new
|
|
20
|
+
def members(options={}, &block)
|
|
21
|
+
@members ||= ApiFactory.new('Orgs::Members', current_options.merge(options), &block)
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
# Access to Orgs::Teams API
|
|
30
|
-
def teams
|
|
31
|
-
@teams ||= ApiFactory.new
|
|
25
|
+
def teams(options={}, &block)
|
|
26
|
+
@teams ||= ApiFactory.new('Orgs::Teams', current_options.merge(options), &block)
|
|
32
27
|
end
|
|
33
28
|
|
|
34
29
|
# List all public organizations for a user.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
require 'github_api/utils/url'
|
|
4
|
+
require 'uri'
|
|
4
5
|
|
|
5
6
|
module Github
|
|
6
7
|
class PageIterator
|
|
@@ -15,8 +16,11 @@ module Github
|
|
|
15
16
|
attr_accessor :"#{attr}_page_uri", :"#{attr}_page"
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
attr_reader :current_api
|
|
20
|
+
|
|
21
|
+
def initialize(links, current_api)
|
|
22
|
+
@links = links
|
|
23
|
+
@current_api = current_api
|
|
20
24
|
update_page_links @links
|
|
21
25
|
end
|
|
22
26
|
|
|
@@ -24,78 +28,89 @@ module Github
|
|
|
24
28
|
next_page == 0 || !next_page_uri.nil?
|
|
25
29
|
end
|
|
26
30
|
|
|
31
|
+
def count
|
|
32
|
+
return nil unless last_page_uri
|
|
33
|
+
parse_query(URI(last_page_uri).query)['page']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Perform http get request for the first resource
|
|
37
|
+
#
|
|
27
38
|
def first
|
|
28
39
|
return nil unless first_page_uri
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
params =
|
|
33
|
-
if parsed_query.keys.include?('sha')
|
|
34
|
-
params['sha'] = 'master'
|
|
35
|
-
end
|
|
40
|
+
page_uri = URI(first_page_uri)
|
|
41
|
+
params = parse_query(page_uri.query)
|
|
42
|
+
if next_page < 1
|
|
43
|
+
params['sha'] = 'master' if params.keys.include?('sha')
|
|
36
44
|
params['per_page'] = parse_per_page_number(first_page_uri)
|
|
37
|
-
|
|
38
|
-
page_request first_page_uri.split(QUERY_STR_SEP).first, params
|
|
39
45
|
else
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
params['page'] = parse_page_number(first_page_uri)
|
|
47
|
+
params['per_page'] = parse_per_page_number(first_page_uri)
|
|
42
48
|
end
|
|
43
49
|
|
|
50
|
+
response = page_request(page_uri.path, params)
|
|
44
51
|
update_page_links response.links
|
|
45
52
|
response
|
|
46
53
|
end
|
|
47
54
|
|
|
55
|
+
# Perform http get request for the next resource
|
|
56
|
+
#
|
|
48
57
|
def next
|
|
49
58
|
return nil unless has_next?
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
page_uri = URI(next_page_uri)
|
|
60
|
+
params = parse_query(page_uri.query)
|
|
61
|
+
if next_page < 1
|
|
53
62
|
params['sha'] = params['last_sha'] if params.keys.include?('last_sha')
|
|
54
63
|
params['per_page'] = parse_per_page_number(next_page_uri)
|
|
55
|
-
page_request next_page_uri.split(QUERY_STR_SEP).first, params
|
|
56
64
|
else
|
|
57
|
-
params
|
|
58
|
-
params['page'] = parse_page_number(next_page_uri)
|
|
65
|
+
params['page'] = parse_page_number(next_page_uri)
|
|
59
66
|
params['per_page'] = parse_per_page_number(next_page_uri)
|
|
60
|
-
page_request next_page_uri.split(QUERY_STR_SEP).first, params
|
|
61
67
|
end
|
|
68
|
+
|
|
69
|
+
response = page_request(page_uri.path, params)
|
|
62
70
|
update_page_links response.links
|
|
63
71
|
response
|
|
64
72
|
end
|
|
65
73
|
|
|
74
|
+
# Perform http get request for the previous resource
|
|
75
|
+
#
|
|
66
76
|
def prev
|
|
67
77
|
return nil unless prev_page_uri
|
|
68
|
-
|
|
69
|
-
params
|
|
78
|
+
page_uri = URI(prev_page_uri)
|
|
79
|
+
params = parse_query(page_uri.query)
|
|
80
|
+
params['page'] = parse_page_number(prev_page_uri)
|
|
70
81
|
params['per_page'] = parse_per_page_number(prev_page_uri)
|
|
71
|
-
response = page_request prev_page_uri.split(QUERY_STR_SEP).first, params
|
|
72
82
|
|
|
83
|
+
response = page_request(page_uri.path, params)
|
|
73
84
|
update_page_links response.links
|
|
74
85
|
response
|
|
75
86
|
end
|
|
76
87
|
|
|
88
|
+
# Perform http get request for the last resource
|
|
89
|
+
#
|
|
77
90
|
def last
|
|
78
91
|
return nil unless last_page_uri
|
|
79
|
-
|
|
80
|
-
params
|
|
92
|
+
page_uri = URI(last_page_uri)
|
|
93
|
+
params = parse_query(page_uri.query)
|
|
94
|
+
params['page'] = parse_page_number(last_page_uri)
|
|
81
95
|
params['per_page'] = parse_per_page_number(last_page_uri)
|
|
82
|
-
response = page_request last_page_uri.split(QUERY_STR_SEP).first, params
|
|
83
96
|
|
|
97
|
+
response = page_request(page_uri.path, params)
|
|
84
98
|
update_page_links response.links
|
|
85
99
|
response
|
|
86
100
|
end
|
|
87
101
|
|
|
88
102
|
# Returns the result for a specific page.
|
|
103
|
+
#
|
|
89
104
|
def get_page(page_number)
|
|
90
105
|
# Find URI that we can work with, if we cannot get the first or the
|
|
91
106
|
# last page URI then there is only one page.
|
|
92
107
|
page_uri = first_page_uri || last_page_uri
|
|
93
108
|
return nil unless page_uri
|
|
94
|
-
params
|
|
95
|
-
params['page']
|
|
109
|
+
params = parse_query URI(page_uri).query
|
|
110
|
+
params['page'] = page_number
|
|
96
111
|
params['per_page'] = parse_per_page_number(page_uri)
|
|
97
|
-
response = page_request page_uri.split(QUERY_STR_SEP).first, params
|
|
98
112
|
|
|
113
|
+
response = page_request URI(page_uri).path, params
|
|
99
114
|
update_page_links response.links
|
|
100
115
|
response
|
|
101
116
|
end
|