reenhanced_bitbucket_api 0.1.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bitbucket_rest_api/api/arguments.rb +248 -0
  3. data/lib/bitbucket_rest_api/api/config/property.rb +30 -0
  4. data/lib/bitbucket_rest_api/api/config/property_set.rb +118 -0
  5. data/lib/bitbucket_rest_api/api/config.rb +107 -0
  6. data/lib/bitbucket_rest_api/api/factory.rb +29 -0
  7. data/lib/bitbucket_rest_api/api.rb +155 -33
  8. data/lib/bitbucket_rest_api/{invitations.rb → client/invitations.rb} +4 -3
  9. data/lib/bitbucket_rest_api/{issues → client/issues}/comments.rb +2 -11
  10. data/lib/bitbucket_rest_api/{issues → client/issues}/components.rb +3 -6
  11. data/lib/bitbucket_rest_api/{issues → client/issues}/milestones.rb +3 -7
  12. data/lib/bitbucket_rest_api/{issues.rb → client/issues.rb} +9 -25
  13. data/lib/bitbucket_rest_api/{repos → client/repos}/changesets.rb +3 -2
  14. data/lib/bitbucket_rest_api/{repos → client/repos}/following.rb +2 -1
  15. data/lib/bitbucket_rest_api/{repos → client/repos}/keys.rb +2 -1
  16. data/lib/bitbucket_rest_api/client/repos/pull_requests/activity.rb +22 -0
  17. data/lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb +40 -0
  18. data/lib/bitbucket_rest_api/client/repos/pull_requests/commits.rb +24 -0
  19. data/lib/bitbucket_rest_api/client/repos/pull_requests.rb +205 -0
  20. data/lib/bitbucket_rest_api/{repos → client/repos}/services.rb +2 -1
  21. data/lib/bitbucket_rest_api/{repos → client/repos}/sources.rb +2 -1
  22. data/lib/bitbucket_rest_api/{repos.rb → client/repos.rb} +26 -40
  23. data/lib/bitbucket_rest_api/{user.rb → client/user.rb} +2 -7
  24. data/lib/bitbucket_rest_api/{users → client/users}/account.rb +2 -1
  25. data/lib/bitbucket_rest_api/client/users.rb +14 -0
  26. data/lib/bitbucket_rest_api/client.rb +28 -32
  27. data/lib/bitbucket_rest_api/configuration.rb +24 -67
  28. data/lib/bitbucket_rest_api/connection.rb +15 -50
  29. data/lib/bitbucket_rest_api/constants.rb +1 -9
  30. data/lib/bitbucket_rest_api/core_ext/array.rb +1 -1
  31. data/lib/bitbucket_rest_api/error/invalid_options.rb +1 -1
  32. data/lib/bitbucket_rest_api/error/required_params.rb +1 -1
  33. data/lib/bitbucket_rest_api/error/unknown_value.rb +1 -1
  34. data/lib/bitbucket_rest_api/ext/faraday.rb +38 -0
  35. data/lib/bitbucket_rest_api/middleware.rb +31 -0
  36. data/lib/bitbucket_rest_api/null_encoder.rb +25 -0
  37. data/lib/bitbucket_rest_api/page_iterator.rb +90 -0
  38. data/lib/bitbucket_rest_api/page_links.rb +33 -0
  39. data/lib/bitbucket_rest_api/paged_request.rb +29 -0
  40. data/lib/bitbucket_rest_api/pagination.rb +98 -0
  41. data/lib/bitbucket_rest_api/parameter_filter.rb +1 -1
  42. data/lib/bitbucket_rest_api/params_hash.rb +100 -0
  43. data/lib/bitbucket_rest_api/request/basic_auth.rb +4 -2
  44. data/lib/bitbucket_rest_api/request/jsonize.rb +5 -0
  45. data/lib/bitbucket_rest_api/request/oauth.rb +3 -3
  46. data/lib/bitbucket_rest_api/request/verbs.rb +53 -0
  47. data/lib/bitbucket_rest_api/request.rb +60 -36
  48. data/lib/bitbucket_rest_api/response/header.rb +68 -0
  49. data/lib/bitbucket_rest_api/response_wrapper.rb +157 -0
  50. data/lib/bitbucket_rest_api/result.rb +5 -77
  51. data/lib/bitbucket_rest_api/users.rb +4 -8
  52. data/lib/bitbucket_rest_api/validations/presence.rb +16 -11
  53. data/lib/bitbucket_rest_api/validations.rb +6 -6
  54. data/lib/bitbucket_rest_api/version.rb +2 -2
  55. data/lib/bitbucket_rest_api.rb +89 -44
  56. metadata +39 -131
  57. data/lib/bitbucket_rest_api/api_factory.rb +0 -30
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'faraday'
4
+ require 'faraday_middleware'
3
5
  require 'bitbucket_rest_api/version'
4
6
  require 'bitbucket_rest_api/configuration'
5
7
  require 'bitbucket_rest_api/constants'
@@ -7,11 +9,18 @@ require 'bitbucket_rest_api/utils/url'
7
9
  require 'bitbucket_rest_api/connection'
8
10
  require 'bitbucket_rest_api/deprecation'
9
11
  require 'bitbucket_rest_api/core_ext/ordered_hash'
12
+ require 'bitbucket_rest_api/ext/faraday'
13
+ require 'bitbucket_rest_api/middleware'
10
14
 
11
15
  module BitBucket
12
- extend Configuration
16
+ LIBNAME = 'bitbucket_rest_api'
17
+
18
+ LIBDIR = File.expand_path("../#{LIBNAME}", __FILE__)
13
19
 
14
20
  class << self
21
+ def included(base)
22
+ base.extend ClassMethods
23
+ end
15
24
 
16
25
  # Handle for the client instance
17
26
  attr_accessor :api_client
@@ -20,7 +29,17 @@ module BitBucket
20
29
  #
21
30
  # @return [BitBucket::Client]
22
31
  def new(options = { }, &block)
23
- @api_client = BitBucket::Client.new(options, &block)
32
+ @api_client = Client.new(options, &block)
33
+ end
34
+
35
+ # Default middleware stack that uses default adapter as specified
36
+ # by configuration setup
37
+ #
38
+ # @return [Proc]
39
+ #
40
+ # @api private
41
+ def default_middleware(options = {})
42
+ Middleware.default(options)
24
43
  end
25
44
 
26
45
  # Delegate to BitBucket::Client
@@ -36,56 +55,82 @@ module BitBucket
36
55
 
37
56
  end
38
57
 
39
- module AutoloadHelper
58
+ module ClassMethods
40
59
 
41
- def autoload_all(prefix, options)
42
- options.each do |const_name, path|
43
- autoload const_name, File.join(prefix, path)
60
+ # Requires internal libraries
61
+ #
62
+ # @param [String] prefix
63
+ # the relative path prefix
64
+ # @param [Array[String]] libs
65
+ # the array of libraries to require
66
+ #
67
+ # @return [self]
68
+ def require_all(prefix, *libs)
69
+ libs.each do |lib|
70
+ require "#{File.join(prefix, lib)}"
44
71
  end
45
72
  end
46
73
 
47
- def register_constant(options)
48
- options.each do |const_name, value|
49
- const_set const_name.upcase.to_s, value
50
- end
74
+ # The client configuration
75
+ #
76
+ # @return [Configuration]
77
+ #
78
+ # @api public
79
+ def configuration
80
+ @configuration ||= Configuration.new
51
81
  end
52
82
 
53
- def lookup_constant(const_name)
54
- const_get const_name.upcase.to_s
83
+ # Configure options
84
+ #
85
+ # @example
86
+ # BitBucket.configure do |c|
87
+ # c.some_option = true
88
+ # end
89
+ #
90
+ # @yield the configuration block
91
+ # @yieldparam configuration [BitBucket::Configuration]
92
+ # the configuration instance
93
+ #
94
+ # @return [nil]
95
+ #
96
+ # @api public
97
+ def configure
98
+ yield configuration
55
99
  end
56
-
57
100
  end
58
101
 
59
- extend AutoloadHelper
60
-
61
- autoload_all 'bitbucket_rest_api',
62
- :API => 'api',
63
- :ApiFactory => 'api_factory',
64
- :Authorization => 'authorization',
65
- :Authorizations => 'authorizations',
66
- :Validations => 'validations',
67
- :ParameterFilter => 'parameter_filter',
68
- :Normalizer => 'normalizer',
69
- :Client => 'client',
70
- :CoreExt => 'core_ext',
71
- :Request => 'request',
72
- :Response => 'response',
73
- :Result => 'result',
74
-
75
- :Repos => 'repos',
76
- #:Error => 'error',
77
- :Issues => 'issues',
78
- :User => 'user',
79
- :Users => 'users',
80
- :Invitations => 'invitations'
81
-
82
- #:Teams => 'teams',
83
- #:PullRequests => 'pull_requests',
84
- #:Users => 'users',
85
- #:Events => 'events',
86
- #:Search => 'search',
87
- #:PageLinks => 'page_links',
88
- #:PageIterator => 'page_iterator',
89
- #:PagedRequest => 'paged_request'
102
+ extend ClassMethods
103
+
104
+ require_all LIBDIR,
105
+ 'authorization',
106
+ 'validations',
107
+ 'normalizer',
108
+ 'parameter_filter',
109
+ 'api',
110
+ 'client',
111
+ 'pagination',
112
+ 'request',
113
+ 'response',
114
+ 'response_wrapper',
115
+ #'result',
116
+ 'error',
117
+ 'page_links',
118
+ 'paged_request',
119
+ 'page_iterator',
120
+ 'params_hash'
121
+
122
+ #'repos',
123
+ #'issues',
124
+ #'user',
125
+ #'users',
126
+ #'invitations',
127
+ #'page_links',
128
+ #'paged_request',
129
+ #'page_iterator'
130
+
131
+ #'teams',
132
+ #'users',
133
+ #'events',
134
+ #'search',
90
135
 
91
136
  end # BitBucket
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reenhanced_bitbucket_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Cochran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-15 00:00:00.000000000 Z
12
+ date: 2015-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
@@ -93,126 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.3.0
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
104
- - !ruby/object:Gem::Dependency
105
- name: rspec
106
- requirement: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- type: :development
112
- prerelease: false
113
- version_requirements: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- - !ruby/object:Gem::Dependency
119
- name: cucumber
120
- requirement: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- type: :development
126
- prerelease: false
127
- version_requirements: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- - !ruby/object:Gem::Dependency
133
- name: webmock
134
- requirement: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 1.8.0
139
- type: :development
140
- prerelease: false
141
- version_requirements: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.8.0
146
- - !ruby/object:Gem::Dependency
147
- name: vcr
148
- requirement: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 2.2.0
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 2.2.0
160
- - !ruby/object:Gem::Dependency
161
- name: simplecov
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 0.6.1
167
- type: :development
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 0.6.1
174
- - !ruby/object:Gem::Dependency
175
- name: guard
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- type: :development
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- - !ruby/object:Gem::Dependency
189
- name: guard-rspec
190
- requirement: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- type: :development
196
- prerelease: false
197
- version_requirements: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- - !ruby/object:Gem::Dependency
203
- name: guard-cucumber
204
- requirement: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- type: :development
210
- prerelease: false
211
- version_requirements: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
103
+ version: 0.3.0
216
104
  - !ruby/object:Gem::Dependency
217
105
  name: rake
218
106
  requirement: !ruby/object:Gem::Requirement
@@ -253,9 +141,31 @@ files:
253
141
  - lib/bitbucket_rest_api.rb
254
142
  - lib/bitbucket_rest_api/api.rb
255
143
  - lib/bitbucket_rest_api/api/actions.rb
256
- - lib/bitbucket_rest_api/api_factory.rb
144
+ - lib/bitbucket_rest_api/api/arguments.rb
145
+ - lib/bitbucket_rest_api/api/config.rb
146
+ - lib/bitbucket_rest_api/api/config/property.rb
147
+ - lib/bitbucket_rest_api/api/config/property_set.rb
148
+ - lib/bitbucket_rest_api/api/factory.rb
257
149
  - lib/bitbucket_rest_api/authorization.rb
258
150
  - lib/bitbucket_rest_api/client.rb
151
+ - lib/bitbucket_rest_api/client/invitations.rb
152
+ - lib/bitbucket_rest_api/client/issues.rb
153
+ - lib/bitbucket_rest_api/client/issues/comments.rb
154
+ - lib/bitbucket_rest_api/client/issues/components.rb
155
+ - lib/bitbucket_rest_api/client/issues/milestones.rb
156
+ - lib/bitbucket_rest_api/client/repos.rb
157
+ - lib/bitbucket_rest_api/client/repos/changesets.rb
158
+ - lib/bitbucket_rest_api/client/repos/following.rb
159
+ - lib/bitbucket_rest_api/client/repos/keys.rb
160
+ - lib/bitbucket_rest_api/client/repos/pull_requests.rb
161
+ - lib/bitbucket_rest_api/client/repos/pull_requests/activity.rb
162
+ - lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb
163
+ - lib/bitbucket_rest_api/client/repos/pull_requests/commits.rb
164
+ - lib/bitbucket_rest_api/client/repos/services.rb
165
+ - lib/bitbucket_rest_api/client/repos/sources.rb
166
+ - lib/bitbucket_rest_api/client/user.rb
167
+ - lib/bitbucket_rest_api/client/users.rb
168
+ - lib/bitbucket_rest_api/client/users/account.rb
259
169
  - lib/bitbucket_rest_api/compatibility.rb
260
170
  - lib/bitbucket_rest_api/configuration.rb
261
171
  - lib/bitbucket_rest_api/connection.rb
@@ -278,33 +188,31 @@ files:
278
188
  - lib/bitbucket_rest_api/error/unknown_value.rb
279
189
  - lib/bitbucket_rest_api/error/unprocessable_entity.rb
280
190
  - lib/bitbucket_rest_api/error/validations.rb
281
- - lib/bitbucket_rest_api/invitations.rb
282
- - lib/bitbucket_rest_api/issues.rb
283
- - lib/bitbucket_rest_api/issues/comments.rb
284
- - lib/bitbucket_rest_api/issues/components.rb
285
- - lib/bitbucket_rest_api/issues/milestones.rb
191
+ - lib/bitbucket_rest_api/ext/faraday.rb
192
+ - lib/bitbucket_rest_api/middleware.rb
286
193
  - lib/bitbucket_rest_api/normalizer.rb
194
+ - lib/bitbucket_rest_api/null_encoder.rb
195
+ - lib/bitbucket_rest_api/page_iterator.rb
196
+ - lib/bitbucket_rest_api/page_links.rb
197
+ - lib/bitbucket_rest_api/paged_request.rb
198
+ - lib/bitbucket_rest_api/pagination.rb
287
199
  - lib/bitbucket_rest_api/parameter_filter.rb
288
- - lib/bitbucket_rest_api/repos.rb
289
- - lib/bitbucket_rest_api/repos/changesets.rb
290
- - lib/bitbucket_rest_api/repos/following.rb
291
- - lib/bitbucket_rest_api/repos/keys.rb
292
- - lib/bitbucket_rest_api/repos/services.rb
293
- - lib/bitbucket_rest_api/repos/sources.rb
200
+ - lib/bitbucket_rest_api/params_hash.rb
294
201
  - lib/bitbucket_rest_api/request.rb
295
202
  - lib/bitbucket_rest_api/request/basic_auth.rb
296
203
  - lib/bitbucket_rest_api/request/jsonize.rb
297
204
  - lib/bitbucket_rest_api/request/oauth.rb
205
+ - lib/bitbucket_rest_api/request/verbs.rb
298
206
  - lib/bitbucket_rest_api/response.rb
207
+ - lib/bitbucket_rest_api/response/header.rb
299
208
  - lib/bitbucket_rest_api/response/helpers.rb
300
209
  - lib/bitbucket_rest_api/response/jsonize.rb
301
210
  - lib/bitbucket_rest_api/response/mashify.rb
302
211
  - lib/bitbucket_rest_api/response/raise_error.rb
303
212
  - lib/bitbucket_rest_api/response/xmlize.rb
213
+ - lib/bitbucket_rest_api/response_wrapper.rb
304
214
  - lib/bitbucket_rest_api/result.rb
305
- - lib/bitbucket_rest_api/user.rb
306
215
  - lib/bitbucket_rest_api/users.rb
307
- - lib/bitbucket_rest_api/users/account.rb
308
216
  - lib/bitbucket_rest_api/utils/url.rb
309
217
  - lib/bitbucket_rest_api/validations.rb
310
218
  - lib/bitbucket_rest_api/validations/format.rb
@@ -331,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
239
  version: '0'
332
240
  requirements: []
333
241
  rubyforge_project:
334
- rubygems_version: 2.2.2
242
+ rubygems_version: 2.4.3
335
243
  signing_key:
336
244
  specification_version: 4
337
245
  summary: Ruby wrapper for the BitBucket API supporting OAuth and Basic Authentication
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'bitbucket_rest_api/core_ext/hash'
4
-
5
- module BitBucket
6
- class ApiFactory
7
-
8
- # Instantiates a new bitbucket api object
9
- def self.new(klass, options={})
10
- return create_instance(klass, options) if klass
11
- raise ArgumentError, 'must provide klass to be instantiated'
12
- end
13
-
14
- # Passes configuration options to instantiated class
15
- def self.create_instance(klass, options)
16
- options.symbolize_keys!
17
- instance = convert_to_constant(klass.to_s).new options
18
- BitBucket.api_client = instance
19
- instance
20
- end
21
-
22
- def self.convert_to_constant(classes)
23
- constant = BitBucket
24
- classes.split('::').each do |klass|
25
- constant = constant.const_get klass
26
- end
27
- return constant
28
- end
29
- end
30
- end # BitBucket