octokit 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
+ * [1.0.7 - May 11, 2012](https://github.com/pengwynn/octokit/compare/v1.0.6...v1.0.7)
3
4
  * [1.0.6 - May 11, 2012](https://github.com/pengwynn/octokit/compare/v1.0.5...v1.0.6)
4
5
  * [1.0.5 - May 2, 2012](https://github.com/pengwynn/octokit/compare/v1.0.4...v1.0.5)
5
6
  * [1.0.4 - April 24, 2012](https://github.com/pengwynn/octokit/compare/v1.0.3...v1.0.4)
@@ -11,7 +11,8 @@ module Octokit
11
11
  :proxy,
12
12
  :oauth_token,
13
13
  :user_agent,
14
- :auto_traversal].freeze
14
+ :auto_traversal,
15
+ :per_page].freeze
15
16
 
16
17
  DEFAULT_ADAPTER = Faraday.default_adapter
17
18
  DEFAULT_API_VERSION = 3
@@ -28,6 +28,10 @@ module Octokit
28
28
  response = connection(authenticate, raw, version, force_urlencoded).send(method) do |request|
29
29
  case method
30
30
  when :delete, :get
31
+ if auto_traversal && per_page.nil?
32
+ self.per_page = 100
33
+ end
34
+ options.merge!(:per_page => per_page) if per_page
31
35
  request.url(path, options)
32
36
  when :patch, :post, :put
33
37
  request.path = path
@@ -1,3 +1,3 @@
1
1
  module Octokit
2
- VERSION = "1.0.6".freeze unless defined?(Octokit::VERSION)
2
+ VERSION = "1.0.7".freeze unless defined?(Octokit::VERSION)
3
3
  end
@@ -10,19 +10,37 @@ describe Octokit::Client do
10
10
  }.should_not raise_exception
11
11
  end
12
12
 
13
- it "should traverse a paginated response if auto_traversal is on" do
14
- stub_get("https://api.github.com/foo/bar").
15
- to_return(:status => 200, :body => %q{["stuff"]}, :headers =>
16
- { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last"} })
17
13
 
18
- stub_get("https://api.github.com/foo/bar?page=2").
19
- to_return(:status => 200, :body => %q{["even more stuff"]}, :headers =>
20
- { 'Link' => %q{<https://api.github.com/foo/bar?page=3>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last", <https://api.github.com/foo/bar?page=1>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
14
+ describe "auto_traversal" do
21
15
 
22
- stub_get("https://api.github.com/foo/bar?page=3").
23
- to_return(:status => 200, :body => %q{["stuffapalooza"]}, :headers =>
24
- { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
16
+ it "should traverse a paginated response using the maximum allowed number of items per page" do
17
+ stub_get("https://api.github.com/foo/bar?per_page=100").
18
+ to_return(:status => 200, :body => %q{["stuff"]}, :headers =>
19
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last"} })
20
+
21
+ stub_get("https://api.github.com/foo/bar?page=2&per_page=100").
22
+ to_return(:status => 200, :body => %q{["even more stuff"]}, :headers =>
23
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=3>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last", <https://api.github.com/foo/bar?page=1>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
24
+
25
+ stub_get("https://api.github.com/foo/bar?page=3&per_page=100").
26
+ to_return(:status => 200, :body => %q{["stuffapalooza"]}, :headers =>
27
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
28
+
29
+ Octokit::Client.new(:auto_traversal => true).get("https://api.github.com/foo/bar", {}, 3).should == ['stuff', 'even more stuff', 'stuffapalooza']
30
+ end
31
+
32
+ it "should use the number set in the per_page configuration option when present" do
33
+ stub_get("https://api.github.com/foo/bar?per_page=50").
34
+ to_return(:status => 200, :body => %q{["stuff"]}, :headers =>
35
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last"} })
36
+
37
+ stub_get("https://api.github.com/foo/bar?page=2&per_page=50").
38
+ to_return(:status => 200, :body => %q{["even more stuff"]}, :headers =>
39
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=3>; rel="last", <https://api.github.com/foo/bar?page=1>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
40
+
41
+ Octokit::Client.new(:auto_traversal => true, :per_page => 50).get("https://api.github.com/foo/bar", {}, 3).should
42
+ end
25
43
 
26
- Octokit::Client.new(:auto_traversal => true).get("https://api.github.com/foo/bar", {}, 3).should == ['stuff', 'even more stuff', 'stuffapalooza']
27
44
  end
45
+
28
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2012-05-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: addressable
18
- requirement: &70196526523460 !ruby/object:Gem::Requirement
18
+ requirement: &70146290234980 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '2.2'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70196526523460
26
+ version_requirements: *70146290234980
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
- requirement: &70196526522860 !ruby/object:Gem::Requirement
29
+ requirement: &70146290234400 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.8'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70196526522860
37
+ version_requirements: *70146290234400
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: faraday_middleware
40
- requirement: &70196526522400 !ruby/object:Gem::Requirement
40
+ requirement: &70146290233920 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0.8'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70196526522400
48
+ version_requirements: *70146290233920
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: hashie
51
- requirement: &70196526521880 !ruby/object:Gem::Requirement
51
+ requirement: &70146290233380 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '1.2'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70196526521880
59
+ version_requirements: *70146290233380
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: multi_json
62
- requirement: &70196526521340 !ruby/object:Gem::Requirement
62
+ requirement: &70146290232860 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '1.3'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70196526521340
70
+ version_requirements: *70146290232860
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: json
73
- requirement: &70196526520940 !ruby/object:Gem::Requirement
73
+ requirement: &70146290232460 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70196526520940
81
+ version_requirements: *70146290232460
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: maruku
84
- requirement: &70196526520380 !ruby/object:Gem::Requirement
84
+ requirement: &70146290231880 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *70196526520380
92
+ version_requirements: *70146290231880
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rake
95
- requirement: &70196526519860 !ruby/object:Gem::Requirement
95
+ requirement: &70146290231360 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *70196526519860
103
+ version_requirements: *70146290231360
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rspec
106
- requirement: &70196526519220 !ruby/object:Gem::Requirement
106
+ requirement: &70146290230680 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: '0'
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *70196526519220
114
+ version_requirements: *70146290230680
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: simplecov
117
- requirement: &70196526511900 !ruby/object:Gem::Requirement
117
+ requirement: &70146290223020 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,10 +122,10 @@ dependencies:
122
122
  version: '0'
123
123
  type: :development
124
124
  prerelease: false
125
- version_requirements: *70196526511900
125
+ version_requirements: *70146290223020
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: webmock
128
- requirement: &70196526510940 !ruby/object:Gem::Requirement
128
+ requirement: &70146290222300 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
131
  - - ! '>='
@@ -133,10 +133,10 @@ dependencies:
133
133
  version: '0'
134
134
  type: :development
135
135
  prerelease: false
136
- version_requirements: *70196526510940
136
+ version_requirements: *70146290222300
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: yard
139
- requirement: &70196526509900 !ruby/object:Gem::Requirement
139
+ requirement: &70146290221400 !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
142
142
  - - ! '>='
@@ -144,7 +144,7 @@ dependencies:
144
144
  version: '0'
145
145
  type: :development
146
146
  prerelease: false
147
- version_requirements: *70196526509900
147
+ version_requirements: *70146290221400
148
148
  description: Simple wrapper for the GitHub API (v2 and v3)
149
149
  email:
150
150
  - wynn.netherland@gmail.com