tinybucket2 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +86 -0
  3. data/Gemfile +32 -0
  4. data/LICENSE +21 -0
  5. data/README.md +387 -0
  6. data/Rakefile +47 -0
  7. data/lib/faraday_middleware/follow_oauth_redirects.rb +71 -0
  8. data/lib/tinybucket.rb +76 -0
  9. data/lib/tinybucket/api.rb +26 -0
  10. data/lib/tinybucket/api/base_api.rb +44 -0
  11. data/lib/tinybucket/api/branch_restrictions_api.rb +51 -0
  12. data/lib/tinybucket/api/branches_api.rb +48 -0
  13. data/lib/tinybucket/api/build_status_api.rb +69 -0
  14. data/lib/tinybucket/api/comments_api.rb +81 -0
  15. data/lib/tinybucket/api/commits_api.rb +97 -0
  16. data/lib/tinybucket/api/diff_api.rb +40 -0
  17. data/lib/tinybucket/api/helper.rb +27 -0
  18. data/lib/tinybucket/api/helper/api_helper.rb +39 -0
  19. data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +29 -0
  20. data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
  21. data/lib/tinybucket/api/helper/build_status_helper.rb +46 -0
  22. data/lib/tinybucket/api/helper/comments_helper.rb +51 -0
  23. data/lib/tinybucket/api/helper/commits_helper.rb +42 -0
  24. data/lib/tinybucket/api/helper/diff_helper.rb +31 -0
  25. data/lib/tinybucket/api/helper/issues_helper.rb +29 -0
  26. data/lib/tinybucket/api/helper/projects_helper.rb +28 -0
  27. data/lib/tinybucket/api/helper/pull_requests_helper.rb +58 -0
  28. data/lib/tinybucket/api/helper/repo_helper.rb +31 -0
  29. data/lib/tinybucket/api/helper/repos_helper.rb +23 -0
  30. data/lib/tinybucket/api/helper/team_helper.rb +45 -0
  31. data/lib/tinybucket/api/helper/user_helper.rb +33 -0
  32. data/lib/tinybucket/api/issues_api.rb +48 -0
  33. data/lib/tinybucket/api/projects_api.rb +26 -0
  34. data/lib/tinybucket/api/pull_requests_api.rb +117 -0
  35. data/lib/tinybucket/api/repo_api.rb +56 -0
  36. data/lib/tinybucket/api/repos_api.rb +28 -0
  37. data/lib/tinybucket/api/team_api.rb +91 -0
  38. data/lib/tinybucket/api/user_api.rb +66 -0
  39. data/lib/tinybucket/api_factory.rb +21 -0
  40. data/lib/tinybucket/client.rb +107 -0
  41. data/lib/tinybucket/config.rb +10 -0
  42. data/lib/tinybucket/connection.rb +84 -0
  43. data/lib/tinybucket/constants.rb +7 -0
  44. data/lib/tinybucket/enumerator.rb +47 -0
  45. data/lib/tinybucket/error.rb +12 -0
  46. data/lib/tinybucket/error/base_error.rb +14 -0
  47. data/lib/tinybucket/error/conflict.rb +8 -0
  48. data/lib/tinybucket/error/not_found.rb +8 -0
  49. data/lib/tinybucket/error/service_error.rb +26 -0
  50. data/lib/tinybucket/iterator.rb +79 -0
  51. data/lib/tinybucket/model.rb +25 -0
  52. data/lib/tinybucket/model/base.rb +45 -0
  53. data/lib/tinybucket/model/branch.rb +48 -0
  54. data/lib/tinybucket/model/branch_restriction.rb +46 -0
  55. data/lib/tinybucket/model/build_status.rb +57 -0
  56. data/lib/tinybucket/model/comment.rb +67 -0
  57. data/lib/tinybucket/model/commit.rb +114 -0
  58. data/lib/tinybucket/model/concerns.rb +19 -0
  59. data/lib/tinybucket/model/concerns/acceptable_attributes.rb +34 -0
  60. data/lib/tinybucket/model/concerns/api_callable.rb +21 -0
  61. data/lib/tinybucket/model/concerns/enumerable.rb +20 -0
  62. data/lib/tinybucket/model/concerns/reloadable.rb +41 -0
  63. data/lib/tinybucket/model/concerns/repository_keys.rb +45 -0
  64. data/lib/tinybucket/model/error_response.rb +24 -0
  65. data/lib/tinybucket/model/issue.rb +48 -0
  66. data/lib/tinybucket/model/page.rb +45 -0
  67. data/lib/tinybucket/model/profile.rb +70 -0
  68. data/lib/tinybucket/model/project.rb +44 -0
  69. data/lib/tinybucket/model/pull_request.rb +160 -0
  70. data/lib/tinybucket/model/repository.rb +219 -0
  71. data/lib/tinybucket/model/team.rb +96 -0
  72. data/lib/tinybucket/null_logger.rb +37 -0
  73. data/lib/tinybucket/parser.rb +15 -0
  74. data/lib/tinybucket/parser/collection_parser.rb +17 -0
  75. data/lib/tinybucket/parser/object_parser.rb +17 -0
  76. data/lib/tinybucket/request.rb +59 -0
  77. data/lib/tinybucket/resource.rb +75 -0
  78. data/lib/tinybucket/resource/base.rb +35 -0
  79. data/lib/tinybucket/resource/branch_restrictions.rb +47 -0
  80. data/lib/tinybucket/resource/branches.rb +35 -0
  81. data/lib/tinybucket/resource/commit/base.rb +14 -0
  82. data/lib/tinybucket/resource/commit/build_statuses.rb +50 -0
  83. data/lib/tinybucket/resource/commit/comments.rb +34 -0
  84. data/lib/tinybucket/resource/commits.rb +46 -0
  85. data/lib/tinybucket/resource/forks.rb +24 -0
  86. data/lib/tinybucket/resource/issues.rb +35 -0
  87. data/lib/tinybucket/resource/projects.rb +49 -0
  88. data/lib/tinybucket/resource/pull_request/base.rb +20 -0
  89. data/lib/tinybucket/resource/pull_request/comments.rb +32 -0
  90. data/lib/tinybucket/resource/pull_request/commits.rb +19 -0
  91. data/lib/tinybucket/resource/pull_requests.rb +50 -0
  92. data/lib/tinybucket/resource/repos.rb +40 -0
  93. data/lib/tinybucket/resource/team/base.rb +24 -0
  94. data/lib/tinybucket/resource/team/followers.rb +15 -0
  95. data/lib/tinybucket/resource/team/following.rb +15 -0
  96. data/lib/tinybucket/resource/team/members.rb +15 -0
  97. data/lib/tinybucket/resource/team/repos.rb +15 -0
  98. data/lib/tinybucket/resource/teams.rb +22 -0
  99. data/lib/tinybucket/resource/user/base.rb +26 -0
  100. data/lib/tinybucket/resource/user/followers.rb +15 -0
  101. data/lib/tinybucket/resource/user/following.rb +15 -0
  102. data/lib/tinybucket/resource/user/repos.rb +15 -0
  103. data/lib/tinybucket/resource/watchers.rb +24 -0
  104. data/lib/tinybucket/response.rb +9 -0
  105. data/lib/tinybucket/response/handler.rb +23 -0
  106. data/lib/tinybucket/version.rb +5 -0
  107. data/tinybucket.gemspec +30 -0
  108. metadata +248 -0
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Resource
5
+ module User
6
+ class Base < Tinybucket::Resource::Base
7
+ def initialize(user_name, options)
8
+ @user_name = user_name
9
+ @args = [options]
10
+ end
11
+
12
+ protected
13
+
14
+ def user_api
15
+ create_api('User').tap do |api|
16
+ api.username = @user_name
17
+ end
18
+ end
19
+
20
+ def create_user_enumerator(method)
21
+ create_enumerator(user_api, method, *@args)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Resource
5
+ module User
6
+ class Followers < Tinybucket::Resource::User::Base
7
+ private
8
+
9
+ def enumerator
10
+ create_user_enumerator(:followers)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Resource
5
+ module User
6
+ class Following < Tinybucket::Resource::User::Base
7
+ private
8
+
9
+ def enumerator
10
+ create_user_enumerator(:following)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Resource
5
+ module User
6
+ class Repos < Tinybucket::Resource::User::Base
7
+ private
8
+
9
+ def enumerator
10
+ create_user_enumerator(:repos)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Resource
5
+ class Watchers < Base
6
+ def initialize(repo, options)
7
+ @repo = repo
8
+ @args = [options]
9
+ end
10
+
11
+ private
12
+
13
+ def repo_api
14
+ create_api('Repo', @repo.repo_keys)
15
+ end
16
+
17
+ def enumerator
18
+ create_enumerator(repo_api, :watchers, *@args) do |m|
19
+ inject_repo_keys(m, @repo.repo_keys)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Response
5
+ extend ActiveSupport::Autoload
6
+
7
+ autoload :Handler
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Response
5
+ class Handler < Faraday::Response::Middleware
6
+ def on_complete(env)
7
+ status_code = env[:status].to_i
8
+
9
+ return if status_code < 400
10
+
11
+ case status_code
12
+ when 404
13
+ raise Tinybucket::Error::NotFound.new(env)
14
+ when 409
15
+ raise Tinybucket::Error::Conflict.new(env)
16
+ else
17
+ Tinybucket.logger.error "Invalid response code:#{status_code}"
18
+ raise Tinybucket::Error::ServiceError.new(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ VERSION = '1.0.0'.freeze
5
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'tinybucket/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'tinybucket2'
9
+ spec.version = Tinybucket::VERSION
10
+ spec.authors = ['hirakiuc']
11
+ spec.email = ['hirakiuc@gmail.com']
12
+ spec.summary = 'ruby wrapper for the Bitbucket REST API (v2) with oauth'
13
+ spec.description = 'ruby wrapper for the Bitbucket REST API (v2) with oauth inspired by vongrippen/bitbucket.'
14
+ spec.homepage = 'http://hirakiuc.github.io/tinybucket/'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = Dir['lib/**/*', 'LICENSE', 'Rakefile', 'Gemfile', 'tinybucket.gemspec', 'README.md', '.rubocop.yml']
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'activemodel', ['>= 4.1.6']
23
+ spec.add_runtime_dependency 'activesupport', ['>= 4.1.6']
24
+ spec.add_runtime_dependency 'faraday', ['~> 0.9']
25
+ spec.add_runtime_dependency 'faraday_middleware', ['~> 0.10']
26
+ spec.add_runtime_dependency 'faraday-http-cache', ['~> 1.2']
27
+ spec.add_runtime_dependency 'simple_oauth', ['~> 0.3']
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.10'
30
+ end
metadata ADDED
@@ -0,0 +1,248 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tinybucket2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - hirakiuc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.1.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday_middleware
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday-http-cache
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simple_oauth
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.10'
111
+ description: ruby wrapper for the Bitbucket REST API (v2) with oauth inspired by vongrippen/bitbucket.
112
+ email:
113
+ - hirakiuc@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".rubocop.yml"
119
+ - Gemfile
120
+ - LICENSE
121
+ - README.md
122
+ - Rakefile
123
+ - lib/faraday_middleware/follow_oauth_redirects.rb
124
+ - lib/tinybucket.rb
125
+ - lib/tinybucket/api.rb
126
+ - lib/tinybucket/api/base_api.rb
127
+ - lib/tinybucket/api/branch_restrictions_api.rb
128
+ - lib/tinybucket/api/branches_api.rb
129
+ - lib/tinybucket/api/build_status_api.rb
130
+ - lib/tinybucket/api/comments_api.rb
131
+ - lib/tinybucket/api/commits_api.rb
132
+ - lib/tinybucket/api/diff_api.rb
133
+ - lib/tinybucket/api/helper.rb
134
+ - lib/tinybucket/api/helper/api_helper.rb
135
+ - lib/tinybucket/api/helper/branch_restrictions_helper.rb
136
+ - lib/tinybucket/api/helper/branches_helper.rb
137
+ - lib/tinybucket/api/helper/build_status_helper.rb
138
+ - lib/tinybucket/api/helper/comments_helper.rb
139
+ - lib/tinybucket/api/helper/commits_helper.rb
140
+ - lib/tinybucket/api/helper/diff_helper.rb
141
+ - lib/tinybucket/api/helper/issues_helper.rb
142
+ - lib/tinybucket/api/helper/projects_helper.rb
143
+ - lib/tinybucket/api/helper/pull_requests_helper.rb
144
+ - lib/tinybucket/api/helper/repo_helper.rb
145
+ - lib/tinybucket/api/helper/repos_helper.rb
146
+ - lib/tinybucket/api/helper/team_helper.rb
147
+ - lib/tinybucket/api/helper/user_helper.rb
148
+ - lib/tinybucket/api/issues_api.rb
149
+ - lib/tinybucket/api/projects_api.rb
150
+ - lib/tinybucket/api/pull_requests_api.rb
151
+ - lib/tinybucket/api/repo_api.rb
152
+ - lib/tinybucket/api/repos_api.rb
153
+ - lib/tinybucket/api/team_api.rb
154
+ - lib/tinybucket/api/user_api.rb
155
+ - lib/tinybucket/api_factory.rb
156
+ - lib/tinybucket/client.rb
157
+ - lib/tinybucket/config.rb
158
+ - lib/tinybucket/connection.rb
159
+ - lib/tinybucket/constants.rb
160
+ - lib/tinybucket/enumerator.rb
161
+ - lib/tinybucket/error.rb
162
+ - lib/tinybucket/error/base_error.rb
163
+ - lib/tinybucket/error/conflict.rb
164
+ - lib/tinybucket/error/not_found.rb
165
+ - lib/tinybucket/error/service_error.rb
166
+ - lib/tinybucket/iterator.rb
167
+ - lib/tinybucket/model.rb
168
+ - lib/tinybucket/model/base.rb
169
+ - lib/tinybucket/model/branch.rb
170
+ - lib/tinybucket/model/branch_restriction.rb
171
+ - lib/tinybucket/model/build_status.rb
172
+ - lib/tinybucket/model/comment.rb
173
+ - lib/tinybucket/model/commit.rb
174
+ - lib/tinybucket/model/concerns.rb
175
+ - lib/tinybucket/model/concerns/acceptable_attributes.rb
176
+ - lib/tinybucket/model/concerns/api_callable.rb
177
+ - lib/tinybucket/model/concerns/enumerable.rb
178
+ - lib/tinybucket/model/concerns/reloadable.rb
179
+ - lib/tinybucket/model/concerns/repository_keys.rb
180
+ - lib/tinybucket/model/error_response.rb
181
+ - lib/tinybucket/model/issue.rb
182
+ - lib/tinybucket/model/page.rb
183
+ - lib/tinybucket/model/profile.rb
184
+ - lib/tinybucket/model/project.rb
185
+ - lib/tinybucket/model/pull_request.rb
186
+ - lib/tinybucket/model/repository.rb
187
+ - lib/tinybucket/model/team.rb
188
+ - lib/tinybucket/null_logger.rb
189
+ - lib/tinybucket/parser.rb
190
+ - lib/tinybucket/parser/collection_parser.rb
191
+ - lib/tinybucket/parser/object_parser.rb
192
+ - lib/tinybucket/request.rb
193
+ - lib/tinybucket/resource.rb
194
+ - lib/tinybucket/resource/base.rb
195
+ - lib/tinybucket/resource/branch_restrictions.rb
196
+ - lib/tinybucket/resource/branches.rb
197
+ - lib/tinybucket/resource/commit/base.rb
198
+ - lib/tinybucket/resource/commit/build_statuses.rb
199
+ - lib/tinybucket/resource/commit/comments.rb
200
+ - lib/tinybucket/resource/commits.rb
201
+ - lib/tinybucket/resource/forks.rb
202
+ - lib/tinybucket/resource/issues.rb
203
+ - lib/tinybucket/resource/projects.rb
204
+ - lib/tinybucket/resource/pull_request/base.rb
205
+ - lib/tinybucket/resource/pull_request/comments.rb
206
+ - lib/tinybucket/resource/pull_request/commits.rb
207
+ - lib/tinybucket/resource/pull_requests.rb
208
+ - lib/tinybucket/resource/repos.rb
209
+ - lib/tinybucket/resource/team/base.rb
210
+ - lib/tinybucket/resource/team/followers.rb
211
+ - lib/tinybucket/resource/team/following.rb
212
+ - lib/tinybucket/resource/team/members.rb
213
+ - lib/tinybucket/resource/team/repos.rb
214
+ - lib/tinybucket/resource/teams.rb
215
+ - lib/tinybucket/resource/user/base.rb
216
+ - lib/tinybucket/resource/user/followers.rb
217
+ - lib/tinybucket/resource/user/following.rb
218
+ - lib/tinybucket/resource/user/repos.rb
219
+ - lib/tinybucket/resource/watchers.rb
220
+ - lib/tinybucket/response.rb
221
+ - lib/tinybucket/response/handler.rb
222
+ - lib/tinybucket/version.rb
223
+ - tinybucket.gemspec
224
+ homepage: http://hirakiuc.github.io/tinybucket/
225
+ licenses:
226
+ - MIT
227
+ metadata: {}
228
+ post_install_message:
229
+ rdoc_options: []
230
+ require_paths:
231
+ - lib
232
+ required_ruby_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ requirements: []
243
+ rubyforge_project:
244
+ rubygems_version: 2.7.8
245
+ signing_key:
246
+ specification_version: 4
247
+ summary: ruby wrapper for the Bitbucket REST API (v2) with oauth
248
+ test_files: []