tinybucket 1.3.0 → 1.4.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.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -1
  3. data/Gemfile +8 -7
  4. data/README.md +28 -5
  5. data/Rakefile +1 -0
  6. data/lib/faraday_middleware/follow_oauth_redirects.rb +5 -2
  7. data/lib/tinybucket.rb +2 -0
  8. data/lib/tinybucket/api.rb +3 -0
  9. data/lib/tinybucket/api/base_api.rb +2 -0
  10. data/lib/tinybucket/api/branch_restrictions_api.rb +6 -5
  11. data/lib/tinybucket/api/branches_api.rb +48 -0
  12. data/lib/tinybucket/api/build_status_api.rb +15 -1
  13. data/lib/tinybucket/api/comments_api.rb +7 -6
  14. data/lib/tinybucket/api/commits_api.rb +25 -4
  15. data/lib/tinybucket/api/diff_api.rb +4 -3
  16. data/lib/tinybucket/api/helper.rb +3 -0
  17. data/lib/tinybucket/api/helper/api_helper.rb +2 -0
  18. data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +2 -0
  19. data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
  20. data/lib/tinybucket/api/helper/build_status_helper.rb +11 -0
  21. data/lib/tinybucket/api/helper/comments_helper.rb +2 -0
  22. data/lib/tinybucket/api/helper/commits_helper.rb +8 -0
  23. data/lib/tinybucket/api/helper/diff_helper.rb +2 -0
  24. data/lib/tinybucket/api/helper/pull_requests_helper.rb +2 -0
  25. data/lib/tinybucket/api/helper/repo_helper.rb +2 -0
  26. data/lib/tinybucket/api/helper/repos_helper.rb +2 -0
  27. data/lib/tinybucket/api/helper/team_helper.rb +2 -0
  28. data/lib/tinybucket/api/helper/user_helper.rb +2 -0
  29. data/lib/tinybucket/api/pull_requests_api.rb +4 -3
  30. data/lib/tinybucket/api/repo_api.rb +4 -3
  31. data/lib/tinybucket/api/repos_api.rb +3 -1
  32. data/lib/tinybucket/api/team_api.rb +4 -2
  33. data/lib/tinybucket/api/user_api.rb +3 -1
  34. data/lib/tinybucket/api_factory.rb +2 -0
  35. data/lib/tinybucket/client.rb +3 -2
  36. data/lib/tinybucket/config.rb +5 -1
  37. data/lib/tinybucket/connection.rb +21 -8
  38. data/lib/tinybucket/constants.rb +2 -0
  39. data/lib/tinybucket/enumerator.rb +2 -0
  40. data/lib/tinybucket/error.rb +2 -0
  41. data/lib/tinybucket/error/base_error.rb +2 -0
  42. data/lib/tinybucket/error/conflict.rb +2 -0
  43. data/lib/tinybucket/error/not_found.rb +2 -0
  44. data/lib/tinybucket/error/service_error.rb +2 -0
  45. data/lib/tinybucket/iterator.rb +4 -2
  46. data/lib/tinybucket/model.rb +3 -0
  47. data/lib/tinybucket/model/base.rb +2 -2
  48. data/lib/tinybucket/model/branch.rb +48 -0
  49. data/lib/tinybucket/model/branch_restriction.rb +4 -2
  50. data/lib/tinybucket/model/build_status.rb +3 -1
  51. data/lib/tinybucket/model/comment.rb +4 -2
  52. data/lib/tinybucket/model/commit.rb +6 -2
  53. data/lib/tinybucket/model/concerns.rb +2 -0
  54. data/lib/tinybucket/model/concerns/acceptable_attributes.rb +2 -0
  55. data/lib/tinybucket/model/concerns/api_callable.rb +2 -0
  56. data/lib/tinybucket/model/concerns/enumerable.rb +2 -0
  57. data/lib/tinybucket/model/concerns/reloadable.rb +2 -0
  58. data/lib/tinybucket/model/concerns/repository_keys.rb +2 -0
  59. data/lib/tinybucket/model/error_response.rb +4 -2
  60. data/lib/tinybucket/model/page.rb +4 -2
  61. data/lib/tinybucket/model/profile.rb +4 -2
  62. data/lib/tinybucket/model/pull_request.rb +4 -2
  63. data/lib/tinybucket/model/repository.rb +31 -5
  64. data/lib/tinybucket/model/team.rb +4 -2
  65. data/lib/tinybucket/null_logger.rb +2 -0
  66. data/lib/tinybucket/parser.rb +5 -0
  67. data/lib/tinybucket/parser/base_parser.rb +3 -2
  68. data/lib/tinybucket/parser/branch_parser.rb +13 -0
  69. data/lib/tinybucket/parser/branch_restriction_parser.rb +2 -0
  70. data/lib/tinybucket/parser/branch_restrictions_parser.rb +2 -0
  71. data/lib/tinybucket/parser/branches_parser.rb +11 -0
  72. data/lib/tinybucket/parser/build_status_parser.rb +2 -0
  73. data/lib/tinybucket/parser/builds_parser.rb +11 -0
  74. data/lib/tinybucket/parser/comment_parser.rb +2 -0
  75. data/lib/tinybucket/parser/comments_parser.rb +2 -0
  76. data/lib/tinybucket/parser/commit_parser.rb +2 -0
  77. data/lib/tinybucket/parser/commits_parser.rb +2 -0
  78. data/lib/tinybucket/parser/profile_parser.rb +2 -0
  79. data/lib/tinybucket/parser/profiles_parser.rb +2 -0
  80. data/lib/tinybucket/parser/pull_request_parser.rb +2 -0
  81. data/lib/tinybucket/parser/pull_requests_parser.rb +2 -0
  82. data/lib/tinybucket/parser/repo_parser.rb +2 -0
  83. data/lib/tinybucket/parser/repos_parser.rb +2 -0
  84. data/lib/tinybucket/parser/team_parser.rb +2 -0
  85. data/lib/tinybucket/parser/teams_parser.rb +2 -0
  86. data/lib/tinybucket/request.rb +2 -0
  87. data/lib/tinybucket/resource.rb +3 -0
  88. data/lib/tinybucket/resource/base.rb +6 -0
  89. data/lib/tinybucket/resource/branch_restrictions.rb +2 -0
  90. data/lib/tinybucket/resource/branches.rb +35 -0
  91. data/lib/tinybucket/resource/commit/base.rb +2 -0
  92. data/lib/tinybucket/resource/commit/build_statuses.rb +6 -3
  93. data/lib/tinybucket/resource/commit/comments.rb +2 -0
  94. data/lib/tinybucket/resource/commits.rb +13 -0
  95. data/lib/tinybucket/resource/forks.rb +2 -0
  96. data/lib/tinybucket/resource/pull_request/base.rb +2 -0
  97. data/lib/tinybucket/resource/pull_request/comments.rb +2 -0
  98. data/lib/tinybucket/resource/pull_request/commits.rb +2 -0
  99. data/lib/tinybucket/resource/pull_requests.rb +2 -0
  100. data/lib/tinybucket/resource/repos.rb +2 -0
  101. data/lib/tinybucket/resource/team/base.rb +2 -0
  102. data/lib/tinybucket/resource/team/followers.rb +2 -0
  103. data/lib/tinybucket/resource/team/following.rb +2 -0
  104. data/lib/tinybucket/resource/team/members.rb +2 -0
  105. data/lib/tinybucket/resource/team/repos.rb +2 -0
  106. data/lib/tinybucket/resource/user/base.rb +2 -0
  107. data/lib/tinybucket/resource/user/followers.rb +2 -0
  108. data/lib/tinybucket/resource/user/following.rb +2 -0
  109. data/lib/tinybucket/resource/user/repos.rb +2 -0
  110. data/lib/tinybucket/resource/watchers.rb +2 -0
  111. data/lib/tinybucket/response.rb +2 -0
  112. data/lib/tinybucket/response/handler.rb +2 -0
  113. data/lib/tinybucket/version.rb +3 -1
  114. data/tinybucket.gemspec +1 -1
  115. metadata +11 -193
  116. data/.coveralls.yml +0 -1
  117. data/.gitignore +0 -33
  118. data/.rspec +0 -1
  119. data/.travis.yml +0 -13
  120. data/Guardfile +0 -13
  121. data/spec/fixtures/branch_restriction.json +0 -17
  122. data/spec/fixtures/build_status.json +0 -16
  123. data/spec/fixtures/comment.json +0 -30
  124. data/spec/fixtures/commit.json +0 -83
  125. data/spec/fixtures/profile.json +0 -29
  126. data/spec/fixtures/pull_request.json +0 -106
  127. data/spec/fixtures/repositories/get.json +0 -78
  128. data/spec/fixtures/repositories/test_owner/get.json +0 -78
  129. data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/1/get.json +0 -17
  130. data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/get.json +0 -101
  131. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/approve/post.json +0 -16
  132. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/1/get.json +0 -38
  133. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/get.json +0 -40
  134. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/get.json +0 -83
  135. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/post.json +0 -16
  136. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json +0 -16
  137. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json +0 -16
  138. data/spec/fixtures/repositories/test_owner/test_repo/commits/get.json +0 -73
  139. data/spec/fixtures/repositories/test_owner/test_repo/diff/1/get.json +0 -21
  140. data/spec/fixtures/repositories/test_owner/test_repo/forks/get.json +0 -78
  141. data/spec/fixtures/repositories/test_owner/test_repo/get.json +0 -71
  142. data/spec/fixtures/repositories/test_owner/test_repo/patch/1/get.json +0 -29
  143. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/delete.json +0 -3
  144. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/post.json +0 -3
  145. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/1/get.json +0 -30
  146. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +0 -44
  147. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +0 -66
  148. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/decline/post.json +0 -116
  149. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/diff/get.txt +0 -13
  150. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/get.json +0 -164
  151. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/merge/post.json +0 -123
  152. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +0 -112
  153. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_declined.json +0 -112
  154. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_merged.json +0 -112
  155. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_open.json +0 -112
  156. data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +0 -32
  157. data/spec/fixtures/repository.json +0 -72
  158. data/spec/fixtures/team.json +0 -32
  159. data/spec/fixtures/teams/test_team/followers/get.json +0 -36
  160. data/spec/fixtures/teams/test_team/following/get.json +0 -39
  161. data/spec/fixtures/teams/test_team/get.json +0 -32
  162. data/spec/fixtures/teams/test_team/members/get.json +0 -36
  163. data/spec/fixtures/teams/test_team/repositories/get.json +0 -125
  164. data/spec/fixtures/users/test_owner/followers/get.json +0 -65
  165. data/spec/fixtures/users/test_owner/following/get.json +0 -100
  166. data/spec/fixtures/users/test_owner/get.json +0 -29
  167. data/spec/lib/tinybucket/api/branch_restrictions_api_spec.rb +0 -77
  168. data/spec/lib/tinybucket/api/build_status_api_spec.rb +0 -65
  169. data/spec/lib/tinybucket/api/comments_api_spec.rb +0 -132
  170. data/spec/lib/tinybucket/api/commits_api_spec.rb +0 -152
  171. data/spec/lib/tinybucket/api/diff_api_spec.rb +0 -5
  172. data/spec/lib/tinybucket/api/pull_requests_api_spec.rb +0 -259
  173. data/spec/lib/tinybucket/api/repo_api_spec.rb +0 -99
  174. data/spec/lib/tinybucket/api/repos_api_spec.rb +0 -27
  175. data/spec/lib/tinybucket/api/team_api_spec.rb +0 -82
  176. data/spec/lib/tinybucket/api/user_api_spec.rb +0 -73
  177. data/spec/lib/tinybucket/api_factory_spec.rb +0 -18
  178. data/spec/lib/tinybucket/client_spec.rb +0 -100
  179. data/spec/lib/tinybucket/connection_spec.rb +0 -30
  180. data/spec/lib/tinybucket/error/service_error_spec.rb +0 -23
  181. data/spec/lib/tinybucket/model/branch_restriction_spec.rb +0 -35
  182. data/spec/lib/tinybucket/model/build_status_spec.rb +0 -66
  183. data/spec/lib/tinybucket/model/comment_spec.rb +0 -37
  184. data/spec/lib/tinybucket/model/commit_spec.rb +0 -108
  185. data/spec/lib/tinybucket/model/page_spec.rb +0 -28
  186. data/spec/lib/tinybucket/model/profile_spec.rb +0 -52
  187. data/spec/lib/tinybucket/model/pull_request_spec.rb +0 -141
  188. data/spec/lib/tinybucket/model/repository_spec.rb +0 -131
  189. data/spec/lib/tinybucket/model/team_spec.rb +0 -70
  190. data/spec/lib/tinybucket/null_logger_spec.rb +0 -53
  191. data/spec/lib/tinybucket/resource/branch_restrictions_spec.rb +0 -60
  192. data/spec/lib/tinybucket/resource/commit/build_statuses_spec.rb +0 -50
  193. data/spec/lib/tinybucket/resource/commit/comments_spec.rb +0 -49
  194. data/spec/lib/tinybucket/resource/commits_spec.rb +0 -43
  195. data/spec/lib/tinybucket/resource/forks_spec.rb +0 -36
  196. data/spec/lib/tinybucket/resource/pull_request/comments_spec.rb +0 -41
  197. data/spec/lib/tinybucket/resource/pull_request/commits_spec.rb +0 -41
  198. data/spec/lib/tinybucket/resource/pull_requests_spec.rb +0 -59
  199. data/spec/lib/tinybucket/resource/repos_spec.rb +0 -76
  200. data/spec/lib/tinybucket/resource/team/followers_spec.rb +0 -27
  201. data/spec/lib/tinybucket/resource/team/following_spec.rb +0 -27
  202. data/spec/lib/tinybucket/resource/team/members_spec.rb +0 -27
  203. data/spec/lib/tinybucket/resource/team/repos_spec.rb +0 -27
  204. data/spec/lib/tinybucket/resource/user/followers_spec.rb +0 -27
  205. data/spec/lib/tinybucket/resource/user/following_spec.rb +0 -27
  206. data/spec/lib/tinybucket/resource/user/repos_spec.rb +0 -27
  207. data/spec/lib/tinybucket/resource/watchers_spec.rb +0 -38
  208. data/spec/lib/tinybucket_spec.rb +0 -42
  209. data/spec/spec_helper.rb +0 -45
  210. data/spec/support/api_response_macros.rb +0 -74
  211. data/spec/support/fixture_macros.rb +0 -5
  212. data/spec/support/model_macros.rb +0 -103
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Api
5
+ module Helper
6
+ module BranchesHelper
7
+ include ::Tinybucket::Api::Helper::ApiHelper
8
+
9
+ private
10
+
11
+ def path_to_list
12
+ build_path(base_path)
13
+ end
14
+
15
+ def path_to_find(branch)
16
+ build_path(base_path,
17
+ [branch, 'branch'])
18
+ end
19
+
20
+ def base_path
21
+ build_path('/repositories',
22
+ [repo_owner, 'repo_owner'],
23
+ [repo_slug, 'repo_slug'],
24
+ 'refs', 'branches')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -6,6 +8,15 @@ module Tinybucket
6
8
 
7
9
  private
8
10
 
11
+ def path_to_list
12
+ build_path('/repositories',
13
+ [repo_owner, 'repo_owner'],
14
+ [repo_slug, 'repo_slug'],
15
+ 'commit',
16
+ [revision, 'revision'],
17
+ 'statuses')
18
+ end
19
+
9
20
  def path_to_find(revision, key)
10
21
  build_path(base_path(revision),
11
22
  [key, 'key'])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -16,6 +18,12 @@ module Tinybucket
16
18
  [revision, 'revision'])
17
19
  end
18
20
 
21
+ def path_to_branch(branch)
22
+ build_path(base_path,
23
+ 'commits',
24
+ [branch, 'branch'])
25
+ end
26
+
19
27
  def path_to_approve(revision)
20
28
  build_path(base_path,
21
29
  'commit',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  module Helper
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  # PullRequests Api client
4
6
  #
5
- # @see https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html
7
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests
6
8
  # pullrequests Resource
7
9
  #
8
10
  # @!attribute [rw] repo_owner
9
11
  # @return [String] repository owner name.
10
12
  # @!attribute [rw] repo_slug
11
- # @return [String] repository slug. (about {https://confluence.atlassian.com/bitbucket/repositories-endpoint-423626330.html#repositoriesEndpoint-Overview
12
- # repo_slug})
13
+ # @return [String] {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D repository slug}.
13
14
  class PullRequestsApi < BaseApi
14
15
  include Tinybucket::Api::Helper::PullRequestsHelper
15
16
 
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  # Repo Api client
4
6
  #
5
- # @see https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html
7
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories
6
8
  # repository Resource
7
9
  #
8
10
  # @!attribute [rw] repo_owner
9
11
  # @return [String] repository owner name.
10
12
  # @!attribute [rw] repo_slug
11
- # @return [String] repository slug. (about {https://confluence.atlassian.com/bitbucket/repositories-endpoint-423626330.html#repositoriesEndpoint-Overview
12
- # repo_slug})
13
+ # @return [String] {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D repository slug}.
13
14
  class RepoApi < BaseApi
14
15
  include Tinybucket::Api::Helper::RepoHelper
15
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  # Repos Api client
@@ -6,7 +8,7 @@ module Tinybucket
6
8
 
7
9
  # Send 'GET a list of repositories for an account' request
8
10
  #
9
- # @see https://confluence.atlassian.com/bitbucket/repositories-endpoint-423626330.html#repositoriesEndpoint-GETalistofrepositoriesforanaccount
11
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories
10
12
  # GET a list of repositories for an account
11
13
  #
12
14
  # @param options [Hash]
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  # Team Api client
4
6
  #
5
- # @see https://confluence.atlassian.com/bitbucket/teams-endpoint-423626335.html
7
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams
6
8
  # teams Endpoint
7
9
  class TeamApi < BaseApi
8
10
  include Tinybucket::Api::Helper::TeamHelper
@@ -46,7 +48,7 @@ module Tinybucket
46
48
  )
47
49
  end
48
50
 
49
- # Send 'GET a lisf of accounts the tema is following' request
51
+ # Send 'GET a lisf of accounts the team is following' request
50
52
  #
51
53
  # @param name [String] The team's name
52
54
  # @param options [Hash]
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Api
3
5
  # User Api client
4
6
  #
5
- # @see https://confluence.atlassian.com/bitbucket/users-endpoint-423626336.html
7
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/users/%7Busername%7D
6
8
  # users Endpoint
7
9
  #
8
10
  # @!attribute [rw] username
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  class ApiFactory
3
5
  class << self
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  class Client
3
5
  include ::Tinybucket::Model::Concerns::Enumerable
@@ -41,8 +43,7 @@ module Tinybucket
41
43
  # Get the repository
42
44
  #
43
45
  # @param owner [String] repository owner name.
44
- # @param repo_slug [String] repository slug. (about {https://confluence.atlassian.com/bitbucket/repositories-endpoint-423626330.html#repositoriesEndpoint-Overview
45
- # repo_slug})
46
+ # @param repo_slug [String] {https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D repository slug}.
46
47
  # @return [Tinybucket::Model::Repository]
47
48
  def repo(owner, repo_slug)
48
49
  Tinybucket::Model::Repository.new({}).tap do |m|
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  class Config
3
5
  include ActiveSupport::Configurable
4
- config_accessor :logger, :oauth_token, :oauth_secret, :cache_store_options
6
+ config_accessor :logger, :oauth_token, :oauth_secret, \
7
+ :cache_store_options, :access_token, \
8
+ :client_id, :client_secret, :user_agent
5
9
  end
6
10
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Connection
5
+ DEFAULT_USER_AGENT = 'Tinybucket Ruby Bitbucket REST client'.freeze
6
+
3
7
  def clear_cache
4
8
  @connection = nil
5
9
  end
@@ -23,7 +27,7 @@ module Tinybucket
23
27
  def default_options(_options)
24
28
  {
25
29
  headers: {
26
- USER_AGENT: 'test client' # TODO: fix this !
30
+ USER_AGENT: Tinybucket.config.user_agent || DEFAULT_USER_AGENT
27
31
  },
28
32
  ssl: { verify: false },
29
33
  url: 'https://api.bitbucket.org/2.0'.freeze
@@ -32,18 +36,13 @@ module Tinybucket
32
36
 
33
37
  def default_middleware(_options)
34
38
  proc do |conn|
35
- oauth_secrets = {
36
- consumer_key: Tinybucket.config.oauth_token,
37
- consumer_secret: Tinybucket.config.oauth_secret
38
- }
39
-
40
39
  configure_response_cache(conn)
41
40
 
42
41
  conn.request :multipart
43
42
  conn.request :url_encoded
44
- conn.request :oauth, oauth_secrets
45
43
 
46
- conn.response :follow_oauth_redirects, oauth_secrets
44
+ configure_auth(conn)
45
+
47
46
  conn.response :json, content_type: /\bjson$/
48
47
  conn.use Tinybucket::Response::Handler
49
48
  conn.use :instrumentation
@@ -52,6 +51,20 @@ module Tinybucket
52
51
  end
53
52
  end
54
53
 
54
+ def configure_auth(conn)
55
+ if Tinybucket.config.access_token
56
+ conn.request :oauth2, Tinybucket.config.access_token
57
+ else
58
+ oauth_secrets = {
59
+ consumer_key: Tinybucket.config.oauth_token,
60
+ consumer_secret: Tinybucket.config.oauth_secret
61
+ }
62
+
63
+ conn.request :oauth, oauth_secrets
64
+ conn.response :follow_oauth_redirects, oauth_secrets
65
+ end
66
+ end
67
+
55
68
  def configure_response_cache(conn)
56
69
  return unless Tinybucket.config.cache_store_options
57
70
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Constants
3
5
  MISSING_REPOSITORY_KEY = 'This method call require repository keys.'.freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  class Enumerator < ::Enumerator
3
5
  # Constructor
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Error
3
5
  extend ActiveSupport::Autoload
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Error
3
5
  class BaseError < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Error
3
5
  class Conflict < ServiceError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Error
3
5
  class NotFound < ServiceError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Error
3
5
  class ServiceError < BaseError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  # Iterator
3
5
  #
@@ -25,11 +27,11 @@ module Tinybucket
25
27
 
26
28
  # Get collection size.
27
29
  #
28
- # @note This method return {https://confluence.atlassian.com/bitbucket/version-2-423626329.html#Version2-Pagingthroughobjectcollections
30
+ # @note This method return {https://developer.atlassian.com/bitbucket/api/2/reference/meta/pagination
29
31
  # size attribute of object collection wrapper}.
30
32
  # So this method may return nil.
31
33
  #
32
- # @see https://confluence.atlassian.com/bitbucket/version-2-423626329.html#Version2-Pagingthroughobjectcollections
34
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/meta/pagination
33
35
  # Paging through object collections
34
36
  #
35
37
  # @return [Fixnum, NillClas] collection size.
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Model
3
5
  extend ActiveSupport::Autoload
4
6
 
5
7
  [
6
8
  :Base,
9
+ :Branch,
7
10
  :BranchRestriction,
8
11
  :BuildStatus,
9
12
  :Comment,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tinybucket
2
4
  module Model
3
5
  class Base
@@ -22,9 +24,7 @@ module Tinybucket
22
24
  if acceptable_attribute?(key)
23
25
  send("#{key}=".intern, value)
24
26
  else
25
- # rubocop:disable Metrics/LineLength
26
27
  logger.warn("Ignored '#{key}' attribute (value: #{value}). [#{self.class}]")
27
- # rubocop:enable Metrics/LineLength
28
28
  end
29
29
  end
30
30
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Model
5
+ # Branch
6
+ #
7
+ # @see https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/refs/branches
8
+ # Branch Resource
9
+ #
10
+ # @!attribute [rw] links
11
+ # @return [Hash]
12
+ # @!attribute [rw] type
13
+ # @return [String]
14
+ # @!attribute [rw] name
15
+ # @return [String]
16
+ # @!attribute [rw] repository
17
+ # @return [Hash]
18
+ # @!attribute [rw] target
19
+ # @return [Hash]
20
+ class Branch < Base
21
+ include Tinybucket::Model::Concerns::RepositoryKeys
22
+
23
+ acceptable_attributes :links, :type, :name, :repository, :target
24
+
25
+ # Returns the commits available for the specific branch
26
+ #
27
+ # @param options [Hash]
28
+ # @return [Tinybucket::Resource::Commits]
29
+ def commits(options = {})
30
+ commits_resource.branch(name, options)
31
+ end
32
+
33
+ private
34
+
35
+ def commits_resource(options = {})
36
+ Tinybucket::Resource::Commits.new(self, options)
37
+ end
38
+
39
+ def branches_api
40
+ create_api('Branches', repo_keys)
41
+ end
42
+
43
+ def load_model
44
+ branches_api.find(name, {})
45
+ end
46
+ end
47
+ end
48
+ end