audc-gerry 0.1.8 → 0.1.10
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.
- checksums.yaml +4 -4
- data/README.md +0 -10
- data/lib/{gerry.rb → audc-gerry.rb} +2 -2
- data/lib/gerry/api/request.rb +30 -16
- data/lib/gerry/client.rb +3 -8
- data/lib/gerry/version.rb +1 -3
- data/spec/spec_helper.rb +2 -2
- metadata +4 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64853e2c559f95443f06f07fc21bc2dbf07bb2ee394e90b2a4e422013776b633
|
|
4
|
+
data.tar.gz: 2147f8045bcbbd98995278f1fb469b3c1ba0b1590549b0e5bd9a855b4e0a1783
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cbedd5135fa630e8a3e28e8745483c3e2f53014611ef27220352df86b237778b0831b953afc60bac0b68d5db6c6fc28bd4b09917cdc1ec8ebefda00231db4fc
|
|
7
|
+
data.tar.gz: d4d024e6ff1bdb777fb2c18785ee8eecd3680dfd3ad9f830a8b7784aedaac76cdd0a7a1d28d46907e4b97d2ad9078f7c30c156da5119022464a847530995c94f
|
data/README.md
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
# gerry[][travis]
|
|
2
|
-
|
|
3
|
-
Base Gerrit Version V2.14.6
|
|
4
|
-
|
|
5
1
|
Simple Ruby wrapper for the Gerrit Code Review REST-API.
|
|
6
2
|
|
|
7
3
|

|
|
8
4
|
|
|
9
|
-
[travis]: https://travis-ci.org/trumant/gerry
|
|
10
|
-
|
|
11
5
|
## Documentation
|
|
12
6
|
[http://rdoc.info/github/trumant/gerry][documentation]
|
|
13
7
|
|
|
@@ -41,10 +35,6 @@ client.changes(['q=is:open'])
|
|
|
41
35
|
=> [{"project"=>"awesome", "branch"=>"master", "id"=>"Ibfedd978...."}]
|
|
42
36
|
```
|
|
43
37
|
|
|
44
|
-
### Authentication type
|
|
45
|
-
Since 2.14, Gerrit no longer supports digest authentication.
|
|
46
|
-
Gerry uses basic authentication against gerrit.
|
|
47
|
-
|
|
48
38
|
## Licence
|
|
49
39
|
The MIT Licence
|
|
50
40
|
|
data/lib/gerry/api/request.rb
CHANGED
|
@@ -18,43 +18,57 @@ module Gerry
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def options(body = nil, is_json = true)
|
|
22
|
-
return {} unless body
|
|
23
|
-
default_options = {
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type' => is_json ? 'application/json' : 'text/plain'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
default_options[:body] = is_json ? body.to_json : body
|
|
29
|
-
default_options
|
|
30
|
-
end
|
|
31
|
-
|
|
32
21
|
def get(url)
|
|
33
|
-
response =
|
|
22
|
+
response = perform_request(:get, auth_url(url))
|
|
34
23
|
parse(response)
|
|
35
24
|
end
|
|
36
25
|
|
|
37
26
|
def auth_url(url)
|
|
38
|
-
|
|
27
|
+
(@username && @password) ? "/a#{url}" : url
|
|
39
28
|
end
|
|
40
29
|
|
|
41
30
|
def put(url, body = nil, is_json = true)
|
|
42
|
-
response =
|
|
31
|
+
response = perform_request(:put, auth_url(url), body, is_json)
|
|
43
32
|
parse(response)
|
|
44
33
|
end
|
|
45
34
|
|
|
46
35
|
def post(url, body, is_json = true)
|
|
47
|
-
response =
|
|
36
|
+
response = perform_request(:post, auth_url(url), body, is_json)
|
|
48
37
|
parse(response)
|
|
49
38
|
end
|
|
50
39
|
|
|
51
40
|
def delete(url)
|
|
52
|
-
response =
|
|
41
|
+
response = perform_request(:delete, auth_url(url))
|
|
53
42
|
parse(response)
|
|
54
43
|
end
|
|
55
44
|
|
|
56
45
|
private
|
|
57
46
|
|
|
47
|
+
def perform_request(method, url, body = nil, is_json = true)
|
|
48
|
+
uri = URI.parse("#{@base_uri}#{url}")
|
|
49
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
50
|
+
http.use_ssl = (uri.scheme == 'https')
|
|
51
|
+
|
|
52
|
+
req_class = {
|
|
53
|
+
get: Net::HTTP::Get,
|
|
54
|
+
put: Net::HTTP::Put,
|
|
55
|
+
post: Net::HTTP::Post,
|
|
56
|
+
delete: Net::HTTP::Delete
|
|
57
|
+
}[method]
|
|
58
|
+
|
|
59
|
+
req = req_class.new(uri.request_uri)
|
|
60
|
+
req['Accept'] = 'application/json'
|
|
61
|
+
|
|
62
|
+
if body
|
|
63
|
+
req['Content-Type'] = is_json ? 'application/json' : 'text/plain'
|
|
64
|
+
req.body = is_json ? body.to_json : body
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
req.basic_auth(@username, @password) if @username && @password
|
|
68
|
+
|
|
69
|
+
http.request(req)
|
|
70
|
+
end
|
|
71
|
+
|
|
58
72
|
def parse(response)
|
|
59
73
|
unless /2[0-9][0-9]/.match(response.code.to_s)
|
|
60
74
|
raise_request_error(response)
|
data/lib/gerry/client.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'httparty'
|
|
4
3
|
require 'json'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'uri'
|
|
5
6
|
|
|
6
7
|
require_relative 'api/access'
|
|
7
8
|
require_relative 'api/accounts'
|
|
@@ -24,9 +25,6 @@ module Gerry
|
|
|
24
25
|
#
|
|
25
26
|
|
|
26
27
|
class Client
|
|
27
|
-
include HTTParty
|
|
28
|
-
headers 'Accept' => 'application/json'
|
|
29
|
-
|
|
30
28
|
include Api::Access
|
|
31
29
|
include Api::Accounts
|
|
32
30
|
include Api::Changes
|
|
@@ -40,7 +38,7 @@ module Gerry
|
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def initialize(url, username = nil, password = nil)
|
|
43
|
-
|
|
41
|
+
@base_uri = url
|
|
44
42
|
|
|
45
43
|
if username && password
|
|
46
44
|
@username = username
|
|
@@ -49,9 +47,6 @@ module Gerry
|
|
|
49
47
|
require 'netrc'
|
|
50
48
|
@username, @password = Netrc.read[URI.parse(url).host]
|
|
51
49
|
end
|
|
52
|
-
if @username && @password
|
|
53
|
-
self.class.basic_auth(@username, @password)
|
|
54
|
-
end
|
|
55
50
|
end
|
|
56
51
|
end
|
|
57
52
|
end
|
data/lib/gerry/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "rspec/expectations"
|
|
2
2
|
require 'webmock/rspec'
|
|
3
3
|
|
|
4
|
-
require_relative '../lib/gerry'
|
|
4
|
+
require_relative '../lib/audc-gerry'
|
|
5
5
|
|
|
6
6
|
class MockGerry < Gerry::Client
|
|
7
7
|
URL = 'http://localhost'
|
|
@@ -47,4 +47,4 @@ def stub_post(url, body, response_body=nil)
|
|
|
47
47
|
stub_request(:post, "#{MockGerry::URL}#{url}").
|
|
48
48
|
with(:body => body, :headers => { 'Content-Type' => 'application/json' }).
|
|
49
49
|
to_return(response)
|
|
50
|
-
end
|
|
50
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: audc-gerry
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fabian Mettler
|
|
@@ -12,22 +12,8 @@ authors:
|
|
|
12
12
|
- iiithking
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date:
|
|
15
|
+
date: 2026-06-11 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
|
-
- !ruby/object:Gem::Dependency
|
|
18
|
-
name: httparty
|
|
19
|
-
requirement: !ruby/object:Gem::Requirement
|
|
20
|
-
requirements:
|
|
21
|
-
- - "~>"
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: 0.23.2
|
|
24
|
-
type: :runtime
|
|
25
|
-
prerelease: false
|
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
27
|
-
requirements:
|
|
28
|
-
- - "~>"
|
|
29
|
-
- !ruby/object:Gem::Version
|
|
30
|
-
version: 0.23.2
|
|
31
17
|
- !ruby/object:Gem::Dependency
|
|
32
18
|
name: guard
|
|
33
19
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,7 +134,7 @@ extra_rdoc_files: []
|
|
|
148
134
|
files:
|
|
149
135
|
- README.md
|
|
150
136
|
- Rakefile
|
|
151
|
-
- lib/gerry.rb
|
|
137
|
+
- lib/audc-gerry.rb
|
|
152
138
|
- lib/gerry/api/access.rb
|
|
153
139
|
- lib/gerry/api/accounts.rb
|
|
154
140
|
- lib/gerry/api/branches.rb
|
|
@@ -201,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
201
187
|
- !ruby/object:Gem::Version
|
|
202
188
|
version: '0'
|
|
203
189
|
requirements: []
|
|
204
|
-
rubygems_version: 3.6.
|
|
190
|
+
rubygems_version: 3.6.7
|
|
205
191
|
specification_version: 4
|
|
206
192
|
summary: Simple Ruby wrapper for the Gerrit Code Review REST-API.
|
|
207
193
|
test_files:
|