git-semaphore 2.8.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/git-semaphore.gemspec +2 -0
- data/lib/ext/faraday.rb +20 -0
- data/lib/ext/nitlink.rb +39 -0
- data/lib/git/semaphore.rb +7 -0
- data/lib/git/semaphore/api.rb +35 -94
- data/lib/git/semaphore/api_cache.rb +12 -12
- data/lib/git/semaphore/api_enrich.rb +6 -6
- data/lib/git/semaphore/project.rb +7 -7
- data/lib/git/semaphore/version.rb +1 -1
- data/lib/semaphore_ci/api.rb +72 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f76f2487f427528a0200987155e53304464e5402e15379c038e42bb1048a06
|
4
|
+
data.tar.gz: cfa81dc4e13c1b33ad0c997060fc5d07d38141dbdef3aa116f141944194111b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7590f74d4d5ef32d38569aa13c9af475b2bc0e596955b04d558a7f69acae22c78185a374edd58cb4802942e64e053ba9237a24d23404c6b7539cf4967a797abd
|
7
|
+
data.tar.gz: 023405af11917e711600b888552b1cdcf9cb08bbb70ad3be684588d104893ac491580ea8189ff52974dead1fbf17ff8459a2a59d5d8837b60a9fd3afc1fa3108
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git-semaphore (
|
4
|
+
git-semaphore (3.0.0)
|
5
|
+
faraday (~> 0.15)
|
6
|
+
nitlink (~> 1.1)
|
5
7
|
rugged (~> 0.27)
|
6
8
|
slop (~> 4.6)
|
7
9
|
|
@@ -10,9 +12,13 @@ GEM
|
|
10
12
|
specs:
|
11
13
|
ast (2.4.0)
|
12
14
|
coderay (1.1.2)
|
15
|
+
faraday (0.15.4)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
13
17
|
jaro_winkler (1.5.2)
|
14
18
|
method_source (0.9.2)
|
15
19
|
minitest (5.11.3)
|
20
|
+
multipart-post (2.0.0)
|
21
|
+
nitlink (1.1.0)
|
16
22
|
parallel (1.14.0)
|
17
23
|
parser (2.6.0.0)
|
18
24
|
ast (~> 2.4.0)
|
data/git-semaphore.gemspec
CHANGED
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.post_install_message = Git::Semaphore::PIM
|
27
27
|
|
28
|
+
spec.add_dependency 'faraday', '~> 0.15'
|
29
|
+
spec.add_dependency 'nitlink', '~> 1.1'
|
28
30
|
spec.add_dependency 'rugged', '~> 0.27'
|
29
31
|
spec.add_dependency 'slop', '~> 4.6'
|
30
32
|
|
data/lib/ext/faraday.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Faraday
|
2
|
+
class Adapter
|
3
|
+
class SemaphoreNetHttp < NetHttp
|
4
|
+
def net_http_connection(env)
|
5
|
+
connections = (Thread.current[:net_http_connections] ||= {})
|
6
|
+
env_key = [env.url.host, env.url.port, env.ssl.verify]
|
7
|
+
connections[env_key] ||= begin
|
8
|
+
super(env).tap { |connection|
|
9
|
+
# uncomment to enable Net::HTTP debugging
|
10
|
+
# connection.set_debug_output($stderr)
|
11
|
+
connection.use_ssl = true
|
12
|
+
connection.start
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
register_middleware semaphore_net_http: SemaphoreNetHttp
|
19
|
+
end
|
20
|
+
end
|
data/lib/ext/nitlink.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# pagination: "{\"total_entries\":1535,\"total_pages\":77,\"per_page\":20,\"current_page\":1,\"first_page\":true,\"last_page\":false,\"previous_page\":null,\"next_page\":2}"
|
2
|
+
|
3
|
+
# {"total_entries"=>1535,
|
4
|
+
# "total_pages"=>77,
|
5
|
+
# "per_page"=>20,
|
6
|
+
# "current_page"=>1,
|
7
|
+
# "first_page"=>true,
|
8
|
+
# "last_page"=>false,
|
9
|
+
# "previous_page"=>nil,
|
10
|
+
# "next_page"=>2}
|
11
|
+
|
12
|
+
module Semlink
|
13
|
+
class Parser
|
14
|
+
def parse(response)
|
15
|
+
link_collection = Nitlink::LinkCollection.new
|
16
|
+
|
17
|
+
# FIXME: url.query could be nil/""
|
18
|
+
|
19
|
+
if (pagination = response['pagination'])
|
20
|
+
pagination = JSON.parse(pagination)
|
21
|
+
|
22
|
+
if (next_page = pagination['next_page'])
|
23
|
+
next_url = response.env['url'].dup
|
24
|
+
next_url.query = [next_url.query, "page=#{next_page}"].join('&')
|
25
|
+
link_collection << Nitlink::Link.new(next_url, 'next', nil, nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
if (prev_page = pagination['previous_page'])
|
29
|
+
prev_url = response.env['url'].dup
|
30
|
+
prev_url.query = [prev_url.query, "page=#{prev_page}"].join('&')
|
31
|
+
link_collection << Nitlink::Link.new(prev_url, 'previous', nil, nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
link_collection
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/git/semaphore.rb
CHANGED
@@ -6,8 +6,13 @@ require 'openssl'
|
|
6
6
|
require 'net/http'
|
7
7
|
require 'fileutils'
|
8
8
|
|
9
|
+
require 'faraday'
|
10
|
+
require 'nitlink'
|
9
11
|
require 'rugged'
|
10
12
|
|
13
|
+
require 'ext/faraday'
|
14
|
+
require 'ext/nitlink'
|
15
|
+
|
11
16
|
module Rugged
|
12
17
|
class Repository
|
13
18
|
def owner() File.basename(File.dirname(workdir)); end
|
@@ -81,6 +86,8 @@ end
|
|
81
86
|
|
82
87
|
require 'git/semaphore/version'
|
83
88
|
|
89
|
+
require 'semaphore_ci/api'
|
90
|
+
|
84
91
|
require 'git/semaphore/api'
|
85
92
|
require 'git/semaphore/api_cache'
|
86
93
|
require 'git/semaphore/api_enrich'
|
data/lib/git/semaphore/api.rb
CHANGED
@@ -2,158 +2,99 @@ module Git
|
|
2
2
|
module Semaphore
|
3
3
|
class API
|
4
4
|
|
5
|
-
def self.projects
|
6
|
-
get_json projects_uri
|
5
|
+
def self.projects
|
6
|
+
get_json projects_uri
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.branches(project_hash_id
|
10
|
-
get_json branches_uri(project_hash_id
|
9
|
+
def self.branches(project_hash_id)
|
10
|
+
get_json branches_uri(project_hash_id)
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.status(project_hash_id, branch_id
|
14
|
-
get_json status_uri(project_hash_id, branch_id
|
13
|
+
def self.status(project_hash_id, branch_id)
|
14
|
+
get_json status_uri(project_hash_id, branch_id)
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.history(project_hash_id, branch_id
|
18
|
-
|
19
|
-
previous_page['builds'] += next_page['builds']
|
20
|
-
end
|
17
|
+
def self.history(project_hash_id, branch_id)
|
18
|
+
get_json history_uri(project_hash_id, branch_id)
|
21
19
|
end
|
22
20
|
|
23
|
-
def self.information(project_hash_id, branch_id, build_number
|
24
|
-
get_json information_uri(project_hash_id, branch_id, build_number
|
21
|
+
def self.information(project_hash_id, branch_id, build_number)
|
22
|
+
get_json information_uri(project_hash_id, branch_id, build_number)
|
25
23
|
end
|
26
24
|
|
27
|
-
def self.log(project_hash_id, branch_id, build_number
|
28
|
-
get_json log_uri(project_hash_id, branch_id, build_number
|
25
|
+
def self.log(project_hash_id, branch_id, build_number)
|
26
|
+
get_json log_uri(project_hash_id, branch_id, build_number)
|
29
27
|
end
|
30
28
|
|
31
|
-
def self.rebuild(project_hash_id, branch_id
|
32
|
-
get_json last_revision_uri(project_hash_id, branch_id
|
29
|
+
def self.rebuild(project_hash_id, branch_id)
|
30
|
+
get_json last_revision_uri(project_hash_id, branch_id), :post
|
33
31
|
end
|
34
32
|
|
33
|
+
#
|
35
34
|
# private helper functions
|
35
|
+
#
|
36
36
|
|
37
|
-
def self.
|
37
|
+
def self.get_json(uri)
|
38
|
+
@client ||= SemaphoreCI::API::V1.new(Git::Semaphore.auth_token)
|
39
|
+
@client.get(uri)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.projects_uri
|
38
43
|
# https://semaphoreci.com/docs/projects-api.html
|
39
44
|
# GET /api/v1/projects
|
40
|
-
|
45
|
+
File.join('/projects')
|
41
46
|
end
|
42
47
|
|
43
48
|
private_class_method :projects_uri
|
44
49
|
|
45
|
-
def self.branches_uri(project_hash_id
|
50
|
+
def self.branches_uri(project_hash_id)
|
46
51
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#project_branches
|
47
52
|
# GET /api/v1/projects/:hash_id/branches
|
48
|
-
|
53
|
+
File.join('/projects', project_hash_id, 'branches')
|
49
54
|
end
|
50
55
|
|
51
56
|
private_class_method :branches_uri
|
52
57
|
|
53
|
-
def self.status_uri(project_hash_id, branch_id
|
58
|
+
def self.status_uri(project_hash_id, branch_id)
|
54
59
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#branch_status
|
55
60
|
# GET /api/v1/projects/:hash_id/:id/status
|
56
|
-
|
61
|
+
File.join('/projects', project_hash_id, branch_id, 'status')
|
57
62
|
end
|
58
63
|
|
59
64
|
private_class_method :status_uri
|
60
65
|
|
61
|
-
def self.history_uri(project_hash_id, branch_id
|
66
|
+
def self.history_uri(project_hash_id, branch_id)
|
62
67
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#branch_history
|
63
68
|
# GET /api/v1/projects/:hash_id/:id
|
64
|
-
|
69
|
+
File.join('/projects', project_hash_id, branch_id)
|
65
70
|
end
|
66
71
|
|
67
72
|
private_class_method :history_uri
|
68
73
|
|
69
|
-
def self.information_uri(project_hash_id, branch_id, build_number
|
74
|
+
def self.information_uri(project_hash_id, branch_id, build_number)
|
70
75
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#build_information
|
71
76
|
# GET /api/v1/projects/:hash_id/:id/builds/:number
|
72
|
-
|
77
|
+
File.join('/projects', project_hash_id, branch_id, 'builds', build_number)
|
73
78
|
end
|
74
79
|
|
75
80
|
private_class_method :information_uri
|
76
81
|
|
77
|
-
def self.log_uri(project_hash_id, branch_id, build_number
|
82
|
+
def self.log_uri(project_hash_id, branch_id, build_number)
|
78
83
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#build_log
|
79
84
|
# GET /api/v1/projects/:hash_id/:id/builds/:number/log
|
80
|
-
|
85
|
+
File.join('/projects', project_hash_id, branch_id, 'builds', build_number, 'log')
|
81
86
|
end
|
82
87
|
|
83
88
|
private_class_method :log_uri
|
84
89
|
|
85
|
-
def self.last_revision_uri(project_hash_id, branch_id
|
90
|
+
def self.last_revision_uri(project_hash_id, branch_id)
|
86
91
|
# https://semaphoreci.com/docs/branches-and-builds-api.html#rebuild
|
87
92
|
# POST /api/v1/projects/:project_hash_id/:branch_id/build
|
88
|
-
|
93
|
+
File.join('/projects', project_hash_id, branch_id, 'build')
|
89
94
|
end
|
90
95
|
|
91
96
|
private_class_method :last_revision_uri
|
92
97
|
|
93
|
-
# more private helper functions
|
94
|
-
|
95
|
-
def self.get_response(uri, action = :get)
|
96
|
-
response = ::Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https'), verify_mode: ::OpenSSL::SSL::VERIFY_NONE) do |net_http|
|
97
|
-
case action
|
98
|
-
when :get
|
99
|
-
net_http.get uri.request_uri
|
100
|
-
when :post
|
101
|
-
net_http.post uri.request_uri, uri.query
|
102
|
-
else
|
103
|
-
raise 'Unsupported action'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def response.json_body
|
108
|
-
# "application/json; charset=utf-8"
|
109
|
-
raise 'JSON body expected' \
|
110
|
-
unless self['content-type'] =~ %r{\Aapplication/json}
|
111
|
-
JSON.parse(body)
|
112
|
-
end
|
113
|
-
|
114
|
-
response
|
115
|
-
end
|
116
|
-
|
117
|
-
private_class_method :get_response
|
118
|
-
|
119
|
-
def self.get_paginated_response(uri, action = :get)
|
120
|
-
response = get_response(uri, action)
|
121
|
-
body = response.json_body
|
122
|
-
loop do
|
123
|
-
pagination_header = response['Pagination']
|
124
|
-
break unless pagination_header
|
125
|
-
pagination = JSON.parse(pagination_header)
|
126
|
-
break if pagination['last_page']
|
127
|
-
uri.query = uri.query.sub(/page=(\d+)/, "page=#{pagination['next_page']}")
|
128
|
-
response = get_response(uri, action)
|
129
|
-
yield(body, response.json_body)
|
130
|
-
end
|
131
|
-
body
|
132
|
-
end
|
133
|
-
|
134
|
-
private_class_method :get_paginated_response
|
135
|
-
|
136
|
-
def self.get_json(uri, action = :get)
|
137
|
-
get_response(uri, action).json_body
|
138
|
-
end
|
139
|
-
|
140
|
-
private_class_method :get_json
|
141
|
-
|
142
|
-
# https://semaphoreci.com/docs/
|
143
|
-
SEMAPHORE_API_HOST = 'semaphoreci.com'.freeze
|
144
|
-
SEMAPHORE_API_URI = '/api/v1/'.freeze
|
145
|
-
|
146
|
-
def self.request_uri(auth_token, options = {})
|
147
|
-
page = options.delete(:page) # API pagination
|
148
|
-
options[:host] ||= SEMAPHORE_API_HOST
|
149
|
-
options[:path].prepend SEMAPHORE_API_URI
|
150
|
-
options[:query] = "auth_token=#{auth_token}"
|
151
|
-
options[:query] << "&page=#{page}" if page
|
152
|
-
URI::HTTPS.build(options)
|
153
|
-
end
|
154
|
-
|
155
|
-
private_class_method :request_uri
|
156
|
-
|
157
98
|
end
|
158
99
|
end
|
159
100
|
end
|
@@ -3,39 +3,39 @@ module Git
|
|
3
3
|
class API
|
4
4
|
class Cache
|
5
5
|
|
6
|
-
def self.projects(refresh
|
6
|
+
def self.projects(refresh)
|
7
7
|
@projects ||= Git::Semaphore.from_json_cache(projects_cache, refresh) do
|
8
|
-
API::Enrich.projects
|
8
|
+
API::Enrich.projects
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.branches(project_hash_id, refresh
|
12
|
+
def self.branches(project_hash_id, refresh)
|
13
13
|
@branches ||= Git::Semaphore.from_json_cache(branches_cache(project_hash_id), refresh) do
|
14
|
-
API.branches project_hash_id
|
14
|
+
API.branches project_hash_id
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.status(project_hash_id, branch_id, refresh
|
18
|
+
def self.status(project_hash_id, branch_id, refresh)
|
19
19
|
@status ||= Git::Semaphore.from_json_cache(status_cache(project_hash_id, branch_id), refresh) do
|
20
|
-
API::Enrich.status project_hash_id, branch_id
|
20
|
+
API::Enrich.status project_hash_id, branch_id
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.history(project_hash_id, branch_id, refresh
|
24
|
+
def self.history(project_hash_id, branch_id, refresh)
|
25
25
|
@history ||= Git::Semaphore.from_json_cache(history_cache(project_hash_id, branch_id), refresh) do
|
26
|
-
API::Enrich.history project_hash_id, branch_id
|
26
|
+
API::Enrich.history project_hash_id, branch_id
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.information(project_hash_id, branch_id, build_number, refresh
|
30
|
+
def self.information(project_hash_id, branch_id, build_number, refresh)
|
31
31
|
@information ||= Git::Semaphore.from_json_cache(information_cache(project_hash_id, branch_id, build_number), refresh) do
|
32
|
-
API.information project_hash_id, branch_id, build_number
|
32
|
+
API.information project_hash_id, branch_id, build_number
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.log(project_hash_id, branch_id, build_number, refresh
|
36
|
+
def self.log(project_hash_id, branch_id, build_number, refresh)
|
37
37
|
@log ||= Git::Semaphore.from_json_cache(log_cache(project_hash_id, branch_id, build_number), refresh) do
|
38
|
-
API.log project_hash_id, branch_id, build_number
|
38
|
+
API.log project_hash_id, branch_id, build_number
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -3,8 +3,8 @@ module Git
|
|
3
3
|
class API
|
4
4
|
class Enrich
|
5
5
|
|
6
|
-
def self.projects
|
7
|
-
API.projects
|
6
|
+
def self.projects
|
7
|
+
API.projects.tap do |results|
|
8
8
|
results.each do |project|
|
9
9
|
# full repository name on github.com: 'pvdb/git-semaphore'
|
10
10
|
project['full_name'] = [project['owner'], project['name']].join('/')
|
@@ -14,16 +14,16 @@ module Git
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.history(project_hash_id, branch_id
|
18
|
-
API.history(project_hash_id, branch_id
|
17
|
+
def self.history(project_hash_id, branch_id)
|
18
|
+
API.history(project_hash_id, branch_id).tap do |history|
|
19
19
|
history['builds'].each do |build|
|
20
20
|
enrich(build)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.status(project_hash_id, branch_id
|
26
|
-
API.status(project_hash_id, branch_id
|
25
|
+
def self.status(project_hash_id, branch_id)
|
26
|
+
API.status(project_hash_id, branch_id).tap do |status|
|
27
27
|
enrich(status)
|
28
28
|
end
|
29
29
|
end
|
@@ -110,7 +110,7 @@ module Git
|
|
110
110
|
#
|
111
111
|
|
112
112
|
def self.all(refresh = false)
|
113
|
-
Git::Semaphore::API::Cache.projects(refresh
|
113
|
+
Git::Semaphore::API::Cache.projects(refresh)
|
114
114
|
end
|
115
115
|
|
116
116
|
class << self
|
@@ -118,27 +118,27 @@ module Git
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def branches(refresh = false)
|
121
|
-
Git::Semaphore::API::Cache.branches(project_hash_id, refresh
|
121
|
+
Git::Semaphore::API::Cache.branches(project_hash_id, refresh)
|
122
122
|
end
|
123
123
|
|
124
124
|
def status(refresh = false)
|
125
|
-
Git::Semaphore::API::Cache.status(project_hash_id, branch_id, refresh
|
125
|
+
Git::Semaphore::API::Cache.status(project_hash_id, branch_id, refresh)
|
126
126
|
end
|
127
127
|
|
128
128
|
def history(refresh = false)
|
129
|
-
Git::Semaphore::API::Cache.history(project_hash_id, branch_id, refresh
|
129
|
+
Git::Semaphore::API::Cache.history(project_hash_id, branch_id, refresh)
|
130
130
|
end
|
131
131
|
|
132
132
|
def information(refresh = false)
|
133
|
-
Git::Semaphore::API::Cache.information(project_hash_id, branch_id, build_number, refresh
|
133
|
+
Git::Semaphore::API::Cache.information(project_hash_id, branch_id, build_number, refresh)
|
134
134
|
end
|
135
135
|
|
136
136
|
def log(refresh = false)
|
137
|
-
Git::Semaphore::API::Cache.log(project_hash_id, branch_id, build_number, refresh
|
137
|
+
Git::Semaphore::API::Cache.log(project_hash_id, branch_id, build_number, refresh)
|
138
138
|
end
|
139
139
|
|
140
140
|
def rebuild
|
141
|
-
Git::Semaphore::API.rebuild(project_hash_id, branch_id
|
141
|
+
Git::Semaphore::API.rebuild(project_hash_id, branch_id)
|
142
142
|
end
|
143
143
|
|
144
144
|
def browse
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module SemaphoreCI
|
2
|
+
module API
|
3
|
+
class Client
|
4
|
+
def initialize(token, url, prefix, link_parser_class)
|
5
|
+
@token = token
|
6
|
+
@url = url
|
7
|
+
@prefix = prefix
|
8
|
+
@link_parser = link_parser_class.new
|
9
|
+
|
10
|
+
@conn = Faraday.new(url: @url) do |conn|
|
11
|
+
# uncomment to enable Faraday debugging
|
12
|
+
# conn.response :logger
|
13
|
+
# conn.token_auth token # FIXME: make we work for V2 API
|
14
|
+
conn.adapter :semaphore_net_http
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path)
|
19
|
+
response = @conn.get(path.prepend(@prefix), auth_token: @token)
|
20
|
+
result = json_from(response)
|
21
|
+
|
22
|
+
while (next_link = @link_parser.parse(response).by_rel('next'))
|
23
|
+
response = @conn.get(next_link.target.to_s)
|
24
|
+
next_result = json_from(response)
|
25
|
+
|
26
|
+
case [result.class, next_result.class]
|
27
|
+
when [Array, Array]
|
28
|
+
# V2 pagination
|
29
|
+
result.concat(next_result)
|
30
|
+
when [Hash, Hash]
|
31
|
+
# V1 pagination
|
32
|
+
next_result.each do |key, value|
|
33
|
+
if value.is_a? Array
|
34
|
+
result[key].concat(value)
|
35
|
+
elsif value.is_a? Hash
|
36
|
+
result[key].merge(value)
|
37
|
+
else
|
38
|
+
result[key] = value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else raise 'Unsupported API response'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def json_from(response)
|
51
|
+
if (content_type = response['content-type'])
|
52
|
+
# should be something like "application/json; charset=utf-8"
|
53
|
+
content_type['application/json'] || raise('JSON body expected')
|
54
|
+
end
|
55
|
+
|
56
|
+
JSON.parse(response.body)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class V1 < Client
|
61
|
+
def initialize(token)
|
62
|
+
super(token, 'https://semaphoreci.com/', '/api/v1', Semlink::Parser)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class V2 < Client
|
67
|
+
def initialize(token)
|
68
|
+
super(token, 'https://api.semaphoreci.com/', '/v2', Nitlink::Parser)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-semaphore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenberk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nitlink
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rugged
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +158,8 @@ files:
|
|
130
158
|
- bin/setup
|
131
159
|
- exe/git-semaphore
|
132
160
|
- git-semaphore.gemspec
|
161
|
+
- lib/ext/faraday.rb
|
162
|
+
- lib/ext/nitlink.rb
|
133
163
|
- lib/git/semaphore.rb
|
134
164
|
- lib/git/semaphore/api.rb
|
135
165
|
- lib/git/semaphore/api_cache.rb
|
@@ -137,6 +167,7 @@ files:
|
|
137
167
|
- lib/git/semaphore/gemspec.rb
|
138
168
|
- lib/git/semaphore/project.rb
|
139
169
|
- lib/git/semaphore/version.rb
|
170
|
+
- lib/semaphore_ci/api.rb
|
140
171
|
homepage: https://github.com/pvdb/git-semaphore
|
141
172
|
licenses:
|
142
173
|
- MIT
|