gitlab-ruby 0.1.0.pre → 0.1.1.pre
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.
- checksums.yaml +4 -4
- data/README.md +5 -9
- data/lib/gitlab/api/base.rb +12 -2
- data/lib/gitlab/api/issues.rb +6 -6
- data/lib/gitlab/pagination.rb +8 -5
- data/lib/gitlab/response.rb +3 -2
- data/lib/gitlab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69eaed3eb91232c2aecbb26b98be4cd5a29fde24248e10a852f659516bb247d0
|
4
|
+
data.tar.gz: 1725f8b68db38f3f053e27ff55337401c052b88d01e84831ffd8992389b6b3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82624e6e5b3c2ea05b39741e860b28c002ad9d1e1da63143987c7737cfed894521a65732f2feaabcf011f706fdf4edfd5746e1cfc04305ab5f0cb327229f9680
|
7
|
+
data.tar.gz: 86991c0381614452da9f14f7f7e1e8ff250a82bc4286060b222f069a72b2a23f3107f7f13f64ab160245284d5462dafc7460bf3642fbd3e3d5d03f09c3dad216
|
data/README.md
CHANGED
@@ -33,15 +33,11 @@ end
|
|
33
33
|
|
34
34
|
#### Pagination
|
35
35
|
```ruby
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
page = response.next_page
|
44
|
-
break if page.zero?
|
36
|
+
client = Gitlab::Client.new(private_token: 'secret')
|
37
|
+
response = client.issues.list
|
38
|
+
|
39
|
+
while (response = response.next_page) do
|
40
|
+
# Do something with next page
|
45
41
|
end
|
46
42
|
```
|
47
43
|
|
data/lib/gitlab/api/base.rb
CHANGED
@@ -9,8 +9,18 @@ module Gitlab
|
|
9
9
|
|
10
10
|
protected
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def handle_action(action)
|
13
|
+
response = action.call
|
14
|
+
Gitlab::Response.new(response, action)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def with_pagination(args)
|
20
|
+
proc do |page = nil|
|
21
|
+
args[:page] = page unless page.nil?
|
22
|
+
yield
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
data/lib/gitlab/api/issues.rb
CHANGED
@@ -4,18 +4,18 @@ module Gitlab
|
|
4
4
|
PATH = 'issues'
|
5
5
|
|
6
6
|
def list(args = {})
|
7
|
-
|
8
|
-
|
7
|
+
action = with_pagination(args) { connection.get(PATH, args) }
|
8
|
+
handle_action(action)
|
9
9
|
end
|
10
10
|
|
11
11
|
def list_group(group, args = {})
|
12
|
-
|
13
|
-
|
12
|
+
action = with_pagination(args) { connection.get(group_path(group), args) }
|
13
|
+
handle_action(action)
|
14
14
|
end
|
15
15
|
|
16
16
|
def list_project(project, args = {})
|
17
|
-
|
18
|
-
|
17
|
+
action = with_pagination(args) { connection.get(project_path(project), args) }
|
18
|
+
handle_action(action)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
data/lib/gitlab/pagination.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Gitlab
|
2
2
|
module Pagination
|
3
|
-
def
|
3
|
+
def current_page_number
|
4
4
|
headers['x-page'].to_i
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def next_page_number
|
8
8
|
headers['x-next-page'].to_i
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def prev_page_number
|
12
12
|
headers['x-prev-page'].to_i
|
13
13
|
end
|
14
14
|
|
@@ -24,8 +24,11 @@ module Gitlab
|
|
24
24
|
headers['x-per-page'].to_i
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def next_page
|
28
|
+
return nil if next_page_number.zero?
|
29
|
+
|
30
|
+
response = @action.call(next_page_number)
|
31
|
+
self.class.new(response, @action)
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
data/lib/gitlab/response.rb
CHANGED
@@ -2,11 +2,12 @@ module Gitlab
|
|
2
2
|
class Response < Faraday::Response
|
3
3
|
include Gitlab::Pagination
|
4
4
|
|
5
|
-
attr_reader :gateway
|
5
|
+
attr_reader :gateway, :action
|
6
6
|
|
7
|
-
def initialize(response)
|
7
|
+
def initialize(response, action = proc {})
|
8
8
|
super()
|
9
9
|
finish(response.env)
|
10
|
+
@action = action
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
data/lib/gitlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|