tinybucket2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +86 -0
- data/Gemfile +32 -0
- data/LICENSE +21 -0
- data/README.md +387 -0
- data/Rakefile +47 -0
- data/lib/faraday_middleware/follow_oauth_redirects.rb +71 -0
- data/lib/tinybucket.rb +76 -0
- data/lib/tinybucket/api.rb +26 -0
- data/lib/tinybucket/api/base_api.rb +44 -0
- data/lib/tinybucket/api/branch_restrictions_api.rb +51 -0
- data/lib/tinybucket/api/branches_api.rb +48 -0
- data/lib/tinybucket/api/build_status_api.rb +69 -0
- data/lib/tinybucket/api/comments_api.rb +81 -0
- data/lib/tinybucket/api/commits_api.rb +97 -0
- data/lib/tinybucket/api/diff_api.rb +40 -0
- data/lib/tinybucket/api/helper.rb +27 -0
- data/lib/tinybucket/api/helper/api_helper.rb +39 -0
- data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +29 -0
- data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
- data/lib/tinybucket/api/helper/build_status_helper.rb +46 -0
- data/lib/tinybucket/api/helper/comments_helper.rb +51 -0
- data/lib/tinybucket/api/helper/commits_helper.rb +42 -0
- data/lib/tinybucket/api/helper/diff_helper.rb +31 -0
- data/lib/tinybucket/api/helper/issues_helper.rb +29 -0
- data/lib/tinybucket/api/helper/projects_helper.rb +28 -0
- data/lib/tinybucket/api/helper/pull_requests_helper.rb +58 -0
- data/lib/tinybucket/api/helper/repo_helper.rb +31 -0
- data/lib/tinybucket/api/helper/repos_helper.rb +23 -0
- data/lib/tinybucket/api/helper/team_helper.rb +45 -0
- data/lib/tinybucket/api/helper/user_helper.rb +33 -0
- data/lib/tinybucket/api/issues_api.rb +48 -0
- data/lib/tinybucket/api/projects_api.rb +26 -0
- data/lib/tinybucket/api/pull_requests_api.rb +117 -0
- data/lib/tinybucket/api/repo_api.rb +56 -0
- data/lib/tinybucket/api/repos_api.rb +28 -0
- data/lib/tinybucket/api/team_api.rb +91 -0
- data/lib/tinybucket/api/user_api.rb +66 -0
- data/lib/tinybucket/api_factory.rb +21 -0
- data/lib/tinybucket/client.rb +107 -0
- data/lib/tinybucket/config.rb +10 -0
- data/lib/tinybucket/connection.rb +84 -0
- data/lib/tinybucket/constants.rb +7 -0
- data/lib/tinybucket/enumerator.rb +47 -0
- data/lib/tinybucket/error.rb +12 -0
- data/lib/tinybucket/error/base_error.rb +14 -0
- data/lib/tinybucket/error/conflict.rb +8 -0
- data/lib/tinybucket/error/not_found.rb +8 -0
- data/lib/tinybucket/error/service_error.rb +26 -0
- data/lib/tinybucket/iterator.rb +79 -0
- data/lib/tinybucket/model.rb +25 -0
- data/lib/tinybucket/model/base.rb +45 -0
- data/lib/tinybucket/model/branch.rb +48 -0
- data/lib/tinybucket/model/branch_restriction.rb +46 -0
- data/lib/tinybucket/model/build_status.rb +57 -0
- data/lib/tinybucket/model/comment.rb +67 -0
- data/lib/tinybucket/model/commit.rb +114 -0
- data/lib/tinybucket/model/concerns.rb +19 -0
- data/lib/tinybucket/model/concerns/acceptable_attributes.rb +34 -0
- data/lib/tinybucket/model/concerns/api_callable.rb +21 -0
- data/lib/tinybucket/model/concerns/enumerable.rb +20 -0
- data/lib/tinybucket/model/concerns/reloadable.rb +41 -0
- data/lib/tinybucket/model/concerns/repository_keys.rb +45 -0
- data/lib/tinybucket/model/error_response.rb +24 -0
- data/lib/tinybucket/model/issue.rb +48 -0
- data/lib/tinybucket/model/page.rb +45 -0
- data/lib/tinybucket/model/profile.rb +70 -0
- data/lib/tinybucket/model/project.rb +44 -0
- data/lib/tinybucket/model/pull_request.rb +160 -0
- data/lib/tinybucket/model/repository.rb +219 -0
- data/lib/tinybucket/model/team.rb +96 -0
- data/lib/tinybucket/null_logger.rb +37 -0
- data/lib/tinybucket/parser.rb +15 -0
- data/lib/tinybucket/parser/collection_parser.rb +17 -0
- data/lib/tinybucket/parser/object_parser.rb +17 -0
- data/lib/tinybucket/request.rb +59 -0
- data/lib/tinybucket/resource.rb +75 -0
- data/lib/tinybucket/resource/base.rb +35 -0
- data/lib/tinybucket/resource/branch_restrictions.rb +47 -0
- data/lib/tinybucket/resource/branches.rb +35 -0
- data/lib/tinybucket/resource/commit/base.rb +14 -0
- data/lib/tinybucket/resource/commit/build_statuses.rb +50 -0
- data/lib/tinybucket/resource/commit/comments.rb +34 -0
- data/lib/tinybucket/resource/commits.rb +46 -0
- data/lib/tinybucket/resource/forks.rb +24 -0
- data/lib/tinybucket/resource/issues.rb +35 -0
- data/lib/tinybucket/resource/projects.rb +49 -0
- data/lib/tinybucket/resource/pull_request/base.rb +20 -0
- data/lib/tinybucket/resource/pull_request/comments.rb +32 -0
- data/lib/tinybucket/resource/pull_request/commits.rb +19 -0
- data/lib/tinybucket/resource/pull_requests.rb +50 -0
- data/lib/tinybucket/resource/repos.rb +40 -0
- data/lib/tinybucket/resource/team/base.rb +24 -0
- data/lib/tinybucket/resource/team/followers.rb +15 -0
- data/lib/tinybucket/resource/team/following.rb +15 -0
- data/lib/tinybucket/resource/team/members.rb +15 -0
- data/lib/tinybucket/resource/team/repos.rb +15 -0
- data/lib/tinybucket/resource/teams.rb +22 -0
- data/lib/tinybucket/resource/user/base.rb +26 -0
- data/lib/tinybucket/resource/user/followers.rb +15 -0
- data/lib/tinybucket/resource/user/following.rb +15 -0
- data/lib/tinybucket/resource/user/repos.rb +15 -0
- data/lib/tinybucket/resource/watchers.rb +24 -0
- data/lib/tinybucket/response.rb +9 -0
- data/lib/tinybucket/response/handler.rb +23 -0
- data/lib/tinybucket/version.rb +5 -0
- data/tinybucket.gemspec +30 -0
- metadata +248 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Commits < Base
|
6
|
+
def initialize(repo, options)
|
7
|
+
@repo = repo
|
8
|
+
@args = [options]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Find the commit
|
12
|
+
#
|
13
|
+
# @param revision [String]
|
14
|
+
# @param options [Hash]
|
15
|
+
# @return [Tinybucket::Model::Commit]
|
16
|
+
def find(revision, options = {})
|
17
|
+
commits_api.find(revision, options).tap do |m|
|
18
|
+
inject_repo_keys(m, @repo.repo_keys)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the commits for a specific branch
|
23
|
+
#
|
24
|
+
# @param name [String]
|
25
|
+
# @param options [Hash]
|
26
|
+
# @return [Tinybucket::Iterator]
|
27
|
+
def branch(name, options = {})
|
28
|
+
create_enumerator(commits_api, :branch, name, options) do |m|
|
29
|
+
inject_repo_keys(m, @repo.repo_keys)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def commits_api
|
36
|
+
create_api('Commits', @repo.repo_keys)
|
37
|
+
end
|
38
|
+
|
39
|
+
def enumerator
|
40
|
+
create_enumerator(commits_api, :list, *@args) do |m|
|
41
|
+
inject_repo_keys(m, @repo.repo_keys)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Forks < 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, :forks, *@args) do |m|
|
19
|
+
inject_repo_keys(m, @repo.repo_keys)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Issues < Tinybucket::Resource::Base
|
6
|
+
def initialize(repo, options)
|
7
|
+
@repo = repo
|
8
|
+
@args = [options]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Find the branch
|
12
|
+
#
|
13
|
+
# @param branch [String]
|
14
|
+
# @param options [Hash]
|
15
|
+
# @return [Tinybucket::Model::Branch]
|
16
|
+
def find(branch, options = {})
|
17
|
+
issues_api.find(branch, options).tap do |m|
|
18
|
+
inject_repo_keys(m, @repo.repo_keys)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def issues_api
|
25
|
+
create_api('Issues', @repo.repo_keys)
|
26
|
+
end
|
27
|
+
|
28
|
+
def enumerator
|
29
|
+
create_enumerator(issues_api, :list, *@args) do |m|
|
30
|
+
inject_repo_keys(m, @repo.repo_keys)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Projects < Base
|
6
|
+
attr_accessor :owner
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
#
|
10
|
+
# @param owner_name [String]
|
11
|
+
# @param options [Hash]
|
12
|
+
def initialize(owner_name, options = {})
|
13
|
+
@owner = owner_name
|
14
|
+
@args = [options]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Find the project
|
18
|
+
#
|
19
|
+
# @param project_key [String]
|
20
|
+
# @param options [Hash]
|
21
|
+
# @return [Tinybucket::Model::Project]
|
22
|
+
def find(project_key, options = {})
|
23
|
+
projects_api.find(project_key, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a new project
|
27
|
+
#
|
28
|
+
# NOTE: Not Implemented yet.
|
29
|
+
#
|
30
|
+
# @param _params [Hash]
|
31
|
+
# @raise [NotImplementedError] to be implemented
|
32
|
+
def create(_params)
|
33
|
+
raise NotImplementedError
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def projects_api
|
39
|
+
create_api('Projects').tap do |api|
|
40
|
+
api.owner = @owner
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def enumerator
|
45
|
+
create_enumerator(projects_api, :list, *@args)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
module PullRequest
|
6
|
+
class Base < Tinybucket::Resource::Base
|
7
|
+
def initialize(pull_request, options)
|
8
|
+
@pull_request = pull_request
|
9
|
+
@args = [options]
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def pull_request_api
|
15
|
+
create_api('PullRequests', @pull_request.repo_keys)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
module PullRequest
|
6
|
+
class Comments < Tinybucket::Resource::PullRequest::Base
|
7
|
+
# Get the specific comment on the pull request.
|
8
|
+
#
|
9
|
+
# @param comment_id [String]
|
10
|
+
# @param options [Hash]
|
11
|
+
# @return [Tinybucket::Model::Comment]
|
12
|
+
def find(comment_id, options)
|
13
|
+
comment_api.find(comment_id, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def comment_api
|
19
|
+
create_api('Comments', @pull_request.repo_keys).tap do |api|
|
20
|
+
api.commented_to = @pull_request
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def enumerator
|
25
|
+
create_enumerator(comment_api, :list, *@args) do |m|
|
26
|
+
inject_repo_keys(m, @pull_request.repo_keys)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
module PullRequest
|
6
|
+
class Commits < Tinybucket::Resource::PullRequest::Base
|
7
|
+
private
|
8
|
+
|
9
|
+
def enumerator
|
10
|
+
params = [@pull_request.id].concat(@args)
|
11
|
+
|
12
|
+
create_enumerator(pull_request_api, :commits, *params) do |m|
|
13
|
+
inject_repo_keys(m, @pull_request.repo_keys)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class PullRequests < Base
|
6
|
+
def initialize(repo, options)
|
7
|
+
@repo = repo
|
8
|
+
@args = [options]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Create a new pull request.
|
12
|
+
#
|
13
|
+
# @todo to be implemented.
|
14
|
+
# @raise [NotImplementedError] to be implemented.
|
15
|
+
def create(_options)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get the specific pull request on the repository.
|
20
|
+
#
|
21
|
+
# @param pullrequest_id [String]
|
22
|
+
# @param options [Hash]
|
23
|
+
# @return [Tinybucket::Model::PullRequest]
|
24
|
+
def find(pullrequest_id, options = {})
|
25
|
+
pull_requests_api.find(pullrequest_id, options).tap do |m|
|
26
|
+
inject_repo_keys(m, @repo.repo_keys)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get activities on the po
|
31
|
+
#
|
32
|
+
# TODO: To be implemented.
|
33
|
+
def activities(_options)
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def pull_requests_api
|
40
|
+
create_api('PullRequests', @repo.repo_keys)
|
41
|
+
end
|
42
|
+
|
43
|
+
def enumerator
|
44
|
+
create_enumerator(pull_requests_api, :list, *@args) do |m|
|
45
|
+
inject_repo_keys(m, @repo.repo_keys)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Repos < Base
|
6
|
+
def initialize(owner, options)
|
7
|
+
@owner = owner
|
8
|
+
@args = [options]
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(_options)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(_options)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def user_api
|
22
|
+
create_api('User').tap do |api|
|
23
|
+
api.username = @owner
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def repos_api
|
28
|
+
create_api('Repos')
|
29
|
+
end
|
30
|
+
|
31
|
+
def enumerator
|
32
|
+
if @owner
|
33
|
+
create_enumerator(user_api, :repos, *@args)
|
34
|
+
else
|
35
|
+
create_enumerator(repos_api, :list, *@args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
module Team
|
6
|
+
class Base < Tinybucket::Resource::Base
|
7
|
+
def initialize(team_name, options)
|
8
|
+
@team_name = team_name
|
9
|
+
@args = [options]
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def team_api
|
15
|
+
create_api('Team')
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_team_enumerator(method)
|
19
|
+
create_enumerator(team_api, method, @team_name, *@args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tinybucket
|
4
|
+
module Resource
|
5
|
+
class Teams < Base
|
6
|
+
def initialize(role_name, options = {})
|
7
|
+
@role_name = role_name
|
8
|
+
@args = [options]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def teams_api
|
14
|
+
create_api('Team')
|
15
|
+
end
|
16
|
+
|
17
|
+
def enumerator
|
18
|
+
create_enumerator(teams_api, :list, @role_name, *@args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|