tinybucket 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -5
- data/README.md +100 -24
- data/lib/tinybucket.rb +1 -0
- data/lib/tinybucket/api.rb +1 -0
- data/lib/tinybucket/api/build_status_api.rb +55 -0
- data/lib/tinybucket/api/helper.rb +1 -0
- data/lib/tinybucket/api/helper/build_status_helper.rb +35 -0
- data/lib/tinybucket/client.rb +28 -45
- data/lib/tinybucket/enumerator.rb +4 -3
- data/lib/tinybucket/model.rb +2 -1
- data/lib/tinybucket/model/base.rb +1 -17
- data/lib/tinybucket/model/build_status.rb +55 -0
- data/lib/tinybucket/model/commit.rb +32 -15
- data/lib/tinybucket/model/concerns.rb +1 -0
- data/lib/tinybucket/model/concerns/api_callable.rb +19 -0
- data/lib/tinybucket/model/profile.rb +9 -26
- data/lib/tinybucket/model/pull_request.rb +18 -28
- data/lib/tinybucket/model/repository.rb +29 -76
- data/lib/tinybucket/model/team.rb +9 -34
- data/lib/tinybucket/parser.rb +1 -0
- data/lib/tinybucket/parser/build_status_parser.rb +9 -0
- data/lib/tinybucket/resource.rb +70 -0
- data/lib/tinybucket/resource/base.rb +29 -0
- data/lib/tinybucket/resource/branch_restrictions.rb +45 -0
- data/lib/tinybucket/resource/commit/base.rb +12 -0
- data/lib/tinybucket/resource/commit/build_statuses.rb +47 -0
- data/lib/tinybucket/resource/commit/comments.rb +32 -0
- data/lib/tinybucket/resource/commits.rb +33 -0
- data/lib/tinybucket/resource/forks.rb +22 -0
- data/lib/tinybucket/resource/pull_request/base.rb +18 -0
- data/lib/tinybucket/resource/pull_request/comments.rb +30 -0
- data/lib/tinybucket/resource/pull_request/commits.rb +17 -0
- data/lib/tinybucket/resource/pull_requests.rb +48 -0
- data/lib/tinybucket/resource/repos.rb +38 -0
- data/lib/tinybucket/resource/team/base.rb +22 -0
- data/lib/tinybucket/resource/team/followers.rb +13 -0
- data/lib/tinybucket/resource/team/following.rb +13 -0
- data/lib/tinybucket/resource/team/members.rb +13 -0
- data/lib/tinybucket/resource/team/repos.rb +13 -0
- data/lib/tinybucket/resource/user/base.rb +24 -0
- data/lib/tinybucket/resource/user/followers.rb +13 -0
- data/lib/tinybucket/resource/user/following.rb +13 -0
- data/lib/tinybucket/resource/user/repos.rb +13 -0
- data/lib/tinybucket/resource/watchers.rb +22 -0
- data/lib/tinybucket/version.rb +1 -1
- data/spec/fixtures/build_status.json +16 -0
- data/spec/fixtures/repositories/test_owner/get.json +1 -1
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/post.json +16 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json +16 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json +16 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +1 -1
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +1 -1
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +1 -1
- data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +1 -1
- data/spec/lib/tinybucket/api/build_status_api_spec.rb +65 -0
- data/spec/lib/tinybucket/client_spec.rb +8 -4
- data/spec/lib/tinybucket/model/build_status_spec.rb +66 -0
- data/spec/lib/tinybucket/model/commit_spec.rb +19 -1
- data/spec/lib/tinybucket/model/profile_spec.rb +3 -3
- data/spec/lib/tinybucket/model/pull_request_spec.rb +3 -15
- data/spec/lib/tinybucket/model/repository_spec.rb +14 -20
- data/spec/lib/tinybucket/model/team_spec.rb +16 -4
- data/spec/lib/tinybucket/resource/branch_restrictions_spec.rb +60 -0
- data/spec/lib/tinybucket/resource/commit/build_statuses_spec.rb +50 -0
- data/spec/lib/tinybucket/resource/commit/comments_spec.rb +49 -0
- data/spec/lib/tinybucket/resource/commits_spec.rb +43 -0
- data/spec/lib/tinybucket/resource/forks_spec.rb +36 -0
- data/spec/lib/tinybucket/resource/pull_request/comments_spec.rb +41 -0
- data/spec/lib/tinybucket/resource/pull_request/commits_spec.rb +41 -0
- data/spec/lib/tinybucket/resource/pull_requests_spec.rb +59 -0
- data/spec/lib/tinybucket/resource/repos_spec.rb +76 -0
- data/spec/lib/tinybucket/resource/team/followers_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/team/following_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/team/members_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/team/repos_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/user/followers_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/user/following_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/user/repos_spec.rb +27 -0
- data/spec/lib/tinybucket/resource/watchers_spec.rb +38 -0
- data/spec/support/api_response_macros.rb +45 -1
- metadata +77 -3
@@ -0,0 +1,17 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
module PullRequest
|
4
|
+
class Commits < Tinybucket::Resource::PullRequest::Base
|
5
|
+
private
|
6
|
+
|
7
|
+
def enumerator
|
8
|
+
params = [@pull_request.id].concat(@args)
|
9
|
+
|
10
|
+
create_enumerator(pull_request_api, :commits, *params) do |m|
|
11
|
+
inject_repo_keys(m, @pull_request.repo_keys)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
class PullRequests < Base
|
4
|
+
def initialize(repo, options)
|
5
|
+
@repo = repo
|
6
|
+
@args = [options]
|
7
|
+
end
|
8
|
+
|
9
|
+
# Create a new pull request.
|
10
|
+
#
|
11
|
+
# @todo to be implemented.
|
12
|
+
# @raise [NotImplementedError] to be implemented.
|
13
|
+
def create(_options)
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the specific pull request on the repository.
|
18
|
+
#
|
19
|
+
# @param pullrequest_id [String]
|
20
|
+
# @param options [Hash]
|
21
|
+
# @return [Tinybucket::Model::PullRequest]
|
22
|
+
def find(pullrequest_id, options = {})
|
23
|
+
pull_requests_api.find(pullrequest_id, options).tap do |m|
|
24
|
+
inject_repo_keys(m, @repo.repo_keys)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get activities on the po
|
29
|
+
#
|
30
|
+
# TODO: To be implemented.
|
31
|
+
def activities(_options)
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def pull_requests_api
|
38
|
+
create_api('PullRequests', @repo.repo_keys)
|
39
|
+
end
|
40
|
+
|
41
|
+
def enumerator
|
42
|
+
create_enumerator(pull_requests_api, :list, *@args) do |m|
|
43
|
+
inject_repo_keys(m, @repo.repo_keys)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
class Repos < Base
|
4
|
+
def initialize(owner, options)
|
5
|
+
@owner = owner
|
6
|
+
@args = [options]
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(_options)
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(_options)
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def user_api
|
20
|
+
create_api('User').tap do |api|
|
21
|
+
api.username = @owner
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def repos_api
|
26
|
+
create_api('Repos')
|
27
|
+
end
|
28
|
+
|
29
|
+
def enumerator
|
30
|
+
if @owner
|
31
|
+
create_enumerator(user_api, :repos, *@args)
|
32
|
+
else
|
33
|
+
create_enumerator(repos_api, :list, *@args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
module Team
|
4
|
+
class Base < Tinybucket::Resource::Base
|
5
|
+
def initialize(team_name, options)
|
6
|
+
@team_name = team_name
|
7
|
+
@args = [options]
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def team_api
|
13
|
+
create_api('Team')
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_team_enumerator(method)
|
17
|
+
create_enumerator(team_api, method, @team_name, *@args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
module User
|
4
|
+
class Base < Tinybucket::Resource::Base
|
5
|
+
def initialize(user_name, options)
|
6
|
+
@user_name = user_name
|
7
|
+
@args = [options]
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def user_api
|
13
|
+
create_api('User').tap do |api|
|
14
|
+
api.username = @user_name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_user_enumerator(method)
|
19
|
+
create_enumerator(user_api, method, *@args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tinybucket
|
2
|
+
module Resource
|
3
|
+
class Watchers < Base
|
4
|
+
def initialize(repo, options)
|
5
|
+
@repo = repo
|
6
|
+
@args = [options]
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def repo_api
|
12
|
+
create_api('Repo', @repo.repo_keys)
|
13
|
+
end
|
14
|
+
|
15
|
+
def enumerator
|
16
|
+
create_enumerator(repo_api, :watchers, *@args) do |m|
|
17
|
+
inject_repo_keys(m, @repo.repo_keys)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/tinybucket/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"state": "SUCCESSFUL",
|
3
|
+
"type": "build",
|
4
|
+
"key": "test_status",
|
5
|
+
"name": "Build #34",
|
6
|
+
"url": "https://example.com/path/to/build",
|
7
|
+
"description": "Changes by John Doe",
|
8
|
+
"links": {
|
9
|
+
"self": {
|
10
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466/statuses/build/BAMBOO-PROJECT-X"
|
11
|
+
},
|
12
|
+
"commit": {
|
13
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -74,5 +74,5 @@
|
|
74
74
|
}
|
75
75
|
],
|
76
76
|
"page": 1,
|
77
|
-
"next": "https://api.bitbucket.org/2.0/repositories?pagelen=1&after=2013-09-26T23%3A01%3A01.638828%2B00%3A00&page=2"
|
77
|
+
"next": "https://api.bitbucket.org/2.0/repositories/test_owner?pagelen=1&after=2013-09-26T23%3A01%3A01.638828%2B00%3A00&page=2"
|
78
78
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"state": "SUCCESSFUL",
|
3
|
+
"type": "build",
|
4
|
+
"key": "BAMBOO-PROJECT-X",
|
5
|
+
"name": "Build #34",
|
6
|
+
"url": "https://example.com/path/to/build",
|
7
|
+
"description": "Changes by John Doe",
|
8
|
+
"links": {
|
9
|
+
"self": {
|
10
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466/statuses/build/BAMBOO-PROJECT-X"
|
11
|
+
},
|
12
|
+
"commit": {
|
13
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"state": "SUCCESSFUL",
|
3
|
+
"type": "build",
|
4
|
+
"key": "BAMBOO-PROJECT-X",
|
5
|
+
"name": "Build #34",
|
6
|
+
"url": "https://example.com/path/to/build",
|
7
|
+
"description": "Changes by John Doe",
|
8
|
+
"links": {
|
9
|
+
"self": {
|
10
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466/statuses/build/BAMBOO-PROJECT-X"
|
11
|
+
},
|
12
|
+
"commit": {
|
13
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"state": "SUCCESSFUL",
|
3
|
+
"type": "build",
|
4
|
+
"key": "BAMBOO-PROJECT-X",
|
5
|
+
"name": "Build #34",
|
6
|
+
"url": "https://example.com/path/to/build",
|
7
|
+
"description": "Changes by John Doe",
|
8
|
+
"links": {
|
9
|
+
"self": {
|
10
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466/statuses/build/BAMBOO-PROJECT-X"
|
11
|
+
},
|
12
|
+
"commit": {
|
13
|
+
"href": "https://api.bitbucket.org/2.0/repositories/emmap1/MyRepo/commits/61d9e64348f9da407e62f64726337fd3bb24b466"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"pagelen": 1,
|
3
|
-
"next": "https://api.bitbucket.org/2.0/repositories/
|
3
|
+
"next": "https://api.bitbucket.org/2.0/repositories/test_owner/test_repo/pullrequests/1/comments?pagelen=1&page=2",
|
4
4
|
"values": [{
|
5
5
|
"parent": {
|
6
6
|
"id": 25334,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"pagelen": 1,
|
3
|
-
"next": "https://api.bitbucket.org/2.0/repositories/
|
3
|
+
"next": "https://api.bitbucket.org/2.0/repositories/test_owner/test_repo/pullrequests/1/commits?pagelen=1&page=2",
|
4
4
|
"values": [{
|
5
5
|
"hash": "ad758aeba36fa4b9d258ac1667f55cfb811e6df3",
|
6
6
|
"links": {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"pagelen": 1,
|
3
|
-
"next": "https://api.bitbucket.org/2.0/repositories/
|
3
|
+
"next": "https://api.bitbucket.org/2.0/repositories/test_owner/test_repo/pullrequests?pagelen=1&page=2",
|
4
4
|
"values": [{
|
5
5
|
"description": "![img](https://cloudup.com/c7ZJtChLw9J+)\r\n\r\n## Removing:\r\n\r\n* Notifications\r\n* Email\r\n* Change password\r\n* Sessions\r\n\r\n## Renaming: \r\n\r\n* Change username\r\n* Delete account (rename to delete team)\r\n\r\n",
|
6
6
|
"links": {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"pagelen": 2,
|
3
|
-
"next": "https://api.bitbucket.org/2.0/repositories/
|
3
|
+
"next": "https://api.bitbucket.org/2.0/repositories/test_owner/test_repo/watchers?pagelen=2&page=2",
|
4
4
|
"values": [
|
5
5
|
{
|
6
6
|
"username": "tutorials",
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::Api::BuildStatusApi do
|
4
|
+
include ApiResponseMacros
|
5
|
+
|
6
|
+
let(:owner) { 'test_owner' }
|
7
|
+
let(:slug) { 'test_repo' }
|
8
|
+
let(:revision) { '1' }
|
9
|
+
let(:status_key) { 'test_status' }
|
10
|
+
let(:options) { {} }
|
11
|
+
|
12
|
+
let(:api) do
|
13
|
+
Tinybucket::Api::BuildStatusApi.new.tap do |api|
|
14
|
+
api.repo_owner = owner
|
15
|
+
api.repo_slug = slug
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
20
|
+
|
21
|
+
describe '#find' do
|
22
|
+
let(:request_path) do
|
23
|
+
"/repositories/#{owner}/#{slug}/commit/#{revision}/statuses/build/#{status_key}"
|
24
|
+
end
|
25
|
+
subject { api.find(revision, status_key) }
|
26
|
+
before { stub_apiresponse(:get, request_path) }
|
27
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::BuildStatus) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#post' do
|
31
|
+
let(:request_path) do
|
32
|
+
"/repositories/#{owner}/#{slug}/commit/#{revision}/statuses/build"
|
33
|
+
end
|
34
|
+
let(:params) do
|
35
|
+
{
|
36
|
+
state: 'INPROGRESS',
|
37
|
+
name: 'test_repo test #10',
|
38
|
+
url: 'https://example.com/path/to/build/info',
|
39
|
+
description: 'Changes by test_owner'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
subject { api.post(revision, status_key, params) }
|
44
|
+
before { stub_apiresponse(:post, request_path) }
|
45
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::BuildStatus) }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#put' do
|
49
|
+
let(:request_path) do
|
50
|
+
"/repositories/#{owner}/#{slug}/commit/#{revision}/statuses/build/#{status_key}"
|
51
|
+
end
|
52
|
+
let(:params) do
|
53
|
+
{
|
54
|
+
state: 'SUCCESSFUL',
|
55
|
+
name: 'test_repo test #10',
|
56
|
+
url: 'https://example.com/path/to/build/info',
|
57
|
+
description: 'Changes by test_owner'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
subject { api.put(revision, status_key, params) }
|
62
|
+
before { stub_apiresponse(:put, request_path) }
|
63
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::BuildStatus) }
|
64
|
+
end
|
65
|
+
end
|