expansions 0.4.33 → 0.4.35
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 -5
- data/lib/expansions/file_merge.rb +1 -1
- data/lib/expansions/template_visitor.rb +23 -17
- data/lib/expansions/version.rb +1 -1
- data/spec/specs/file_merge_spec.rb +2 -2
- data/spec/specs/kernel_spec.rb +2 -2
- data/spec/specs/template_visitor_spec.rb +23 -4
- metadata +7 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1eb812bc08443b3690124ff06b7c3160bf53f1b5119a4729133fe0b0c7fadc3
|
4
|
+
data.tar.gz: 4dd15f72d8ea0889e1d3e3527cba52f951b7a56a27bd787de5772a660e9743a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9faf85ebb12b2f665cda089e6de19ba745bd82a392d260e68753db1c6726edc829c6f10e590b406c04be787bad00ec46373f3d9aa23844db916a51cb88490eb1
|
7
|
+
data.tar.gz: 921a5edaeb87e6e6406ca9c1c3c2c55eabc08c0886144097e4959b8cca35cab52a62db9652da70b21c9f766a1b1571955d26815d0230a5e655f929eefdc580b6
|
@@ -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
@@ -7,7 +7,7 @@ module Expansions
|
|
7
7
|
let(:output_file){"out_file.rb"}
|
8
8
|
let(:sut){FileMerge.new(output_file)}
|
9
9
|
before (:each) do
|
10
|
-
File.stub(:
|
10
|
+
File.stub(:exist?).with(file).and_return(true)
|
11
11
|
end
|
12
12
|
context "and it is not already in the list" do
|
13
13
|
before (:each) do
|
@@ -36,7 +36,7 @@ module Expansions
|
|
36
36
|
let(:output_file){"out_file.rb"}
|
37
37
|
let(:sut){FileMerge.new(output_file)}
|
38
38
|
before (:each) do
|
39
|
-
File.stub(:
|
39
|
+
File.stub(:exist?).with(file).and_return(true)
|
40
40
|
end
|
41
41
|
|
42
42
|
before (:each) do
|
data/spec/specs/kernel_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe Expansions do
|
|
27
27
|
|
28
28
|
context "and no block is given" do
|
29
29
|
before (:each) do
|
30
|
-
@result = glob(File.join(RelativeFileSystem.base_path,"
|
30
|
+
@result = glob(File.join(RelativeFileSystem.base_path,"**/**"))
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should return all files in path" do
|
@@ -41,7 +41,7 @@ describe Expansions do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
before (:each) do
|
44
|
-
@result = glob(File.join(RelativeFileSystem.base_path,"
|
44
|
+
@result = glob(File.join(RelativeFileSystem.base_path,"**/*")) do |file|
|
45
45
|
@items_visited += 1
|
46
46
|
end
|
47
47
|
end
|
@@ -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.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Develop With Passion®
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configatron
|
@@ -112,7 +112,7 @@ homepage: http://www.developwithpassion.com
|
|
112
112
|
licenses:
|
113
113
|
- MIT
|
114
114
|
metadata: {}
|
115
|
-
post_install_message:
|
115
|
+
post_install_message:
|
116
116
|
rdoc_options: []
|
117
117
|
require_paths:
|
118
118
|
- lib
|
@@ -127,26 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
|
131
|
-
|
132
|
-
signing_key:
|
130
|
+
rubygems_version: 3.3.7
|
131
|
+
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: Simple Expansion Automation Utility
|
135
|
-
test_files:
|
136
|
-
- spec/spec_helper.rb
|
137
|
-
- spec/specs/array_spec.rb
|
138
|
-
- spec/specs/configuration_spec.rb
|
139
|
-
- spec/specs/copy_spec.rb
|
140
|
-
- spec/specs/copy_to_target_spec.rb
|
141
|
-
- spec/specs/enumerable_extensions_spec.rb
|
142
|
-
- spec/specs/erb_template_file_spec.rb
|
143
|
-
- spec/specs/expansion_spec.rb
|
144
|
-
- spec/specs/file_merge_spec.rb
|
145
|
-
- spec/specs/file_spec.rb
|
146
|
-
- spec/specs/kernel_spec.rb
|
147
|
-
- spec/specs/mustache_template_file_spec.rb
|
148
|
-
- spec/specs/shell_action_against_file_spec.rb
|
149
|
-
- spec/specs/string_spec.rb
|
150
|
-
- spec/specs/template_processors_spec.rb
|
151
|
-
- spec/specs/template_visitor_spec.rb
|
152
|
-
has_rdoc:
|
134
|
+
test_files: []
|