dice_bag 0.8.0 → 0.9.0
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 +5 -13
- data/lib/dice_bag/configuration.rb +22 -1
- data/lib/dice_bag/templates/newrelic.yml.dice +1 -1
- data/lib/dice_bag/version.rb +1 -1
- data/spec/command_spec.rb +1 -1
- data/spec/configuration_spec.rb +61 -0
- data/spec/spec_helper.rb +0 -1
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjBkY2RhMWU0ZTI0ZWMzMDhiM2JkMTczYmRhYmIzYWIwYWU2YTFjYg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60e5efa65c58bb068ea937851e75ace6470f3b0c
|
4
|
+
data.tar.gz: 56c46bf21478f61b2af8e5a3d689fc0204a4ef73
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTc2OGZjZTI2ZjcwYjQ2YTA3YjA5YWEyZDg5ZDBlMmE1MDNhM2EwMmI4YWY5
|
11
|
-
ZmNhZWRhZWYxMzNjZmFhMjVjMDExMmRiOWY3ZWMzODkyYTVhM2U=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDJlZGIzNDgzMWIzMDhkYTJlYzJlMGU4Y2NiYWQ3ZDYxMmQxZWU4NGFjOGRm
|
14
|
-
MzdhYzhhM2ZjMmZlMjM1MWNiZDdhNmZiN2VjMzc1NDU3YTgxODQ3MjY2Yjll
|
15
|
-
ZTI5MjMwMThlMzJlYzM3ZGQ0NGZjMDY2NjgxOWVmMzJiMzJkMjY=
|
6
|
+
metadata.gz: 27e0e05915afc78875d92a57a1587f5efd75282f9985c124f28f6cbd59db012e77e75d2b51e97e8ab6d11ca5917774c0a1641c98a928d2d9ab63e704c6fb9df7
|
7
|
+
data.tar.gz: 95970fb430a7b7fac1c662d6b27033d5db905be6598f9aea21bc802366e1d19345241c62af9fa1a49dd307723cd134b49240f574cb6c0dca038b33ec514c8fd0
|
@@ -16,7 +16,28 @@ module DiceBag
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def method_missing(name)
|
19
|
-
|
19
|
+
if name.to_s.end_with?('!')
|
20
|
+
ensured_in_production(name)
|
21
|
+
else
|
22
|
+
ENV[name.to_s.upcase]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def ensured_in_production(name)
|
29
|
+
variable_name = name.to_s.chomp('!').upcase
|
30
|
+
value = ENV[variable_name]
|
31
|
+
if in_production? && value.nil?
|
32
|
+
raise "Environment variable #{variable_name} required in production but it was not provided"
|
33
|
+
end
|
34
|
+
value
|
35
|
+
end
|
36
|
+
|
37
|
+
def in_production?
|
38
|
+
(defined?(Rails) && Rails.env.production?) ||
|
39
|
+
(defined?(Sinatra) && Sinatra::Application.production?) ||
|
40
|
+
ENV['RACK_ENV'] == 'production'
|
20
41
|
end
|
21
42
|
|
22
43
|
# This class acts like +Configuration+ but with a prefix applied to the
|
@@ -5,7 +5,7 @@ common: &default_settings
|
|
5
5
|
app_name: <%= configured.domain || 'PROJECT_NAME' %>
|
6
6
|
enabled: <%= configured.enable_newrelic || false %>
|
7
7
|
log_level: <%= configured.new_relic_debug == 'true' ? 'debug' : 'info' %>
|
8
|
-
ssl:
|
8
|
+
ssl: true
|
9
9
|
apdex_t: 0.5
|
10
10
|
capture_params: false
|
11
11
|
transaction_tracer:
|
data/lib/dice_bag/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dice_bag/configuration'
|
3
|
+
module DiceBag
|
4
|
+
|
5
|
+
shared_examples_for 'configuration in production' do
|
6
|
+
it 'returns values ending in ! available in the environment' do
|
7
|
+
expect(Configuration.new.test_var!).to eq(value)
|
8
|
+
end
|
9
|
+
it 'returns values not ending in ! not available in the environment' do
|
10
|
+
expect(Configuration.new.idontexist).to eq(nil)
|
11
|
+
end
|
12
|
+
it 'raises an exception when the value ends in ! and is not available in the environment' do
|
13
|
+
expect{Configuration.new.idontexist!}.to raise_exception(StandardError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
RSpec.describe Configuration do
|
19
|
+
let(:value) { '42' }
|
20
|
+
before(:each) do
|
21
|
+
ENV['TEST_VAR'] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns values" do
|
25
|
+
expect(Configuration.new.test_var).to eq(value)
|
26
|
+
end
|
27
|
+
it "returns values ending in !" do
|
28
|
+
expect(Configuration.new.test_var!).to eq(value)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'Running in Rails production environment' do
|
32
|
+
before(:each) do
|
33
|
+
rails = class_double('Rails')
|
34
|
+
allow(rails).to receive_message_chain("env.production?") { true }
|
35
|
+
stub_const("Rails", rails)
|
36
|
+
end
|
37
|
+
it_behaves_like 'configuration in production'
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'Running in Sinatra production environment' do
|
41
|
+
before(:each) do
|
42
|
+
sinatra = class_double('Sinatra')
|
43
|
+
allow(sinatra).to receive(:production?).and_return(true)
|
44
|
+
stub_const("Sinatra::Application", sinatra)
|
45
|
+
end
|
46
|
+
it_behaves_like 'configuration in production'
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'Running in a rack app production environment' do
|
50
|
+
# Not the most elegant but given how much we use ENV in these tests, does seem good enough
|
51
|
+
before(:each) do
|
52
|
+
ENV['RACK_ENV'] = 'production'
|
53
|
+
end
|
54
|
+
after(:each) do
|
55
|
+
ENV['RACK_ENV'] = nil
|
56
|
+
end
|
57
|
+
it_behaves_like 'configuration in production'
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dice_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
@@ -9,67 +9,65 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: aruba
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 0.5.1
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.5.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '3.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
description:
|
71
|
-
of The Twelve-Factor App. It also provides continuous integration tasks that rely
|
72
|
-
on the configuration tasks.
|
70
|
+
description:
|
73
71
|
email:
|
74
72
|
- asmith@mdsol.com
|
75
73
|
- jcarres@mdsol.com
|
@@ -100,10 +98,10 @@ files:
|
|
100
98
|
- lib/dice_bag/version.rb
|
101
99
|
- lib/dice_bag/warning.rb
|
102
100
|
- spec/command_spec.rb
|
101
|
+
- spec/configuration_spec.rb
|
103
102
|
- spec/spec_helper.rb
|
104
103
|
homepage: https://github.com/mdsol/dice_bag
|
105
|
-
licenses:
|
106
|
-
- MIT
|
104
|
+
licenses: []
|
107
105
|
metadata: {}
|
108
106
|
post_install_message:
|
109
107
|
rdoc_options: []
|
@@ -111,12 +109,12 @@ require_paths:
|
|
111
109
|
- lib
|
112
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
111
|
requirements:
|
114
|
-
- -
|
112
|
+
- - ">="
|
115
113
|
- !ruby/object:Gem::Version
|
116
114
|
version: '0'
|
117
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
116
|
requirements:
|
119
|
-
- -
|
117
|
+
- - ">="
|
120
118
|
- !ruby/object:Gem::Version
|
121
119
|
version: '0'
|
122
120
|
requirements: []
|
@@ -129,5 +127,6 @@ summary: Dice Bag is a library of rake tasks for configuring web apps in the sty
|
|
129
127
|
on the configuration tasks.
|
130
128
|
test_files:
|
131
129
|
- spec/command_spec.rb
|
130
|
+
- spec/configuration_spec.rb
|
132
131
|
- spec/spec_helper.rb
|
133
132
|
has_rdoc:
|