travis-conditions 1.0.10 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dedeb04bec488371ab045739237bff10a34ca15a
4
- data.tar.gz: 7a4c46f91e0238bc78b6819afe98aa76d9d1f6d3
3
+ metadata.gz: 1f5550042752d66fdf3b72b0d9c0990e3f09c954
4
+ data.tar.gz: a408b3f617cf6754abb579856f26ba2de9487da5
5
5
  SHA512:
6
- metadata.gz: a72f8c330507570e4f013da10c68dba03cc6023815dc53059e73a15294a829aff544d0d6229dee3594bb0a52b47fc6c00aa6f00a372844b04197f14e50026ae5
7
- data.tar.gz: 6b23fe2e7795cc6bdbf70c22cb7dce52e46a5f28fb734223f94c2aeb09f4215ae230feb759147c6688bb2bfd7bff7daac014dc9d5ff0715729a13567a11926c1
6
+ metadata.gz: e0ce5f91ec4bc825d987df57411f07313dca588042fc3bace4f8bd0ca6f8954851c74ed76356c720a27676bc4cc08382b5ac710e1ecaacbee8c71e93c12e86d0
7
+ data.tar.gz: dab76f7f8f8188b684c7e245370c5862b1585e6df00deef89b3131360af839f38e48ff757ee080884d0026c83a59643f2391d3cb6fa976015eb20becd2f26692
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.8
4
+
5
+ ### Fixed
6
+
7
+ - Do not raise Type Error when a missing env var is used as a regular expression
8
+
3
9
  ## v1.0.7
4
10
 
5
11
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- travis-conditions (1.0.9)
4
+ travis-conditions (1.0.10)
5
5
  parslet (~> 1.8.2)
6
6
  sh_vars (~> 1.0.2)
7
7
 
@@ -10,19 +10,19 @@ GEM
10
10
  specs:
11
11
  diff-lcs (1.3)
12
12
  parslet (1.8.2)
13
- rspec (3.6.0)
14
- rspec-core (~> 3.6.0)
15
- rspec-expectations (~> 3.6.0)
16
- rspec-mocks (~> 3.6.0)
17
- rspec-core (3.6.0)
18
- rspec-support (~> 3.6.0)
19
- rspec-expectations (3.6.0)
13
+ rspec (3.9.0)
14
+ rspec-core (~> 3.9.0)
15
+ rspec-expectations (~> 3.9.0)
16
+ rspec-mocks (~> 3.9.0)
17
+ rspec-core (3.9.1)
18
+ rspec-support (~> 3.9.1)
19
+ rspec-expectations (3.9.0)
20
20
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.6.0)
22
- rspec-mocks (3.6.0)
21
+ rspec-support (~> 3.9.0)
22
+ rspec-mocks (3.9.1)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.6.0)
25
- rspec-support (3.6.0)
24
+ rspec-support (~> 3.9.0)
25
+ rspec-support (3.9.2)
26
26
  sh_vars (1.0.2)
27
27
 
28
28
  PLATFORMS
@@ -34,7 +34,8 @@ module Travis
34
34
  end
35
35
 
36
36
  def match(lft, rgt)
37
- evl(lft) =~ evl(rgt)
37
+ lft, rgt = evl(lft), evl(rgt)
38
+ lft && rgt && lft =~ rgt
38
39
  end
39
40
 
40
41
  def not_match(lft, rgt)
@@ -63,7 +64,8 @@ module Travis
63
64
  end
64
65
 
65
66
  def reg(expr)
66
- Regexp.new(evl(expr))
67
+ str = evl(expr)
68
+ Regexp.new(str) if str
67
69
  end
68
70
 
69
71
  def var(name)
@@ -1,5 +1,5 @@
1
1
  module Travis
2
2
  module Conditions
3
- VERSION = '1.0.10'
3
+ VERSION = '1.0.11'
4
4
  end
5
5
  end
@@ -54,4 +54,18 @@ describe Travis::Conditions::V1, 'real conditions' do
54
54
  subject { described_class.eval(cond, data) }
55
55
  it { should be true }
56
56
  end
57
+
58
+ describe 'env vars as hashes' do
59
+ let(:cond) { 'repo = env(SLUG)' }
60
+ let(:data) { { repo: 'owner/name', env: [SLUG: 'owner/name'] } }
61
+ subject { described_class.eval(cond, data) }
62
+ it { should be true }
63
+ end
64
+
65
+ describe 'missing env var' do
66
+ let(:cond) { 'branch =~ env(PATTERN)' }
67
+ let(:data) { { branch: 'master', env: [] } }
68
+ subject { described_class.eval(cond, data) }
69
+ it { should be false }
70
+ end
57
71
  end
data/spec/v1/data_spec.rb CHANGED
@@ -69,6 +69,12 @@ describe Travis::Conditions::V1::Data do
69
69
  it { expect(subject.env(:FOO)).to eq 'foo' }
70
70
  it { expect(subject.env('FOO')).to eq 'foo' }
71
71
  end
72
+
73
+ describe 'with several vars' do
74
+ let(:env) { [{ FOO: 'foo' }, { BAR: 'bar' }] }
75
+ it { expect(subject.env(:BAR)).to eq 'bar' }
76
+ it { expect(subject.env('BAR')).to eq 'bar' }
77
+ end
72
78
  end
73
79
 
74
80
  describe 'given a double quoted string' do
data/spec/v1/eval_spec.rb CHANGED
@@ -173,6 +173,26 @@ describe Travis::Conditions::V1, 'eval' do
173
173
  let(:str) { 'env(foo) =~ concat("^", env(foo), "$")' }
174
174
  it { should be true }
175
175
  end
176
+
177
+ context do
178
+ let(:str) { 'env(missing) =~ str' }
179
+ it { should be false }
180
+ end
181
+
182
+ context do
183
+ let(:str) { 'str =~ env(missing)' }
184
+ it { should be false }
185
+ end
186
+
187
+ context do
188
+ let(:str) { 'env(missing) =~ ^.*$' }
189
+ it { should be false }
190
+ end
191
+
192
+ context do
193
+ let(:str) { '^.*$ =~ env(missing)' }
194
+ it { should be false }
195
+ end
176
196
  end
177
197
 
178
198
  describe 'in' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-conditions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis CI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2020-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sh_vars