audc-gerry 0.1.6 → 0.1.8

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -62
  3. data/Rakefile +7 -7
  4. data/lib/gerry/api/access.rb +17 -17
  5. data/lib/gerry/api/accounts.rb +38 -38
  6. data/lib/gerry/api/branches.rb +45 -45
  7. data/lib/gerry/api/changes.rb +38 -38
  8. data/lib/gerry/api/groups.rb +72 -72
  9. data/lib/gerry/api/projects.rb +73 -73
  10. data/lib/gerry/api/request.rb +86 -86
  11. data/lib/gerry/client.rb +58 -58
  12. data/lib/gerry/version.rb +5 -5
  13. data/lib/gerry.rb +11 -11
  14. data/spec/access_spec.rb +15 -15
  15. data/spec/accounts_spec.rb +35 -35
  16. data/spec/branches_spec.rb +36 -36
  17. data/spec/changes_spec.rb +55 -55
  18. data/spec/fixtures/README.md.json +2 -2
  19. data/spec/fixtures/access_rights.json +250 -250
  20. data/spec/fixtures/account_groups.json +32 -32
  21. data/spec/fixtures/branch_access.json +50 -50
  22. data/spec/fixtures/capabilities.json +7 -7
  23. data/spec/fixtures/changes.json +30 -30
  24. data/spec/fixtures/changes_batch_0.json +18 -18
  25. data/spec/fixtures/changes_batch_1.json +18 -18
  26. data/spec/fixtures/changes_batch_2.json +17 -17
  27. data/spec/fixtures/group_members.json +14 -14
  28. data/spec/fixtures/groups.json +68 -68
  29. data/spec/fixtures/open_changes.json +16 -16
  30. data/spec/fixtures/project_branch.json +6 -6
  31. data/spec/fixtures/project_branches.json +21 -21
  32. data/spec/fixtures/project_head.json +2 -2
  33. data/spec/fixtures/projects.json +9 -9
  34. data/spec/fixtures/query_capabilities.json +4 -4
  35. data/spec/groups_spec.rb +92 -92
  36. data/spec/projects_spec.rb +90 -90
  37. data/spec/request_spec.rb +46 -46
  38. data/spec/spec_helper.rb +49 -49
  39. metadata +52 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a1b763d810800ab1dcb57c97e7df8ba54e09d207e549b5e3270b5d09b16aadf
4
- data.tar.gz: 194d9b4dda05ca8cc5b1bf70ef454c706331bb8a32e3f48c3f84f4754675fa18
3
+ metadata.gz: cdd416d7090678970f5d1a5f04d4a0827133e2e070269465054e08f314b64e20
4
+ data.tar.gz: 969930379685fd48a5bbb1b638a7e417f26609e04a3ee61b63527766d5b0ff65
5
5
  SHA512:
6
- metadata.gz: eca9ab70813663d3b95aa85aeaec1918743246d611b19c9690fc388dd6266149e8af2ec10ad1d55d859c92ddebd389bdb6337b490ef2c26f00e64dfd8fab57f9
7
- data.tar.gz: 30bde14c9bc657860cf403d3482b14f2ef13c7f76d65f6ad449b050208e22aeb46c754d2501c7547769a080dd445380e98896b3ab43a1dc30e2a25574a4adefe
6
+ metadata.gz: 87c0d98150ae7eb2e434ea8f16a9e2eb0b09012a165f60da73aaf51875dbdb154a74faef3ff5fb399403fad52870dbae977c5e2a4295abfe97ad4248caf52070
7
+ data.tar.gz: 0e9db5dd62742df26d1cd9a8f1b4f3eb63c2b161f02822e875defd6a3bfd112a5e706bf96b1f9fb82247fe010c6f9efbb614d405ca69235450dc600f6dfe0743
data/README.md CHANGED
@@ -1,62 +1,62 @@
1
- # gerry[![Build Status](https://travis-ci.org/trumant/gerry.svg)][travis]
2
-
3
- Base Gerrit Version V2.14.6
4
-
5
- Simple Ruby wrapper for the Gerrit Code Review REST-API.
6
-
7
- ![Gary from spongebob square pants](http://en.spongepedia.org/images/3/37/Garry.jpg)
8
-
9
- [travis]: https://travis-ci.org/trumant/gerry
10
-
11
- ## Documentation
12
- [http://rdoc.info/github/trumant/gerry][documentation]
13
-
14
- [documentation]: http://rdoc.info/github/trumant/gerry
15
-
16
- ## Install
17
- ```
18
- bundle
19
- bundle exec rake install
20
- ```
21
-
22
- ## Examples
23
- ### Get the global capabilities
24
- ```ruby
25
- client = Gerry.new('https://review')
26
- client.account_capabilities
27
- => {"queryLimit"=>{"min"=>0, "max"=>250}}
28
- ```
29
-
30
- ### List projects
31
- ```ruby
32
- client = Gerry.new('https://review')
33
- client.projects
34
- => { "awesome"=>{ "description"=>"Awesome project"}}
35
- ```
36
-
37
- ### List open changes
38
- ```ruby
39
- client = Gerry.new('https://review')
40
- client.changes(['q=is:open'])
41
- => [{"project"=>"awesome", "branch"=>"master", "id"=>"Ibfedd978...."}]
42
- ```
43
-
44
- ### Authentication type
45
- Since 2.14, Gerrit no longer supports digest authentication.
46
- Gerry uses basic authentication against gerrit.
47
-
48
- ## Licence
49
- The MIT Licence
50
-
51
- Copyright (c) Fabian Mettler, Andrew Erickson, Travis Truman, Sebastian Schuberth, Orgad Shaneh
52
-
53
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
54
-
55
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
56
-
57
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58
-
59
- ## References
60
- https://www.gerritcodereview.com/
61
-
62
- https://gerrit-review.googlesource.com/Documentation/rest-api.html
1
+ # gerry[![Build Status](https://travis-ci.org/trumant/gerry.svg)][travis]
2
+
3
+ Base Gerrit Version V2.14.6
4
+
5
+ Simple Ruby wrapper for the Gerrit Code Review REST-API.
6
+
7
+ ![Gary from spongebob square pants](http://en.spongepedia.org/images/3/37/Garry.jpg)
8
+
9
+ [travis]: https://travis-ci.org/trumant/gerry
10
+
11
+ ## Documentation
12
+ [http://rdoc.info/github/trumant/gerry][documentation]
13
+
14
+ [documentation]: http://rdoc.info/github/trumant/gerry
15
+
16
+ ## Install
17
+ ```
18
+ bundle
19
+ bundle exec rake install
20
+ ```
21
+
22
+ ## Examples
23
+ ### Get the global capabilities
24
+ ```ruby
25
+ client = Gerry.new('https://review')
26
+ client.account_capabilities
27
+ => {"queryLimit"=>{"min"=>0, "max"=>250}}
28
+ ```
29
+
30
+ ### List projects
31
+ ```ruby
32
+ client = Gerry.new('https://review')
33
+ client.projects
34
+ => { "awesome"=>{ "description"=>"Awesome project"}}
35
+ ```
36
+
37
+ ### List open changes
38
+ ```ruby
39
+ client = Gerry.new('https://review')
40
+ client.changes(['q=is:open'])
41
+ => [{"project"=>"awesome", "branch"=>"master", "id"=>"Ibfedd978...."}]
42
+ ```
43
+
44
+ ### Authentication type
45
+ Since 2.14, Gerrit no longer supports digest authentication.
46
+ Gerry uses basic authentication against gerrit.
47
+
48
+ ## Licence
49
+ The MIT Licence
50
+
51
+ Copyright (c) Fabian Mettler, Andrew Erickson, Travis Truman, Sebastian Schuberth, Orgad Shaneh
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
54
+
55
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58
+
59
+ ## References
60
+ https://www.gerritcodereview.com/
61
+
62
+ https://gerrit-review.googlesource.com/Documentation/rest-api.html
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'rspec/core/rake_task'
2
- require 'bundler/gem_tasks'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
7
-
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -1,17 +1,17 @@
1
- require 'erb'
2
-
3
- module Gerry
4
- module Api
5
- module Access
6
- # Get access rights for the specified project
7
- #
8
- # @param [VarArgs] projects the project names
9
- # @return [Hash] the list of access rights
10
- def access(*projects)
11
- projects = projects.flatten.map { |name| ERB::Util.url_encode(name) }
12
- url = "/access/?project=#{projects.join('&project=')}"
13
- get(url)
14
- end
15
- end
16
- end
17
- end
1
+ require 'erb'
2
+
3
+ module Gerry
4
+ module Api
5
+ module Access
6
+ # Get access rights for the specified project
7
+ #
8
+ # @param [VarArgs] projects the project names
9
+ # @return [Hash] the list of access rights
10
+ def access(*projects)
11
+ projects = projects.flatten.map { |name| ERB::Util.url_encode(name) }
12
+ url = "/access/?project=#{projects.join('&project=')}"
13
+ get(url)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,38 +1,38 @@
1
- module Gerry
2
- module Api
3
- module Accounts
4
- # Get the account info for the specified account ID.
5
- #
6
- # @param [String] account_id the account.
7
- # @return [Hash] the account info.
8
- def account_info(account_id)
9
- url = "/accounts/#{account_id}"
10
- get(url)
11
- end
12
-
13
- # Get the global capabilities that are enabled for the calling user.
14
- #
15
- # @param [Array] options the query parameters.
16
- # @return [Hash] the account capabilities.
17
- def account_capabilities(options = [])
18
- url = '/accounts/self/capabilities'
19
-
20
- if options.empty?
21
- return get(url)
22
- end
23
-
24
- options = map_options(options)
25
- get("#{url}?#{options}")
26
- end
27
-
28
- # Get all groups that contain the specified account as a member
29
- #
30
- # @param [String] account_id the account
31
- # @return [Enumberable] the groups
32
- def groups_for_account(account_id)
33
- url = "/accounts/#{account_id}/groups/"
34
- get(url)
35
- end
36
- end
37
- end
38
- end
1
+ module Gerry
2
+ module Api
3
+ module Accounts
4
+ # Get the account info for the specified account ID.
5
+ #
6
+ # @param [String] account_id the account.
7
+ # @return [Hash] the account info.
8
+ def account_info(account_id)
9
+ url = "/accounts/#{account_id}"
10
+ get(url)
11
+ end
12
+
13
+ # Get the global capabilities that are enabled for the calling user.
14
+ #
15
+ # @param [Array] options the query parameters.
16
+ # @return [Hash] the account capabilities.
17
+ def account_capabilities(options = [])
18
+ url = '/accounts/self/capabilities'
19
+
20
+ if options.empty?
21
+ return get(url)
22
+ end
23
+
24
+ options = map_options(options)
25
+ get("#{url}?#{options}")
26
+ end
27
+
28
+ # Get all groups that contain the specified account as a member
29
+ #
30
+ # @param [String] account_id the account
31
+ # @return [Enumberable] the groups
32
+ def groups_for_account(account_id)
33
+ url = "/accounts/#{account_id}/groups/"
34
+ get(url)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,45 +1,45 @@
1
- # frozen_string_literal: true
2
-
3
- module Gerry
4
- module Api
5
- module Branches
6
- ##
7
- # Get the branches of project
8
- #
9
- def branches(project_name)
10
- get("/projects/#{project_name}/branches")
11
- end
12
-
13
- # Get the projects that start with the specified prefix
14
- # and accessible by the caller.
15
- #
16
- # @param [String] name the project name.
17
- # @return [Hash] the projects.
18
- def branch(project_name, branch_name)
19
- get("/projects/#{project_name}/branches/#{branch_name}")
20
- end
21
-
22
- ##
23
- # create branch that derived from branch name or revision
24
- #
25
- # example: create_branch('foo', 'master', 'stable')
26
- # create_branch('foo', 'revision', 'stable')
27
- #
28
- def create_branch(project_name, source, branch)
29
- # try source as ref
30
- body = { ref: source }
31
- put("/projects/#{project_name}/branches/#{branch}", body)
32
- rescue Gerry::Api::Request::RequestError
33
- # try source as revision
34
- body = { revision: source }
35
- put("/projects/#{project_name}/branches/#{branch}", body)
36
- end
37
-
38
- ##
39
- # Gets the reflog of a certain branch.
40
- def branch_reflog(project_name, branch, number)
41
- get("/projects/#{project_name}/branches/#{branch}/reflog?n=#{number}")
42
- end
43
- end
44
- end
45
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Gerry
4
+ module Api
5
+ module Branches
6
+ ##
7
+ # Get the branches of project
8
+ #
9
+ def branches(project_name)
10
+ get("/projects/#{project_name}/branches")
11
+ end
12
+
13
+ # Get the projects that start with the specified prefix
14
+ # and accessible by the caller.
15
+ #
16
+ # @param [String] name the project name.
17
+ # @return [Hash] the projects.
18
+ def branch(project_name, branch_name)
19
+ get("/projects/#{project_name}/branches/#{branch_name}")
20
+ end
21
+
22
+ ##
23
+ # create branch that derived from branch name or revision
24
+ #
25
+ # example: create_branch('foo', 'master', 'stable')
26
+ # create_branch('foo', 'revision', 'stable')
27
+ #
28
+ def create_branch(project_name, source, branch)
29
+ # try source as ref
30
+ body = { ref: source }
31
+ put("/projects/#{project_name}/branches/#{branch}", body)
32
+ rescue Gerry::Api::Request::RequestError
33
+ # try source as revision
34
+ body = { revision: source }
35
+ put("/projects/#{project_name}/branches/#{branch}", body)
36
+ end
37
+
38
+ ##
39
+ # Gets the reflog of a certain branch.
40
+ def branch_reflog(project_name, branch, number)
41
+ get("/projects/#{project_name}/branches/#{branch}/reflog?n=#{number}")
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,38 +1,38 @@
1
- require 'cgi'
2
-
3
- module Gerry
4
- module Api
5
- module Changes
6
- # Get changes visible to the caller.
7
- #
8
- # @param [Array] options the query parameters.
9
- # @return [Hash] the changes.
10
- def changes(options = [])
11
- endpoint = '/changes/'
12
- url = endpoint
13
-
14
- if !options.empty?
15
- url += '?' + map_options(options)
16
- end
17
-
18
- response = get(url)
19
- return response if response.empty? || !response.last.delete('_more_changes')
20
-
21
- # Get the original start parameter, if any, else start from 0.
22
- query = URI.parse(url).query
23
- query = query ? CGI.parse(query) : { 'S' => ['0'] }
24
- start = query['S'].join.to_i
25
-
26
- # Keep getting data until there are no more changes.
27
- loop do
28
- # Replace the start parameter, using the original start as an offset.
29
- query['S'] = ["#{start + response.size}"]
30
- url = endpoint + '?' + map_options(query)
31
-
32
- response.concat(get(url))
33
- return response if response.empty? || !response.last.delete('_more_changes')
34
- end
35
- end
36
- end
37
- end
38
- end
1
+ require 'cgi'
2
+
3
+ module Gerry
4
+ module Api
5
+ module Changes
6
+ # Get changes visible to the caller.
7
+ #
8
+ # @param [Array] options the query parameters.
9
+ # @return [Hash] the changes.
10
+ def changes(options = [])
11
+ endpoint = '/changes/'
12
+ url = endpoint
13
+
14
+ if !options.empty?
15
+ url += '?' + map_options(options)
16
+ end
17
+
18
+ response = get(url)
19
+ return response if response.empty? || !response.last.delete('_more_changes')
20
+
21
+ # Get the original start parameter, if any, else start from 0.
22
+ query = URI.parse(url).query
23
+ query = query ? CGI.parse(query) : { 'S' => ['0'] }
24
+ start = query['S'].join.to_i
25
+
26
+ # Keep getting data until there are no more changes.
27
+ loop do
28
+ # Replace the start parameter, using the original start as an offset.
29
+ query['S'] = ["#{start + response.size}"]
30
+ url = endpoint + '?' + map_options(query)
31
+
32
+ response.concat(get(url))
33
+ return response if response.empty? || !response.last.delete('_more_changes')
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,72 +1,72 @@
1
- require 'json'
2
-
3
- module Gerry
4
- module Api
5
- module Groups
6
- # Get all groups
7
- #
8
- # @return [Hash] the groups
9
- def groups
10
- url = '/groups/'
11
- get(url)
12
- end
13
-
14
- # Get all members for a group
15
- #
16
- # @param [Array] options the query parameters
17
- # @return [Array] the members
18
- def group_members(group_id, options = [])
19
- url = "/groups/#{group_id}/members/"
20
-
21
- if options.empty?
22
- return get(url)
23
- end
24
-
25
- options = map_options(options)
26
- get("#{url}?#{options}")
27
- end
28
-
29
- # Get the directly included groups of a group
30
- #
31
- # @return [Array] the included groups
32
- def included_groups(group_id)
33
- url = "/groups/#{group_id}/groups/"
34
- get(url)
35
- end
36
-
37
- # Create a new group
38
- #
39
- # @return [Hash] the group details
40
- def create_group(name, description, visible, owner_id=nil)
41
- url = "/groups/#{name}"
42
- body = {
43
- description: description,
44
- visible_to_all: visible,
45
- }
46
- body[:owner_id] = owner_id unless owner_id.nil? || owner_id.empty?
47
- put(url, body)
48
- end
49
-
50
- # Adds one or more users to a group
51
- #
52
- # @param [String] group_id the group id
53
- # @param [Enumberable] users the list of users identified by email address
54
- # @return [Hash] the account info details for each user added
55
- def add_to_group(group_id, users)
56
- url = "/groups/#{group_id}/members"
57
- body = {
58
- members: users
59
- }
60
- post(url, body)
61
- end
62
-
63
- def remove_from_group(group_id, users)
64
- url = "/groups/#{group_id}/members.delete"
65
- body = {
66
- members: users
67
- }
68
- post(url, body)
69
- end
70
- end
71
- end
72
- end
1
+ require 'json'
2
+
3
+ module Gerry
4
+ module Api
5
+ module Groups
6
+ # Get all groups
7
+ #
8
+ # @return [Hash] the groups
9
+ def groups
10
+ url = '/groups/'
11
+ get(url)
12
+ end
13
+
14
+ # Get all members for a group
15
+ #
16
+ # @param [Array] options the query parameters
17
+ # @return [Array] the members
18
+ def group_members(group_id, options = [])
19
+ url = "/groups/#{group_id}/members/"
20
+
21
+ if options.empty?
22
+ return get(url)
23
+ end
24
+
25
+ options = map_options(options)
26
+ get("#{url}?#{options}")
27
+ end
28
+
29
+ # Get the directly included groups of a group
30
+ #
31
+ # @return [Array] the included groups
32
+ def included_groups(group_id)
33
+ url = "/groups/#{group_id}/groups/"
34
+ get(url)
35
+ end
36
+
37
+ # Create a new group
38
+ #
39
+ # @return [Hash] the group details
40
+ def create_group(name, description, visible, owner_id=nil)
41
+ url = "/groups/#{name}"
42
+ body = {
43
+ description: description,
44
+ visible_to_all: visible,
45
+ }
46
+ body[:owner_id] = owner_id unless owner_id.nil? || owner_id.empty?
47
+ put(url, body)
48
+ end
49
+
50
+ # Adds one or more users to a group
51
+ #
52
+ # @param [String] group_id the group id
53
+ # @param [Enumberable] users the list of users identified by email address
54
+ # @return [Hash] the account info details for each user added
55
+ def add_to_group(group_id, users)
56
+ url = "/groups/#{group_id}/members"
57
+ body = {
58
+ members: users
59
+ }
60
+ post(url, body)
61
+ end
62
+
63
+ def remove_from_group(group_id, users)
64
+ url = "/groups/#{group_id}/members.delete"
65
+ body = {
66
+ members: users
67
+ }
68
+ post(url, body)
69
+ end
70
+ end
71
+ end
72
+ end