travis-config 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01e2ead5a4c4320d76ba27ab1ddadfb1e38ad084
4
- data.tar.gz: 9259351d3b135e6177042cfe48ed67169c3399d8
3
+ metadata.gz: 0ef1a02277339c9c3f8f26ace76974090635ca7f
4
+ data.tar.gz: 2b874c972e135d322e470e6758390c59ed23b6c2
5
5
  SHA512:
6
- metadata.gz: 2108e59adca723d5ea77c9ec0637161635c917f43c7c9626ab76b1065369c3bf41c05fdcf7f9121123fcee537aafcd2ccfcf8f54b9f384f3ea5817b52c40e0a1
7
- data.tar.gz: 71807a6d9e917136adc15af1017476cca9f180cc04e822afe30118f99fefa84d74cb8629e66651e9eee05abd7c2f4bd9a48d6cffd33e4803c5e3f0c88ca7f093
6
+ metadata.gz: 34d9a4d344e3a683dcc128732a015d77b24ce7b749236d9e0535908bb9268c4e7afeba743e1857d1f758fdc923961ff524a6a57a15b3e6a76fc6b76cbd8c7d92
7
+ data.tar.gz: e6dad88f4181ec55a9669d350e3df5e8171ecb3301f2a653e04b5fc20b7d5af71f1536e8181f87b773ff55763c98d28035535237b4fac3abfd6483c59364b2d5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- travis-config (1.0.2)
4
+ travis-config (1.0.3)
5
5
  hashr (~> 2.0.0)
6
6
 
7
7
  GEM
@@ -28,16 +28,25 @@ module Travis
28
28
  end
29
29
 
30
30
  def amqp
31
- compact(Url.parse(ENV['RABBITMQ_URL'] || ENV['RABBITMQ_BIGWIG_URL']).to_h) # rabbitmq-bigwig add-ons can only be attached as RABBITMQ_BIGWIG
31
+ compact(Url.parse(amqp_url).to_h)
32
32
  end
33
33
 
34
34
  def redis
35
- compact(url: ENV['REDIS_URL'])
35
+ compact(url: redis_url)
36
36
  end
37
37
 
38
38
  def memcached
39
39
  Memcached.new.config
40
40
  end
41
+
42
+ def amqp_url
43
+ # rabbitmq-bigwig add-ons can only be attached as RABBITMQ_BIGWIG
44
+ ENV['TRAVIS_RABBITMQ_URL'] || ENV['RABBITMQ_URL'] || ENV['RABBITMQ_BIGWIG_URL']
45
+ end
46
+
47
+ def redis_url
48
+ ENV['TRAVIS_REDIS_URL'] || ENV['REDIS_URL']
49
+ end
41
50
  end
42
51
  end
43
52
  end
@@ -6,27 +6,24 @@ module Travis
6
6
  class Database < Struct.new(:options)
7
7
  include Helpers
8
8
 
9
- DEFAULTS = { adapter: 'postgresql', encoding: 'unicode', application_name: ENV['DYNO'] || $0 }
9
+ VARIABLES = { application_name: ENV['DYNO'] || $0, statement_timeout: 10_000 }
10
+ DEFAULTS = { adapter: 'postgresql', encoding: 'unicode', variables: VARIABLES }
10
11
 
11
12
  def config
12
- config = parse_url
13
- config = DEFAULTS.merge(config) unless config.empty?
13
+ config = compact(Url.parse(url).to_h)
14
+ config = deep_merge(DEFAULTS, config) unless config.empty?
14
15
  config[:pool] = pool.to_i if pool
15
16
  config
16
17
  end
17
18
 
18
19
  private
19
20
 
20
- def parse_url
21
- compact(Url.parse(url).to_h)
21
+ def url
22
+ env('TRAVIS_DATABASE_URL', 'DATABASE_URL').compact.first
22
23
  end
23
24
 
24
25
  def pool
25
- env('DB_POOL', 'DATABASE_POOL_SIZE').compact.first
26
- end
27
-
28
- def url
29
- env('DATABASE_URL').compact.first
26
+ env('TRAVIS_DATABASE_POOL_SIZE', 'DATABASE_POOL_SIZE', 'DB_POOL').compact.first
30
27
  end
31
28
 
32
29
  def env(*keys)
@@ -1,3 +1,3 @@
1
1
  module TravisConfig
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -1,21 +1,36 @@
1
1
  describe Travis::Config::Heroku, :Database do
2
2
  let(:config) { Travis::Test::Config.load(:heroku) }
3
- let(:vars) { %w(DATABASE_URL DB_POOL DATABASE_POOL_SIZE LOGS_DATABASE_URL LOGS_DB_POOL LOGS_DATABASE_POOL_SIZE DYNO) }
3
+ let(:vars) { %w(TRAVIS_DATABASE_URL DATABASE_URL DB_POOL TRAVIS_DATABASE_POOL_SIZE DATABASE_POOL_SIZE LOGS_DATABASE_URL LOGS_DB_POOL LOGS_DATABASE_POOL_SIZE DYNO) }
4
4
  after { vars.each { |key| ENV.delete(key) } }
5
5
  before { ENV['DYNO'] = 'app_name' }
6
6
 
7
+ it 'loads a TRAVIS_DATABASE_URL with a port' do
8
+ ENV['TRAVIS_DATABASE_URL'] = 'postgres://username:password@hostname:1234/database'
9
+
10
+ expect(config.database.to_h).to eq(
11
+ adapter: 'postgresql',
12
+ host: 'hostname',
13
+ port: 1234,
14
+ database: 'database',
15
+ username: 'username',
16
+ password: 'password',
17
+ encoding: 'unicode',
18
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
19
+ )
20
+ end
21
+
7
22
  it 'loads a DATABASE_URL with a port' do
8
23
  ENV['DATABASE_URL'] = 'postgres://username:password@hostname:1234/database'
9
24
 
10
25
  expect(config.database.to_h).to eq(
11
- application_name: 'travis-config/specs',
12
- adapter: 'postgresql',
13
- host: 'hostname',
14
- port: 1234,
15
- database: 'database',
16
- username: 'username',
17
- password: 'password',
18
- encoding: 'unicode'
26
+ adapter: 'postgresql',
27
+ host: 'hostname',
28
+ port: 1234,
29
+ database: 'database',
30
+ username: 'username',
31
+ password: 'password',
32
+ encoding: 'unicode',
33
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
19
34
  )
20
35
  end
21
36
 
@@ -23,30 +38,30 @@ describe Travis::Config::Heroku, :Database do
23
38
  ENV['DATABASE_URL'] = 'postgres://username:password@hostname/database'
24
39
 
25
40
  expect(config.database.to_h).to eq(
26
- application_name: 'travis-config/specs',
27
- adapter: 'postgresql',
28
- host: 'hostname',
29
- database: 'database',
30
- username: 'username',
31
- password: 'password',
32
- encoding: 'unicode'
41
+ adapter: 'postgresql',
42
+ host: 'hostname',
43
+ database: 'database',
44
+ username: 'username',
45
+ password: 'password',
46
+ encoding: 'unicode',
47
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
33
48
  )
34
49
  end
35
50
 
36
- it 'loads DB_POOL' do
51
+ it 'loads DATABASE_POOL_SIZE' do
37
52
  ENV['DATABASE_URL'] = 'postgres://username:password@hostname:1234/database'
38
- ENV['DB_POOL'] = '25'
53
+ ENV['DATABASE_POOL_SIZE'] = '25'
39
54
 
40
55
  expect(config.database.to_h).to eq(
41
- application_name: 'travis-config/specs',
42
- adapter: 'postgresql',
43
- host: 'hostname',
44
- port: 1234,
45
- database: 'database',
46
- username: 'username',
47
- password: 'password',
48
- encoding: 'unicode',
49
- pool: 25
56
+ adapter: 'postgresql',
57
+ host: 'hostname',
58
+ port: 1234,
59
+ database: 'database',
60
+ username: 'username',
61
+ password: 'password',
62
+ encoding: 'unicode',
63
+ pool: 25,
64
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
50
65
  )
51
66
  end
52
67
 
@@ -55,15 +70,32 @@ describe Travis::Config::Heroku, :Database do
55
70
  ENV['DATABASE_POOL_SIZE'] = '25'
56
71
 
57
72
  expect(config.database.to_h).to eq(
58
- application_name: 'travis-config/specs',
59
- adapter: 'postgresql',
60
- host: 'hostname',
61
- port: 1234,
62
- database: 'database',
63
- username: 'username',
64
- password: 'password',
65
- encoding: 'unicode',
66
- pool: 25
73
+ adapter: 'postgresql',
74
+ host: 'hostname',
75
+ port: 1234,
76
+ database: 'database',
77
+ username: 'username',
78
+ password: 'password',
79
+ encoding: 'unicode',
80
+ pool: 25,
81
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
82
+ )
83
+ end
84
+
85
+ it 'loads DB_POOL' do
86
+ ENV['DATABASE_URL'] = 'postgres://username:password@hostname:1234/database'
87
+ ENV['DB_POOL'] = '25'
88
+
89
+ expect(config.database.to_h).to eq(
90
+ adapter: 'postgresql',
91
+ host: 'hostname',
92
+ port: 1234,
93
+ database: 'database',
94
+ username: 'username',
95
+ password: 'password',
96
+ encoding: 'unicode',
97
+ pool: 25,
98
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
67
99
  )
68
100
  end
69
101
 
@@ -71,14 +103,14 @@ describe Travis::Config::Heroku, :Database do
71
103
  ENV['LOGS_DATABASE_URL'] = 'postgres://username:password@hostname:1234/logs_database'
72
104
 
73
105
  expect(config.logs_database.to_h).to eq(
74
- application_name: 'travis-config/specs',
75
- adapter: 'postgresql',
76
- host: 'hostname',
77
- port: 1234,
78
- database: 'logs_database',
79
- username: 'username',
80
- password: 'password',
81
- encoding: 'unicode'
106
+ adapter: 'postgresql',
107
+ host: 'hostname',
108
+ port: 1234,
109
+ database: 'logs_database',
110
+ username: 'username',
111
+ password: 'password',
112
+ encoding: 'unicode',
113
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
82
114
  )
83
115
  end
84
116
 
@@ -86,13 +118,13 @@ describe Travis::Config::Heroku, :Database do
86
118
  ENV['LOGS_DATABASE_URL'] = 'postgres://username:password@hostname/logs_database'
87
119
 
88
120
  expect(config.logs_database.to_h).to eq(
89
- application_name: 'travis-config/specs',
90
- adapter: 'postgresql',
91
- host: 'hostname',
92
- database: 'logs_database',
93
- username: 'username',
94
- password: 'password',
95
- encoding: 'unicode'
121
+ adapter: 'postgresql',
122
+ host: 'hostname',
123
+ database: 'logs_database',
124
+ username: 'username',
125
+ password: 'password',
126
+ encoding: 'unicode',
127
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
96
128
  )
97
129
  end
98
130
 
@@ -101,15 +133,15 @@ describe Travis::Config::Heroku, :Database do
101
133
  ENV['LOGS_DB_POOL'] = '1'
102
134
 
103
135
  expect(config.logs_database.to_h).to eq(
104
- application_name: 'travis-config/specs',
105
- adapter: 'postgresql',
106
- host: 'hostname',
107
- port: 1234,
108
- database: 'logs_database',
109
- username: 'username',
110
- password: 'password',
111
- encoding: 'unicode',
112
- pool: 1
136
+ adapter: 'postgresql',
137
+ host: 'hostname',
138
+ port: 1234,
139
+ database: 'logs_database',
140
+ username: 'username',
141
+ password: 'password',
142
+ encoding: 'unicode',
143
+ pool: 1,
144
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
113
145
  )
114
146
  end
115
147
 
@@ -118,15 +150,15 @@ describe Travis::Config::Heroku, :Database do
118
150
  ENV['LOGS_DATABASE_POOL_SIZE'] = '25'
119
151
 
120
152
  expect(config.logs_database.to_h).to eq(
121
- application_name: 'travis-config/specs',
122
- adapter: 'postgresql',
123
- host: 'hostname',
124
- port: 1234,
125
- database: 'logs_database',
126
- username: 'username',
127
- password: 'password',
128
- encoding: 'unicode',
129
- pool: 25
153
+ adapter: 'postgresql',
154
+ host: 'hostname',
155
+ port: 1234,
156
+ database: 'logs_database',
157
+ username: 'username',
158
+ password: 'password',
159
+ encoding: 'unicode',
160
+ pool: 25,
161
+ variables: { application_name: 'travis-config/specs', statement_timeout: 10_000 }
130
162
  )
131
163
  end
132
164
 
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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis CI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashr