rake-funnel 0.0.1.pre → 0.0.2.pre

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: d13cf1a193e9b4f8f63bf3845a7b9e3411dc6b77
4
- data.tar.gz: 83dcbb1be8a17e1b7b8b6065a69868d550ca2c71
3
+ metadata.gz: 534bce3208ca29cf25f9e04b4938c6167db9410c
4
+ data.tar.gz: 823fb7a0a61e1bf89860fbe20ad2aacd86839779
5
5
  SHA512:
6
- metadata.gz: a082174a5f60488ae61a0319fbc0e793073b92f7a5363161d9f57e28ef86325ed51d6d953824d132b9f31d11596700d7978e6931abcfdf8a3c9c572d5a197738
7
- data.tar.gz: 1bb7a3277da0c4c7a0b49f411abea297bc3fae354fbce34bbddc056dcdc71109ec695439a2a7d2a48018d3ae70bab20207b7e678720e8f30525a6d30a876818a
6
+ metadata.gz: 6dd1a16051c0acd07de377b14b8417ebf53517f379cd4c2d9e176ebf53e780f0823feaddaa31641b544db1cf69d23c92ac120b109c1608c871e68ceb021b47be
7
+ data.tar.gz: fac23dfb383cada38f8eb1c76d39e63680848bb402506fbb1eba621ca75a10cd60f3772b30cccf062120941989a8236f2cb332e0e54786ca4ac71ff12fa77fb9
@@ -17,7 +17,7 @@ module Rake::Funnel::Tasks::EnvironmentsSupport
17
17
  operation = 'Merging'
18
18
 
19
19
  yaml = File.read(file)
20
- yaml = ERB.new(yaml).result
20
+ yaml = evaluate_erb(yaml, file)
21
21
  yaml = YAML.load(yaml) || {}
22
22
  store.configure_from_hash(yaml)
23
23
  end
@@ -28,6 +28,12 @@ module Rake::Funnel::Tasks::EnvironmentsSupport
28
28
  log(store.inspect)
29
29
  end
30
30
 
31
+ def evaluate_erb(yaml, filename)
32
+ render = ERB.new(yaml)
33
+ render.filename = filename
34
+ render.result
35
+ end
36
+
31
37
  private
32
38
  def log(message)
33
39
  Rake.rake_output_message(message)
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.0.1.pre'
3
+ VERSION = '0.0.2.pre'
4
4
  end
5
5
  end
@@ -1,12 +1,24 @@
1
1
  describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
2
- describe 'loading configuration' do
3
- let(:config) {
4
- {
5
- name: 'environment name',
6
- config_files: config_files.keys.map(&:to_s)
7
- }
2
+ let(:store) {
3
+ double(Configatron::Store).as_null_object
4
+ }
5
+
6
+ let(:config) {
7
+ {
8
+ name: 'environment name',
9
+ config_files: config_files.keys.map(&:to_s)
8
10
  }
11
+ }
9
12
 
13
+ before {
14
+ config_files.each do |file, content|
15
+ allow(File).to receive(:read).with(file.to_s).and_return(content)
16
+ end
17
+
18
+ allow(Rake).to receive(:rake_output_message)
19
+ }
20
+
21
+ describe 'loading configuration' do
10
22
  let(:config_files) {
11
23
  {
12
24
  one: 'one: 23',
@@ -14,18 +26,6 @@ describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
14
26
  }
15
27
  }
16
28
 
17
- let(:store) {
18
- double(Configatron::Store).as_null_object
19
- }
20
-
21
- before {
22
- config_files.each do |file, content|
23
- allow(File).to receive(:read).with(file.to_s).and_return(content)
24
- end
25
-
26
- allow(Rake).to receive(:rake_output_message)
27
- }
28
-
29
29
  before {
30
30
  described_class.load_configuration(config, store)
31
31
  }
@@ -98,17 +98,36 @@ describe Rake::Funnel::Tasks::EnvironmentsSupport::Loader do
98
98
  expect(store).to have_received(:configure_from_hash).with({})
99
99
  end
100
100
  end
101
+ end
101
102
 
102
- context 'config file with ERb' do
103
+ describe 'config file with ERb' do
104
+ context 'ERb success' do
103
105
  let(:config_files) {
104
106
  {
105
107
  with_erb: 'foo: <%= 40 + 2 %>'
106
108
  }
107
109
  }
108
110
 
111
+ before {
112
+ described_class.load_configuration(config, store)
113
+ }
114
+
109
115
  it 'should evaluate ERb' do
110
116
  expect(store).to have_received(:configure_from_hash).with({ 'foo' => 42 })
111
117
  end
112
118
  end
119
+
120
+ context 'ERb failure' do
121
+ let(:config_files) {
122
+ {
123
+ with_erb: 'bogus: <%= 42 + "a" %>'
124
+ }
125
+ }
126
+
127
+ it 'should report file name' do
128
+ expect(lambda { described_class.load_configuration(config, store) })
129
+ .to raise_error { |ex| expect(ex.backtrace.join("\n")).to match(/with_erb/) }
130
+ end
131
+ end
113
132
  end
114
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-funnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
4
+ version: 0.0.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Groß