tinybucket 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed12324002ab5952c612faf543af7d705047ed6c
4
- data.tar.gz: db4392d5bbb95d6e40169ca48742baaa9051d8cd
3
+ metadata.gz: b4003b1b649423a198a6b8f676c62c7ca5d67a2f
4
+ data.tar.gz: 843f94ec752774731ccd9ce103a6c2ebe7aec049
5
5
  SHA512:
6
- metadata.gz: 6ecc10dd11258c440125c0c302540ce6aec02024a00e19d0d82216afc65c5a73048d0bc7c7474f339e7c0b0b4d512785a59aac3998ceef55d3cc1507c7b0dff0
7
- data.tar.gz: 72b1d6d150ce83c0b804264159fa37de12d7ab76992ceae6be809f2a80147ba700a62cffd151e51e2098bfee5f5f1a22dcab6b2ea064e84c1eeae980b3713bed
6
+ metadata.gz: ce3b46142b36346ffdde5b61b99d2a1359c140e7e982ce38ab311141d7b6e2a8c94107cb9fc1cd801b9b44018e732d58c117f4640fd7039c3a8babb05cfe7ec8
7
+ data.tar.gz: 5c675ff9e9edee793f11e37b1f9562ae0c6f56144ba136e7d929d6ce59e9339c49b6d7b5665c3881ebf04fe7321a5c64fc9bfb6fe92ac282eab2433fe83bcd04
@@ -12,6 +12,7 @@ module Tinybucket
12
12
  :CommitsApi,
13
13
  :CommentsApi,
14
14
  :DiffApi,
15
+ :ProjectsApi,
15
16
  :PullRequestsApi,
16
17
  :ReposApi,
17
18
  :RepoApi,
@@ -16,6 +16,7 @@ module Tinybucket
16
16
  :ReposHelper,
17
17
  :RepoHelper,
18
18
  :PullRequestsHelper,
19
+ :ProjectsHelper,
19
20
  :TeamHelper,
20
21
  :UserHelper
21
22
  ].each do |klass_name|
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Api
5
+ module Helper
6
+ module ProjectsHelper
7
+ include ::Tinybucket::Api::Helper::ApiHelper
8
+
9
+ private
10
+
11
+ def path_to_list(owner)
12
+ base_path(owner)
13
+ end
14
+
15
+ def path_to_find(owner, project_key)
16
+ build_path(base_path(owner),
17
+ [project_key, 'project_key'])
18
+ end
19
+
20
+ def base_path(owner)
21
+ build_path('/teams',
22
+ [owner, 'owner'],
23
+ 'projects',
24
+ '/')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -8,28 +8,36 @@ module Tinybucket
8
8
 
9
9
  private
10
10
 
11
+ def path_to_list
12
+ base_path
13
+ end
14
+
11
15
  def path_to_find(name)
12
- base_path(name)
16
+ team_path(name)
13
17
  end
14
18
 
15
19
  def path_to_members(name)
16
- build_path(base_path(name), 'members')
20
+ build_path(team_path(name), 'members')
17
21
  end
18
22
 
19
23
  def path_to_followers(name)
20
- build_path(base_path(name), 'followers')
24
+ build_path(team_path(name), 'followers')
21
25
  end
22
26
 
23
27
  def path_to_following(name)
24
- build_path(base_path(name), 'following')
28
+ build_path(team_path(name), 'following')
25
29
  end
26
30
 
27
31
  def path_to_repos(name)
28
- build_path(base_path(name), 'repositories')
32
+ build_path(team_path(name), 'repositories')
33
+ end
34
+
35
+ def base_path
36
+ build_path('/teams')
29
37
  end
30
38
 
31
- def base_path(name)
32
- build_path('/teams', [name, 'teamname'])
39
+ def team_path(name)
40
+ build_path(base_path, [name, 'teamname'])
33
41
  end
34
42
  end
35
43
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Api
5
+ class ProjectsApi < BaseApi
6
+ include Tinybucket::Api::Helper::ProjectsHelper
7
+ attr_accessor :owner
8
+
9
+ def list(options = {})
10
+ get_path(
11
+ path_to_list(owner),
12
+ options,
13
+ Tinybucket::Parser::ProjectsParser
14
+ )
15
+ end
16
+
17
+ def find(project_key, options = {})
18
+ get_path(
19
+ path_to_find(owner, project_key),
20
+ options,
21
+ Tinybucket::Parser::ProjectParser
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -9,6 +9,19 @@ module Tinybucket
9
9
  class TeamApi < BaseApi
10
10
  include Tinybucket::Api::Helper::TeamHelper
11
11
 
12
+ # Send 'GET teams' request
13
+ #
14
+ # @param role_name [String] role name
15
+ # @param options [Hash]
16
+ # @return [Tinybucket::Model::Page]
17
+ def list(role_name, options = {})
18
+ get_path(
19
+ path_to_list,
20
+ { role: role_name }.merge(options),
21
+ Tinybucket::Parser::TeamsParser
22
+ )
23
+ end
24
+
12
25
  # Send 'GET the team profile' request
13
26
  #
14
27
  # @param name [String] The team's name
@@ -52,6 +52,15 @@ module Tinybucket
52
52
  end
53
53
  end
54
54
 
55
+ # Get teams
56
+ #
57
+ # @param role_name [String] role name (one of "admin", "contributor", or "member")
58
+ # @param options
59
+ # @return [Tinybucket::Resource::Teams]
60
+ def teams(role_name, options = {})
61
+ Tinybucket::Resource::Teams.new(role_name, options)
62
+ end
63
+
55
64
  # Get the team
56
65
  #
57
66
  # @param teamname [String] the team name.
@@ -14,6 +14,7 @@ module Tinybucket
14
14
  :ErrorResponse,
15
15
  :Page,
16
16
  :Profile,
17
+ :Project,
17
18
  :PullRequest,
18
19
  :Repository,
19
20
  :Team
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Model
5
+ class Project < Base
6
+ acceptable_attributes \
7
+ :type, :description, :links, :uuid, :created_on,
8
+ :key, :updated_on, :is_private, :name, :owner
9
+
10
+ # Update this project
11
+ #
12
+ # @param _params [Hash]
13
+ # @raise [NotImplementedError] to be implemented
14
+ def update(_params)
15
+ raise NotImplementedError
16
+ end
17
+
18
+ # Destroy this project
19
+ #
20
+ # @raise [NotImplementedError] to be implemented.
21
+ def destroy
22
+ raise NotImplementedError
23
+ end
24
+
25
+ # Get repositories
26
+ #
27
+ # @return [Tinybucket::Resource::Repos]
28
+ def repos
29
+ repos_resource
30
+ end
31
+
32
+ private
33
+
34
+ def owner_name
35
+ raise 'This project is not loaded yet.' if (owner.nil? || owner['username'].nil?)
36
+ owner['username']
37
+ end
38
+
39
+ def repos_resource
40
+ Tinybucket::Resource::Repos.new(owner_name, q: %(project.key="#{key}"))
41
+ end
42
+ end
43
+ end
44
+ end
@@ -54,6 +54,22 @@ module Tinybucket
54
54
  Tinybucket::Resource::Team::Following.new(username, options)
55
55
  end
56
56
 
57
+ # Get projects
58
+ #
59
+ # @param options [Hash]
60
+ # @return [Tinybucket::Resource::Team::Project]
61
+ def projects(options = {})
62
+ projects_resource(options)
63
+ end
64
+
65
+ # Get the project
66
+ #
67
+ # @param project_key [String]
68
+ # @return [Tinybucket::Model::Project]
69
+ def project(project_key, options = {})
70
+ projects_resource().find(project_key, options)
71
+ end
72
+
57
73
  # Get this team's repositories.
58
74
  #
59
75
  # @param options [Hash]
@@ -64,6 +80,10 @@ module Tinybucket
64
80
 
65
81
  private
66
82
 
83
+ def projects_resource(options = {})
84
+ Tinybucket::Resource::Projects.new(username, options)
85
+ end
86
+
67
87
  def team_api
68
88
  create_api('Team')
69
89
  end
@@ -18,6 +18,8 @@ module Tinybucket
18
18
  :CommentsParser,
19
19
  :ProfileParser,
20
20
  :ProfilesParser,
21
+ :ProjectParser,
22
+ :ProjectsParser,
21
23
  :PullRequestParser,
22
24
  :PullRequestsParser,
23
25
  :RepoParser,
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Parser
5
+ class ProjectParser < BaseParser
6
+ def convert(json)
7
+ Tinybucket::Model::Project.new(json)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tinybucket
4
+ module Parser
5
+ class ProjectsParser < BaseParser
6
+ def convert(json)
7
+ Tinybucket::Model::Page.new(json, Tinybucket::Model::Project)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -11,9 +11,11 @@ module Tinybucket
11
11
  :Commits,
12
12
  :Forks,
13
13
  :OwnersRepos,
14
+ :Projects,
14
15
  :PublicRepos,
15
16
  :PullRequests,
16
17
  :Repos,
18
+ :Teams,
17
19
  :Watchers
18
20
  ].each do |klass_name|
19
21
  autoload klass_name
@@ -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,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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tinybucket
4
- VERSION = '1.4.0'.freeze
4
+ VERSION = '1.5.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinybucket
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirakiuc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -138,11 +138,13 @@ files:
138
138
  - lib/tinybucket/api/helper/comments_helper.rb
139
139
  - lib/tinybucket/api/helper/commits_helper.rb
140
140
  - lib/tinybucket/api/helper/diff_helper.rb
141
+ - lib/tinybucket/api/helper/projects_helper.rb
141
142
  - lib/tinybucket/api/helper/pull_requests_helper.rb
142
143
  - lib/tinybucket/api/helper/repo_helper.rb
143
144
  - lib/tinybucket/api/helper/repos_helper.rb
144
145
  - lib/tinybucket/api/helper/team_helper.rb
145
146
  - lib/tinybucket/api/helper/user_helper.rb
147
+ - lib/tinybucket/api/projects_api.rb
146
148
  - lib/tinybucket/api/pull_requests_api.rb
147
149
  - lib/tinybucket/api/repo_api.rb
148
150
  - lib/tinybucket/api/repos_api.rb
@@ -176,6 +178,7 @@ files:
176
178
  - lib/tinybucket/model/error_response.rb
177
179
  - lib/tinybucket/model/page.rb
178
180
  - lib/tinybucket/model/profile.rb
181
+ - lib/tinybucket/model/project.rb
179
182
  - lib/tinybucket/model/pull_request.rb
180
183
  - lib/tinybucket/model/repository.rb
181
184
  - lib/tinybucket/model/team.rb
@@ -194,6 +197,8 @@ files:
194
197
  - lib/tinybucket/parser/commits_parser.rb
195
198
  - lib/tinybucket/parser/profile_parser.rb
196
199
  - lib/tinybucket/parser/profiles_parser.rb
200
+ - lib/tinybucket/parser/project_parser.rb
201
+ - lib/tinybucket/parser/projects_parser.rb
197
202
  - lib/tinybucket/parser/pull_request_parser.rb
198
203
  - lib/tinybucket/parser/pull_requests_parser.rb
199
204
  - lib/tinybucket/parser/repo_parser.rb
@@ -210,6 +215,7 @@ files:
210
215
  - lib/tinybucket/resource/commit/comments.rb
211
216
  - lib/tinybucket/resource/commits.rb
212
217
  - lib/tinybucket/resource/forks.rb
218
+ - lib/tinybucket/resource/projects.rb
213
219
  - lib/tinybucket/resource/pull_request/base.rb
214
220
  - lib/tinybucket/resource/pull_request/comments.rb
215
221
  - lib/tinybucket/resource/pull_request/commits.rb
@@ -220,6 +226,7 @@ files:
220
226
  - lib/tinybucket/resource/team/following.rb
221
227
  - lib/tinybucket/resource/team/members.rb
222
228
  - lib/tinybucket/resource/team/repos.rb
229
+ - lib/tinybucket/resource/teams.rb
223
230
  - lib/tinybucket/resource/user/base.rb
224
231
  - lib/tinybucket/resource/user/followers.rb
225
232
  - lib/tinybucket/resource/user/following.rb