travis-config 1.0.8 → 1.0.9

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: 67de0f0017df11901eb406bc43cf6b7ad52f4857
4
- data.tar.gz: 05b1962b2089d429cf1c62196167b8c1520e2069
3
+ metadata.gz: ece7b075d7cfafadd4396a14bbe84fbdac918b0e
4
+ data.tar.gz: 8e676abb5ced7f60cd329393eec3569404649ed3
5
5
  SHA512:
6
- metadata.gz: 5ae88bf2d9be78bc13914f2ef22069a55eb4da7ade28e6281d9ffda974bc642cc93b8ea2485334fbc552bef39acd65e7840fa96f459b7bfede6e6096e2bf8426
7
- data.tar.gz: d50ac580463df69f5662f7dfcf17ba772f67f012499a4807d5a9194ef4c1302e5fd315e9562498c11c9aaa54edcc6cb5cfda9b337076fe640c73c2ff9eef1ffc
6
+ metadata.gz: 317b2e96faa0bd261834a517f0337f764bcb4b2f4b527fa83091e14c155613fc993ab4f5bf0578409f1cd7d651ff5f31a2ffb8b8712811ea428dc8fea9ba0cee
7
+ data.tar.gz: 08d4f9ebd80a763543d62370b847c4eb0bd2552632adc5650c26183a351c5a7e3e0e853223c2fa0c77f9f9f55e94d9872d74958a1516eae3f811750619053915
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- travis-config (1.0.7)
4
+ travis-config (1.0.8)
5
5
  hashr (~> 2.0.0)
6
6
 
7
7
  GEM
@@ -17,7 +17,9 @@ module Travis
17
17
  end
18
18
 
19
19
  def load(*names)
20
- new(load_from(*names))
20
+ config = load_from(*names)
21
+ config = normalize(config)
22
+ new(config)
21
23
  end
22
24
 
23
25
  private
@@ -32,6 +34,11 @@ module Travis
32
34
  names = [:files, :env, :heroku, :docker] if names.empty?
33
35
  names.map { |name| const_get(camelize(name)).new }
34
36
  end
37
+
38
+ def normalize(config)
39
+ config[:logs_database] = config[:database] if blank?(config[:logs_database])
40
+ config
41
+ end
35
42
  end
36
43
 
37
44
  def env
@@ -1,6 +1,6 @@
1
1
  module Travis
2
2
  class Config
3
- class Env
3
+ class Env # TODO rename to keychain
4
4
  def load
5
5
  ENV['travis_config'] ? YAML.load(ENV['travis_config']) : {}
6
6
  end
@@ -34,7 +34,7 @@ module Travis
34
34
  end
35
35
 
36
36
  def blank?(obj)
37
- obj.respond_to?(:empty?) ? !!obj.empty? : !obj
37
+ obj.respond_to?(:empty?) ? obj.empty? : !obj
38
38
  end
39
39
 
40
40
  def camelize(string)
@@ -4,7 +4,7 @@ require 'travis/config/heroku/memcached'
4
4
 
5
5
  module Travis
6
6
  class Config
7
- class Heroku
7
+ class Heroku # TODO rename to EnvVar
8
8
  include Helpers
9
9
 
10
10
  def load
@@ -24,8 +24,7 @@ module Travis
24
24
  end
25
25
 
26
26
  def logs_database
27
- config = Database.new(prefix: 'logs').config
28
- config.empty? ? database : config
27
+ Database.new(prefix: 'logs').config
29
28
  end
30
29
 
31
30
  def amqp
@@ -1,3 +1,3 @@
1
1
  module TravisConfig
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
  end
@@ -193,22 +193,7 @@ describe Travis::Config::Heroku, :Database do
193
193
  )
194
194
  end
195
195
 
196
- it 'defaults logs_database to database if no other config is given' do
197
- ENV['DATABASE_URL'] = 'postgres://username:password@hostname:1234/logs_database'
198
-
199
- expect(config.logs_database.to_h).to eq(
200
- adapter: 'postgresql',
201
- host: 'hostname',
202
- port: 1234,
203
- database: 'logs_database',
204
- username: 'username',
205
- password: 'password',
206
- encoding: 'unicode',
207
- variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
208
- )
209
- end
210
-
211
- it 'sets logs_database to nil if no DATABASE_URL and no LOGS_DATABASE_URL is given' do
196
+ it 'sets logs_database to nil if no LOGS_DATABASE_URL is given' do
212
197
  expect(config.logs_database).to be_nil
213
198
  end
214
199
  end
@@ -47,9 +47,31 @@ describe Travis::Config do
47
47
  end
48
48
  end
49
49
 
50
-
51
50
  it 'deep symbolizes arrays, too' do
52
51
  config = Travis::Config.new('queues' => [{ 'slug' => 'rails/rails', 'queue' => 'rails' }])
53
52
  expect(config.queues.first.values_at(:slug, :queue)).to eq(['rails/rails', 'rails'])
54
53
  end
54
+
55
+ describe 'logs_database config' do
56
+ before { ENV['DATABASE_URL'] = 'postgres://username:password@hostname:1234/database' }
57
+ after { ENV['DATABASE_URL'] = nil }
58
+
59
+ describe 'given logs_database is defined in a config file' do
60
+ before do
61
+ Dir.stubs(:[]).returns ['config/travis.yml']
62
+ YAML.stubs(:load_file).with('config/travis.yml').returns('test' => { 'logs_database' => { 'database' => 'config_file' } })
63
+ end
64
+ it { expect(config.logs_database.database).to eq 'config_file' }
65
+ end
66
+
67
+ describe 'given logs_database is defined in the keychain' do
68
+ before { ENV['travis_config'] = YAML.dump('logs_database' => { 'database' => 'keychain' }) }
69
+ after { ENV['travis_config'] = nil }
70
+ it { expect(config.logs_database.database).to eq 'keychain' }
71
+ end
72
+
73
+ describe 'given logs_database is not defined anywhere it defaults to database' do
74
+ it { expect(config.logs_database.database).to eq 'database' }
75
+ end
76
+ end
55
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis CI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-16 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashr