expansions 0.4.33 → 0.4.34
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 +4 -4
- data/lib/expansions/template_visitor.rb +23 -17
- data/lib/expansions/version.rb +1 -1
- data/spec/specs/template_visitor_spec.rb +23 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6046ae97940c3fab57fa282f1d0ff83d98a9fbb7
|
|
4
|
+
data.tar.gz: 61944c393d2e5b01345dd0034bababe455f23cc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c9ba5a75fd6dc2e1929a3c98e7193d543d83af160d2b42581bca1b6003f2040ab5947c78ecf481a885ce208b26923f46af842bafad508da4a6a71f1b42bed6a
|
|
7
|
+
data.tar.gz: be8ddabe704ba220a48866dfe497c59c01485284f5982c4332c5f0995b0182d9595d17e3d942c1266d2f118972935721b0981933771b6ab58a151af27b056934
|
|
@@ -11,28 +11,34 @@ module Expansions
|
|
|
11
11
|
|
|
12
12
|
def run_using(file_name)
|
|
13
13
|
processor = processors.get_processor_for(file_name)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
load_settings_file(File.dirname(file_name), generated_name)
|
|
18
|
-
|
|
19
|
-
generated_name = generated_name.gsub(DOT_FILE_PATTERN, "")
|
|
20
|
-
|
|
21
|
-
generated_name = ".#{generated_name}" if (DOT_FILE_PATTERN =~ file_name)
|
|
22
|
-
|
|
23
|
-
output = File.join(File.dirname(file_name),generated_name)
|
|
24
|
-
|
|
14
|
+
names = get_file_names(file_name)
|
|
15
|
+
load_settings_file(names[:settings_file])
|
|
16
|
+
output = names[:output_file_name]
|
|
25
17
|
file.delete(output) if file.exists?(output)
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
begin
|
|
20
|
+
processor.process(:input => file_name,:output => output)
|
|
21
|
+
rescue Exception => e
|
|
22
|
+
raise "Error processing template file: #{file_name}"
|
|
23
|
+
end
|
|
28
24
|
end
|
|
29
25
|
|
|
30
|
-
def
|
|
31
|
-
|
|
26
|
+
def get_file_names(file_name)
|
|
27
|
+
base_name = File.basename(file_name, File.extname(file_name))
|
|
28
|
+
dir_name = File.dirname(file_name)
|
|
29
|
+
generated_name = base_name.gsub(DOT_FILE_PATTERN, "")
|
|
30
|
+
generated_name = ".#{generated_name}" if (DOT_FILE_PATTERN =~ file_name)
|
|
31
|
+
output_file_name = File.join(dir_name, generated_name)
|
|
32
|
+
settings_file = File.join(dir_name, "#{base_name}.settings")
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
settings_file: settings_file,
|
|
36
|
+
output_file_name: output_file_name
|
|
37
|
+
}
|
|
38
|
+
end
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
end
|
|
40
|
+
def load_settings_file(settings_file)
|
|
41
|
+
load settings_file if File.exist?(settings_file)
|
|
36
42
|
end
|
|
37
43
|
end
|
|
38
44
|
end
|
data/lib/expansions/version.rb
CHANGED
|
@@ -20,7 +20,6 @@ module Expansions
|
|
|
20
20
|
context "and the generated file already exists" do
|
|
21
21
|
let(:file_name){"some.file"}
|
|
22
22
|
before (:each) do
|
|
23
|
-
the_processor.stub(:remove_template_extension_from).and_return(file_name)
|
|
24
23
|
file.stub(:exists?).with("./some.file").and_return(true)
|
|
25
24
|
end
|
|
26
25
|
|
|
@@ -34,7 +33,6 @@ module Expansions
|
|
|
34
33
|
context "and the generated file does not already exists" do
|
|
35
34
|
let(:file_name){"some.file"}
|
|
36
35
|
before (:each) do
|
|
37
|
-
the_processor.stub(:remove_template_extension_from).and_return(file_name)
|
|
38
36
|
file.stub(:exists?).with("./some.file").and_return(false)
|
|
39
37
|
end
|
|
40
38
|
|
|
@@ -53,7 +51,6 @@ module Expansions
|
|
|
53
51
|
|
|
54
52
|
before (:each) do
|
|
55
53
|
registry.stub(:get_processor_for).and_return(the_processor)
|
|
56
|
-
the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc.dotfile")
|
|
57
54
|
end
|
|
58
55
|
before (:each) do
|
|
59
56
|
sut.run_using(file_name)
|
|
@@ -69,7 +66,6 @@ module Expansions
|
|
|
69
66
|
|
|
70
67
|
before (:each) do
|
|
71
68
|
registry.stub(:get_processor_for).and_return(the_processor)
|
|
72
|
-
the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc")
|
|
73
69
|
end
|
|
74
70
|
before (:each) do
|
|
75
71
|
sut.run_using(file_name)
|
|
@@ -79,6 +75,29 @@ module Expansions
|
|
|
79
75
|
the_processor.should have_received_message(:process,:input => file_name,:output => "blah/bashrc")
|
|
80
76
|
end
|
|
81
77
|
end
|
|
78
|
+
|
|
79
|
+
context "and the template processor throw an exception" do
|
|
80
|
+
let(:file_name){"blah/bashrc.erb"}
|
|
81
|
+
let(:options){{}}
|
|
82
|
+
let(:inner) { Exception.new("This is an error") }
|
|
83
|
+
|
|
84
|
+
before (:each) do
|
|
85
|
+
registry.stub(:get_processor_for).and_return(the_processor)
|
|
86
|
+
the_processor.stub(:process).throws(inner)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
before (:each) do
|
|
90
|
+
begin
|
|
91
|
+
sut.run_using(file_name)
|
|
92
|
+
rescue Exception => e
|
|
93
|
+
@error = e
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should rethrow the exception with details of the file that could not be transformed" do
|
|
98
|
+
expect(@error.message).to match(/Error processing/)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
82
101
|
end
|
|
83
102
|
end
|
|
84
103
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: expansions
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Develop With Passion®
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: configatron
|