vx-service_connector 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vx/service_connector/error.rb +1 -1
- data/lib/vx/service_connector/gitlab_v6/session.rb +20 -6
- data/lib/vx/service_connector/instrumentation.rb +0 -1
- data/lib/vx/service_connector/model.rb +8 -2
- data/lib/vx/service_connector/version.rb +1 -1
- data/spec/lib/model_spec.rb +20 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52cbb6a0746f93f3d0a5cb115b40bea4ca1d3285
|
4
|
+
data.tar.gz: f26d4ff7f9c5b8a10d47d09128d18af8393a0ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0c48d29fe52fc515f4af58e35c669f035d4e1b9148f34a517dc0cdfafd6918a5c1a81ba5554e9025482d42026cd4bb805ff35bbec58ca6091f369938b20ec3
|
7
|
+
data.tar.gz: db8f3a59715a8fa358e2c179cdf2e68a4e94e7fd55e8b612f39d8f0638298daa1183c142fa2263e7426235cdcdb1a2198c379ed637f7cbc00316cc3f3704706a
|
@@ -7,18 +7,24 @@ module Vx
|
|
7
7
|
Session = Struct.new(:endpoint, :private_token) do
|
8
8
|
|
9
9
|
def get(url, options = {})
|
10
|
-
|
11
|
-
|
10
|
+
wrap do
|
11
|
+
res = agent.call :get, request_url(url), nil, query: options
|
12
|
+
response! res
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
16
|
def post(url, options = {})
|
15
|
-
|
16
|
-
|
17
|
+
wrap do
|
18
|
+
res = agent.call :post, request_url(url), options, nil
|
19
|
+
response! res
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def delete(url, options = {})
|
20
|
-
|
21
|
-
|
24
|
+
wrap do
|
25
|
+
res = agent.call :delete, request_url(url), nil, query: options
|
26
|
+
response! res
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
def uri
|
@@ -27,6 +33,14 @@ module Vx
|
|
27
33
|
|
28
34
|
private
|
29
35
|
|
36
|
+
def wrap
|
37
|
+
begin
|
38
|
+
yield
|
39
|
+
rescue Errno::ETIMEDOUT => e
|
40
|
+
raise RequestError, e
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
30
44
|
def response!(res)
|
31
45
|
if (200..204).include?(res.status)
|
32
46
|
res.data
|
@@ -2,6 +2,8 @@ module Vx
|
|
2
2
|
module ServiceConnector
|
3
3
|
module Model
|
4
4
|
|
5
|
+
PAYLOAD_IGNORE_RE = Regexp.escape("[ci skip]")
|
6
|
+
|
5
7
|
Repo = Struct.new(
|
6
8
|
:id,
|
7
9
|
:full_name,
|
@@ -12,7 +14,7 @@ module Vx
|
|
12
14
|
)
|
13
15
|
|
14
16
|
Payload = Struct.new(
|
15
|
-
:
|
17
|
+
:skip,
|
16
18
|
:pull_request?,
|
17
19
|
:pull_request_number,
|
18
20
|
:branch,
|
@@ -25,6 +27,10 @@ module Vx
|
|
25
27
|
) do
|
26
28
|
def to_hash ; to_h end
|
27
29
|
|
30
|
+
def ignore?
|
31
|
+
skip || message.to_s =~ /#{PAYLOAD_IGNORE_RE}/
|
32
|
+
end
|
33
|
+
|
28
34
|
class << self
|
29
35
|
def from_hash(params)
|
30
36
|
payload = Payload.new
|
@@ -40,7 +46,7 @@ module Vx
|
|
40
46
|
|
41
47
|
def test_payload_attributes(params = {})
|
42
48
|
{
|
43
|
-
|
49
|
+
skip: false,
|
44
50
|
pull_request?: false,
|
45
51
|
pull_request_number: nil,
|
46
52
|
branch: 'master',
|
data/spec/lib/model_spec.rb
CHANGED
@@ -2,11 +2,27 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "(models)" do
|
4
4
|
context Vx::ServiceConnector::Model::Payload do
|
5
|
+
let(:params) { Vx::ServiceConnector::Model.test_payload_attributes }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
it { should eq params }
|
7
|
+
it "should build from hash" do
|
8
|
+
payload = described_class.from_hash(params).to_hash
|
9
|
+
expect(payload).to eq params
|
10
10
|
end
|
11
|
+
|
12
|
+
it "should knowns [ci skip]" do
|
13
|
+
params[:skip] = false
|
14
|
+
payload = described_class.from_hash(params)
|
15
|
+
expect(payload).to_not be_ignore
|
16
|
+
|
17
|
+
params[:skip] = true
|
18
|
+
payload = described_class.from_hash(params)
|
19
|
+
expect(payload).to be_ignore
|
20
|
+
|
21
|
+
params[:skip] = false
|
22
|
+
params[:message] = 'message [ci skip]'
|
23
|
+
payload = described_class.from_hash(params)
|
24
|
+
expect(payload).to be_ignore
|
25
|
+
end
|
26
|
+
|
11
27
|
end
|
12
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-service_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|