travis-conditions 1.0.12 → 1.0.13

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: bcc052238888d66a8cd6e573129090c78a3c45e4
4
- data.tar.gz: 1ee9d4f0a792f3075531380001e6ec944336b47a
3
+ metadata.gz: 508161e7fcdb5f6b5fa7f6b62d286e8e86b5e9bc
4
+ data.tar.gz: eef0be00cbef1f64ef60679949a835307697a988
5
5
  SHA512:
6
- metadata.gz: aad2cbd038e0e36758058f06452ff2e1968cf074801175f9bb04919761a8669ba290961384de88081312bdf6a9340401b0d4ac78b0c08c42686d3d2834b1250c
7
- data.tar.gz: a4b885612b3727d7380e57b680a863027478e36cdeb90f0e8d7005011b3c8952262623e98f5dbcfe71d1959951e34e382a6f34df9a2f7b9b7b9b4f3a90b1c68d
6
+ metadata.gz: aaa3cbd52975af87be2348c3778bcfa91c8e8dc71b7713bb3d91ffbcff8e8d372a9f9eb72aedf8b9c8bec6810e8b350f166d429b2bc29f1ac5d3d3370704933f
7
+ data.tar.gz: 8041e836d7fd63a78c8f4fcdb217b9ce88f8264538c4b72caaca56de341edbfacc5876f18ca220c6b05c75cfb6e0976ab6af74d4432f44af20393f9e05c45b33
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.13
4
+
5
+ ### Fixed
6
+
7
+ - Do not raise an ArgumentError if env() was used with a missing argument
8
+
3
9
  ## v1.0.12
4
10
 
5
11
  ### Fixed
@@ -9,11 +9,11 @@ module Travis
9
9
  end
10
10
 
11
11
  def [](key)
12
- data[key.to_sym]
12
+ data[key&.to_sym]
13
13
  end
14
14
 
15
15
  def env(key)
16
- value = data.fetch(:env, {})[key.to_sym]
16
+ value = data.fetch(:env, {})[key&.to_sym]
17
17
  value = value.gsub(/^(["'])(.*)\1$/, '\2') if value.respond_to?(:gsub)
18
18
  value
19
19
  end
@@ -78,7 +78,7 @@ module Travis
78
78
  send(name.to_s.downcase, *args.map { |arg| evl(arg) })
79
79
  end
80
80
 
81
- def env(key)
81
+ def env(key = nil)
82
82
  data.env(key)
83
83
  end
84
84
 
@@ -54,7 +54,7 @@ module Travis
54
54
  include Boolean, Helper
55
55
 
56
56
  VAR = /type|repo|head_repo|os|dist|group|sudo|language|sender|fork|
57
- branch|head_branch|tag|commit_message/ix
57
+ branch|head_branch|tag|commit_message/x
58
58
 
59
59
  PRED = /present|blank|true|false/i
60
60
  FUNC = /env|concat/i
@@ -1,5 +1,5 @@
1
1
  module Travis
2
2
  module Conditions
3
- VERSION = '1.0.12'
3
+ VERSION = '1.0.13'
4
4
  end
5
5
  end
@@ -62,10 +62,24 @@ describe Travis::Conditions::V1, 'real conditions' do
62
62
  it { should be true }
63
63
  end
64
64
 
65
+ describe 'env vars as hashes' do
66
+ let(:cond) { "repo = env(REPO)" }
67
+ let(:data) { { repo: 'owner/name', env: [REPO: 'owner/name'] } }
68
+ subject { described_class.eval(cond, data) }
69
+ it { should be true }
70
+ end
71
+
65
72
  describe 'missing env var' do
66
73
  let(:cond) { 'branch =~ env(PATTERN)' }
67
74
  let(:data) { { branch: 'master', env: [] } }
68
75
  subject { described_class.eval(cond, data) }
69
76
  it { should be false }
70
77
  end
78
+
79
+ describe 'missing argument' do
80
+ let(:cond) { 'branch = env()' }
81
+ let(:data) { { branch: 'master' } }
82
+ subject { described_class.eval(cond, data) }
83
+ it { should be false }
84
+ end
71
85
  end
@@ -24,6 +24,11 @@ describe Travis::Conditions::V1::Parser do
24
24
  [:call, :env, [[:val, 'FOO']]]
25
25
  end
26
26
 
27
+ it 'env()' do
28
+ should eq \
29
+ [:call, :env, []]
30
+ end
31
+
27
32
  # one operand
28
33
 
29
34
  it '1=1' do
@@ -476,6 +481,10 @@ describe Travis::Conditions::V1::Parser do
476
481
  [:eq, [:var, :type], [:val, 'buz']]]]
477
482
  end
478
483
 
484
+ it '= foo' do
485
+ expect { subject }.to raise_error(Travis::Conditions::ParseError)
486
+ end
487
+
479
488
  it 'branch = $FOO' do
480
489
  expect { subject }.to raise_error(Travis::Conditions::ParseError)
481
490
  end
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.12
4
+ version: 1.0.13
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-03-12 00:00:00.000000000 Z
11
+ date: 2020-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sh_vars