travis-conditions 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +10 -8
- data/lib/travis/conditions/v1/data.rb +6 -4
- data/lib/travis/conditions/version.rb +1 -1
- data/spec/v1/conditions_spec.rb +10 -3
- data/spec/v1/data_spec.rb +39 -1
- data/travis-conditions.gemspec +23 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dedeb04bec488371ab045739237bff10a34ca15a
|
4
|
+
data.tar.gz: 7a4c46f91e0238bc78b6819afe98aa76d9d1f6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72f8c330507570e4f013da10c68dba03cc6023815dc53059e73a15294a829aff544d0d6229dee3594bb0a52b47fc6c00aa6f00a372844b04197f14e50026ae5
|
7
|
+
data.tar.gz: 6b23fe2e7795cc6bdbf70c22cb7dce52e46a5f28fb734223f94c2aeb09f4215ae230feb759147c6688bb2bfd7bff7daac014dc9d5ff0715729a13567a11926c1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
remote:
|
3
|
-
revision: 6ed4b4c27f5f9a57f4aa9f0ae8e15a6dfaf7eeb6
|
4
|
-
ref: sf-env_vars
|
1
|
+
PATH
|
2
|
+
remote: .
|
5
3
|
specs:
|
6
|
-
travis-
|
4
|
+
travis-conditions (1.0.9)
|
5
|
+
parslet (~> 1.8.2)
|
6
|
+
sh_vars (~> 1.0.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.3)
|
12
|
-
parslet (1.8.
|
12
|
+
parslet (1.8.2)
|
13
13
|
rspec (3.6.0)
|
14
14
|
rspec-core (~> 3.6.0)
|
15
15
|
rspec-expectations (~> 3.6.0)
|
@@ -23,6 +23,7 @@ GEM
|
|
23
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
24
|
rspec-support (~> 3.6.0)
|
25
25
|
rspec-support (3.6.0)
|
26
|
+
sh_vars (1.0.2)
|
26
27
|
|
27
28
|
PLATFORMS
|
28
29
|
ruby
|
@@ -30,7 +31,8 @@ PLATFORMS
|
|
30
31
|
DEPENDENCIES
|
31
32
|
parslet
|
32
33
|
rspec
|
33
|
-
|
34
|
+
sh_vars
|
35
|
+
travis-conditions!
|
34
36
|
|
35
37
|
BUNDLED WITH
|
36
|
-
|
38
|
+
2.0.2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'sh_vars'
|
2
2
|
|
3
3
|
module Travis
|
4
4
|
module Conditions
|
@@ -13,7 +13,9 @@ module Travis
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def env(key)
|
16
|
-
data.fetch(:env, {})[key.to_sym]
|
16
|
+
value = data.fetch(:env, {})[key.to_sym]
|
17
|
+
value = value.gsub(/^(["'])(.*)\1$/, '\2') if value.respond_to?(:gsub)
|
18
|
+
value
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -55,9 +57,9 @@ module Travis
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def parse(str)
|
58
|
-
vars =
|
60
|
+
vars = ShVars::String.new(str).parse
|
59
61
|
vars.map { |lft, rgt| [lft, cast(unquote(rgt))] }
|
60
|
-
rescue
|
62
|
+
rescue ShVars::ParseError
|
61
63
|
puts "[travis-conditions] Cannot normalize env var (#{str.inspect} given)"
|
62
64
|
[]
|
63
65
|
end
|
data/spec/v1/conditions_spec.rb
CHANGED
@@ -32,19 +32,26 @@ describe Travis::Conditions::V1, 'real conditions' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context do
|
35
|
-
let(:
|
35
|
+
let(:cond) do
|
36
36
|
%(
|
37
37
|
repo = iribeyri/travis-experiments
|
38
38
|
AND type != pull_request
|
39
39
|
AND (branch = master OR tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$)
|
40
40
|
)
|
41
41
|
end
|
42
|
-
it { expect { described_class.parse(
|
42
|
+
it { expect { described_class.parse(cond) }.to_not raise_error }
|
43
43
|
end
|
44
44
|
|
45
45
|
context do
|
46
46
|
let(:subject) { described_class.parse(cond) }
|
47
47
|
let(:cond) { 'commit_message !~ concat("[skip", env(TRAVIS_JOB_NAME), "]")' }
|
48
|
-
it { expect {
|
48
|
+
it { expect { described_class.parse(cond) }.to_not raise_error }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'quoted env var' do
|
52
|
+
let(:cond) { 'branch = env(FOO)' }
|
53
|
+
let(:data) { { branch: 'foo', env: [FOO: '"foo"'] } }
|
54
|
+
subject { described_class.eval(cond, data) }
|
55
|
+
it { should be true }
|
49
56
|
end
|
50
57
|
end
|
data/spec/v1/data_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Travis::Conditions::V1::Data do
|
|
12
12
|
it { expect(subject.env('FOO')).to eq 'foo' }
|
13
13
|
end
|
14
14
|
|
15
|
-
describe 'given an env array' do
|
15
|
+
describe 'given an env array of strings' do
|
16
16
|
describe 'with a single var' do
|
17
17
|
let(:env) { ['FOO=foo'] }
|
18
18
|
it { expect(subject.env(:FOO)).to eq 'foo' }
|
@@ -63,6 +63,44 @@ describe Travis::Conditions::V1::Data do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
describe 'given an env array of hashes' do
|
67
|
+
describe 'with a single var' do
|
68
|
+
let(:env) { [FOO: 'foo'] }
|
69
|
+
it { expect(subject.env(:FOO)).to eq 'foo' }
|
70
|
+
it { expect(subject.env('FOO')).to eq 'foo' }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'given a double quoted string' do
|
75
|
+
let(:env) { [FOO: '"foo"'] }
|
76
|
+
it { expect(subject.env(:FOO)).to eq 'foo' }
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'given a single quoted string' do
|
80
|
+
let(:env) { [FOO: "'foo'"] }
|
81
|
+
it { expect(subject.env(:FOO)).to eq 'foo' }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'given a string with an unbalanced double quote at the beginning' do
|
85
|
+
let(:env) { [FOO: '"foo'] }
|
86
|
+
it { expect(subject.env(:FOO)).to eq '"foo' }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'given a string with an unbalanced double quote at the end' do
|
90
|
+
let(:env) { [FOO: 'foo"'] }
|
91
|
+
it { expect(subject.env(:FOO)).to eq 'foo"' }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'given a string with an unbalanced single quote at the beginning' do
|
95
|
+
let(:env) { [FOO: "'foo"] }
|
96
|
+
it { expect(subject.env(:FOO)).to eq "'foo" }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'given a string with an unbalanced single quote at the end' do
|
100
|
+
let(:env) { [FOO: "foo'"] }
|
101
|
+
it { expect(subject.env(:FOO)).to eq "foo'" }
|
102
|
+
end
|
103
|
+
|
66
104
|
describe 'given a string without an = it raises an ArgumentError' do
|
67
105
|
let(:env) { 'foo' }
|
68
106
|
xit { expect { subject }.to raise_error Travis::Conditions::ArgumentError, 'Invalid env data ("foo" given)' }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'travis/conditions/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "travis-conditions"
|
9
|
+
s.version = Travis::Conditions::VERSION
|
10
|
+
s.authors = ["Travis CI"]
|
11
|
+
s.email = "contact@travis-ci.org"
|
12
|
+
s.homepage = "https://github.com/travis-ci/travis-conditions"
|
13
|
+
s.summary = "Boolean language for conditional builds, stages, jobs"
|
14
|
+
s.licenses = ['MIT']
|
15
|
+
|
16
|
+
s.files = Dir['{bin/**/*,lib/**/*,spec/**/*,[A-Z]*}']
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
s.require_path = 'lib'
|
19
|
+
s.executables << 'travis-conditions'
|
20
|
+
|
21
|
+
s.add_dependency 'sh_vars', '~> 1.0.2'
|
22
|
+
s.add_dependency 'parslet', '~> 1.8.2'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-conditions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis CI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sh_vars
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: parslet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.8.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.8.2
|
41
41
|
description:
|
42
42
|
email: contact@travis-ci.org
|
43
43
|
executables:
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- spec/v1/parser/var_spec.rb
|
98
98
|
- spec/v1/parser_spec.rb
|
99
99
|
- spec/v1/user_spec.rb
|
100
|
+
- travis-conditions.gemspec
|
100
101
|
homepage: https://github.com/travis-ci/travis-conditions
|
101
102
|
licenses:
|
102
103
|
- MIT
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.6.
|
121
|
+
rubygems_version: 2.6.11
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Boolean language for conditional builds, stages, jobs
|