audc-gerry 0.1.9 → 0.1.11
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/lib/gerry/api/request.rb +30 -16
- data/lib/gerry/client.rb +5 -8
- data/lib/gerry/version.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +3 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d4a9979f2094ec0152b871da64e077343cfabb17c113e931fc9aee97b3ec5334
|
|
4
|
+
data.tar.gz: a34a5c5bc528c812cc6e6d76657c7143eea9b43b82cea0665b2a7492e9c7561a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 166044fab28cc7375df59bf4b9122ac832be1e62e8c18d7694ff1d43af86345143b4fd1f5d8d1005208346bcea1a05577aa4a5bd8b26f7ab5b3e4666b0a90386
|
|
7
|
+
data.tar.gz: d3751ff7ebfe9b8a705da6d7ff14e4f619444dc4bf5280b12ff48e9bc85a28d6d0169dfafcc393ce4de668737233da8c8ef93c01117578d258fba46171ed009f
|
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
|
|
@@ -35,12 +33,14 @@ module Gerry
|
|
|
35
33
|
include Api::Branches
|
|
36
34
|
include Api::Request
|
|
37
35
|
|
|
36
|
+
attr_reader :base_uri
|
|
37
|
+
|
|
38
38
|
def set_auth_type(auth_type)
|
|
39
39
|
warn 'set_auth_type is deprecated. digest auth is no longer supported'
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def initialize(url, username = nil, password = nil)
|
|
43
|
-
|
|
43
|
+
@base_uri = url
|
|
44
44
|
|
|
45
45
|
if username && password
|
|
46
46
|
@username = username
|
|
@@ -49,9 +49,6 @@ module Gerry
|
|
|
49
49
|
require 'netrc'
|
|
50
50
|
@username, @password = Netrc.read[URI.parse(url).host]
|
|
51
51
|
end
|
|
52
|
-
if @username && @password
|
|
53
|
-
self.class.basic_auth(@username, @password)
|
|
54
|
-
end
|
|
55
52
|
end
|
|
56
53
|
end
|
|
57
54
|
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.11
|
|
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
|
|
@@ -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:
|