travis-config 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/travis/config/env.rb +4 -4
- data/lib/travis/config/version.rb +1 -1
- data/spec/travis/config/env_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2db328b9fff6ec2788a6c6b297005601117a8045
|
4
|
+
data.tar.gz: 239d6c3e786ea50e771b22134c6c514ddc43e7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d43b9068219b5c555a713c631c81b862ef60b129646f11f3e7095a40783ef835a5f1128b51ebf3a7b3743b855eee6d86b2dea6601736b69762f781c77acf80
|
7
|
+
data.tar.gz: fd874e4d30b6ca7d298dd72b68fb2e26dcf6e8b2ea749b23530cb43bdf299960d69b92f851a81be2332b8625e340e2ec4e4a36b4b2879092bb645c1d11802f15
|
data/Gemfile.lock
CHANGED
data/lib/travis/config/env.rb
CHANGED
@@ -47,7 +47,7 @@ module Travis
|
|
47
47
|
key = key.map(&:upcase).join('_')
|
48
48
|
value = env.fetch(key, default)
|
49
49
|
raise UnexpectedString.new(key, value) if value.is_a?(String) && hashes?(default)
|
50
|
-
default.is_a?(Array) ? split(value) : cast(value)
|
50
|
+
default.is_a?(Array) ? split(value) : cast(value, default)
|
51
51
|
end
|
52
52
|
|
53
53
|
def vars(env, keys, default)
|
@@ -57,7 +57,7 @@ module Travis
|
|
57
57
|
vars.group_by(&:pop).values.map(&:to_h)
|
58
58
|
end
|
59
59
|
|
60
|
-
def cast(value)
|
60
|
+
def cast(value, default = nil)
|
61
61
|
case value
|
62
62
|
when /^[\d]+\.[\d]+$/
|
63
63
|
value.to_f
|
@@ -70,7 +70,7 @@ module Travis
|
|
70
70
|
when ''
|
71
71
|
nil
|
72
72
|
else
|
73
|
-
value
|
73
|
+
default.is_a?(Symbol) ? value.to_sym : value
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -85,7 +85,7 @@ module Travis
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.prefix(prefix = nil)
|
88
|
-
prefix ? @prefix = prefix : @prefix
|
88
|
+
prefix ? @prefix = prefix : @prefix ||= 'travis'
|
89
89
|
end
|
90
90
|
|
91
91
|
def load
|
@@ -2,6 +2,7 @@ module Travis::Test::Env
|
|
2
2
|
class Config < Travis::Config
|
3
3
|
define database: { adapter: nil, variables: { statement_timeout: nil } },
|
4
4
|
hash: { under_scored: nil, nested: { foo: nil } },
|
5
|
+
symbol: :foo,
|
5
6
|
integer: nil,
|
6
7
|
float: nil,
|
7
8
|
true: nil,
|
@@ -11,9 +12,6 @@ module Travis::Test::Env
|
|
11
12
|
no: nil,
|
12
13
|
off: nil,
|
13
14
|
nil: nil
|
14
|
-
|
15
|
-
|
16
|
-
Env.prefix :travis
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
@@ -23,6 +21,7 @@ describe Travis::Config::Env do
|
|
23
21
|
describe 'cast' do
|
24
22
|
env TRAVIS_HASH_UNDER_SCORED: 'under_scored',
|
25
23
|
TRAVIS_HASH_NESTED_FOO: 'foo',
|
24
|
+
TRAVIS_SYMBOL: 'bar',
|
26
25
|
TRAVIS_INTEGER: '10',
|
27
26
|
TRAVIS_FLOAT: '10.0',
|
28
27
|
TRAVIS_TRUE: 'true',
|
@@ -35,6 +34,7 @@ describe Travis::Config::Env do
|
|
35
34
|
|
36
35
|
it { expect(config.hash.under_scored).to eq 'under_scored' }
|
37
36
|
it { expect(config.hash.nested.foo).to eq 'foo' }
|
37
|
+
it { expect(config.symbol).to eq :bar }
|
38
38
|
it { expect(config.integer).to eq 10 }
|
39
39
|
it { expect(config.float).to eq 10.0 }
|
40
40
|
it { expect(config.true).to be true }
|