expansions 0.0.6
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.
- data/.gitignore +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/README.md +61 -0
- data/Rakefile +1 -0
- data/bin/expansions +4 -0
- data/expansions.gemspec +29 -0
- data/lib/core/array.rb +8 -0
- data/lib/core/cli_interface.rb +39 -0
- data/lib/core/copy.rb +19 -0
- data/lib/core/copy_to_target.rb +11 -0
- data/lib/core/enumerable_extensions.rb +11 -0
- data/lib/core/erb_template_file.rb +31 -0
- data/lib/core/expansion.rb +79 -0
- data/lib/core/file.rb +32 -0
- data/lib/core/file_merge.rb +45 -0
- data/lib/core/kernel.rb +35 -0
- data/lib/core/log.rb +15 -0
- data/lib/core/mustache_template_file.rb +9 -0
- data/lib/core/shell.rb +7 -0
- data/lib/core/shell_action_against_file.rb +10 -0
- data/lib/core/string.rb +5 -0
- data/lib/core/template_processors.rb +22 -0
- data/lib/core/template_visitor.rb +18 -0
- data/lib/core/version.rb +3 -0
- data/lib/expansions.rb +24 -0
- data/spec/spec_helper.rb +50 -0
- data/spec/specs/array_spec.rb +20 -0
- data/spec/specs/copy_spec.rb +87 -0
- data/spec/specs/copy_to_target_spec.rb +22 -0
- data/spec/specs/enumerable_extensions_spec.rb +27 -0
- data/spec/specs/erb_template_file_spec.rb +63 -0
- data/spec/specs/expansion_spec.rb +107 -0
- data/spec/specs/file_merge_spec.rb +131 -0
- data/spec/specs/file_spec.rb +79 -0
- data/spec/specs/kernel_spec.rb +56 -0
- data/spec/specs/mustache_template_file_spec.rb +48 -0
- data/spec/specs/shell_action_against_file_spec.rb +22 -0
- data/spec/specs/string_spec.rb +11 -0
- data/spec/specs/template_processors_spec.rb +62 -0
- data/spec/specs/template_visitor_spec.rb +84 -0
- metadata +215 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Expansions
|
4
|
+
describe TemplateProcessors do
|
5
|
+
context "when a template processor is registered" do
|
6
|
+
context "and there is not already a processor registered for the template type" do
|
7
|
+
let(:first_processor){fake}
|
8
|
+
let(:processors){{}}
|
9
|
+
let(:sut){TemplateProcessors.new(processors)}
|
10
|
+
before (:each) do
|
11
|
+
sut.register_processor(:erb,first_processor)
|
12
|
+
end
|
13
|
+
it "should be added to the list or processors" do
|
14
|
+
processors[:erb].should == first_processor
|
15
|
+
end
|
16
|
+
end
|
17
|
+
context "and there is already a processor registered for the template type" do
|
18
|
+
let(:first_processor){fake}
|
19
|
+
let(:processors){{}}
|
20
|
+
let(:sut){TemplateProcessors.new(processors)}
|
21
|
+
before (:each) do
|
22
|
+
processors[:erb] = first_processor
|
23
|
+
end
|
24
|
+
before (:each) do
|
25
|
+
@exception = catch_exception{sut.register_processor(:erb,fake)}
|
26
|
+
end
|
27
|
+
it "should raise an error" do
|
28
|
+
(/exist/ =~ @exception.message).should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not change the processor" do
|
32
|
+
processors[:erb].should == first_processor
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
context "when getting the processor for a template" do
|
37
|
+
let(:first_processor){fake}
|
38
|
+
let(:processors){{}}
|
39
|
+
let(:sut){TemplateProcessors.new(processors)}
|
40
|
+
before (:each) do
|
41
|
+
processors[:erb] = first_processor
|
42
|
+
end
|
43
|
+
context "and it exists" do
|
44
|
+
before (:each) do
|
45
|
+
@result = sut.get_processor_for("blah.erb")
|
46
|
+
end
|
47
|
+
it "should return the processor to the caller" do
|
48
|
+
@result.should == first_processor
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "and it does not exists" do
|
53
|
+
before (:each) do
|
54
|
+
@exception = catch_exception{sut.get_processor_for("blah.txt")}
|
55
|
+
end
|
56
|
+
it "should raise an error" do
|
57
|
+
(/no process/ =~ @exception.message).should be_true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Expansions
|
4
|
+
describe TemplateVisitor do
|
5
|
+
let(:all_templates){[]}
|
6
|
+
let(:registry){fake}
|
7
|
+
let(:file){fake}
|
8
|
+
let(:args){{:processor_registry => registry,:file => file}}
|
9
|
+
let(:the_processor){fake}
|
10
|
+
let(:sut){TemplateVisitor.new(args)}
|
11
|
+
before (:each) do
|
12
|
+
TemplateProcessors.stub(:instance).and_return(nil)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when processing a template" do
|
16
|
+
before (:each) do
|
17
|
+
registry.stub(:get_processor_for).and_return(the_processor)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "and the generated file already exists" do
|
21
|
+
let(:file_name){"some.file"}
|
22
|
+
before (:each) do
|
23
|
+
the_processor.stub(:remove_template_extension_from).and_return(file_name)
|
24
|
+
file.stub(:exists?).with("./some.file").and_return(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
before (:each) do
|
28
|
+
sut.run_using("some.file.name")
|
29
|
+
end
|
30
|
+
it "should delete the original file" do
|
31
|
+
file.should have_received(:delete,"./#{file_name}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context "and the generated file does not already exists" do
|
35
|
+
let(:file_name){"some.file"}
|
36
|
+
before (:each) do
|
37
|
+
the_processor.stub(:remove_template_extension_from).and_return(file_name)
|
38
|
+
file.stub(:exists?).with("./some.file").and_return(false)
|
39
|
+
end
|
40
|
+
|
41
|
+
before (:each) do
|
42
|
+
sut.run_using(file_name)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not try to delete the original file" do
|
46
|
+
file.should_not have_received(:delete)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "that represents a dotfile" do
|
51
|
+
let(:file_name){"blah/bashrc.dotfile.erb"}
|
52
|
+
let(:options){{}}
|
53
|
+
|
54
|
+
before (:each) do
|
55
|
+
registry.stub(:get_processor_for).and_return(the_processor)
|
56
|
+
the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc.dotfile")
|
57
|
+
end
|
58
|
+
before (:each) do
|
59
|
+
sut.run_using(file_name)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should tell the template to be expanded to a file with dotfile naming conventions" do
|
63
|
+
the_processor.should have_received(:process,:input => file_name,:output => "blah/.bashrc")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
context "that represents a non dotfile" do
|
67
|
+
let(:file_name){"blah/bashrc.erb"}
|
68
|
+
let(:options){{}}
|
69
|
+
|
70
|
+
before (:each) do
|
71
|
+
registry.stub(:get_processor_for).and_return(the_processor)
|
72
|
+
the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc")
|
73
|
+
end
|
74
|
+
before (:each) do
|
75
|
+
sut.run_using(file_name)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should tell the template to be expanded to a file without the template name" do
|
79
|
+
the_processor.should have_received(:process,:input => file_name,:output => "blah/bashrc")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: expansions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Develop With Passion®
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard-rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fakes-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-notifu
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: configatron
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.9.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.9.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: mustache
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: developwithpassion_arrays
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Automation utitlity that I use to support cross platform file maintenance
|
127
|
+
email:
|
128
|
+
- open_source@developwithpassion.com
|
129
|
+
executables:
|
130
|
+
- expansions
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- .rvmrc
|
136
|
+
- Gemfile
|
137
|
+
- Guardfile
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/expansions
|
141
|
+
- expansions.gemspec
|
142
|
+
- lib/core/array.rb
|
143
|
+
- lib/core/cli_interface.rb
|
144
|
+
- lib/core/copy.rb
|
145
|
+
- lib/core/copy_to_target.rb
|
146
|
+
- lib/core/enumerable_extensions.rb
|
147
|
+
- lib/core/erb_template_file.rb
|
148
|
+
- lib/core/expansion.rb
|
149
|
+
- lib/core/file.rb
|
150
|
+
- lib/core/file_merge.rb
|
151
|
+
- lib/core/kernel.rb
|
152
|
+
- lib/core/log.rb
|
153
|
+
- lib/core/mustache_template_file.rb
|
154
|
+
- lib/core/shell.rb
|
155
|
+
- lib/core/shell_action_against_file.rb
|
156
|
+
- lib/core/string.rb
|
157
|
+
- lib/core/template_processors.rb
|
158
|
+
- lib/core/template_visitor.rb
|
159
|
+
- lib/core/version.rb
|
160
|
+
- lib/expansions.rb
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
- spec/specs/array_spec.rb
|
163
|
+
- spec/specs/copy_spec.rb
|
164
|
+
- spec/specs/copy_to_target_spec.rb
|
165
|
+
- spec/specs/enumerable_extensions_spec.rb
|
166
|
+
- spec/specs/erb_template_file_spec.rb
|
167
|
+
- spec/specs/expansion_spec.rb
|
168
|
+
- spec/specs/file_merge_spec.rb
|
169
|
+
- spec/specs/file_spec.rb
|
170
|
+
- spec/specs/kernel_spec.rb
|
171
|
+
- spec/specs/mustache_template_file_spec.rb
|
172
|
+
- spec/specs/shell_action_against_file_spec.rb
|
173
|
+
- spec/specs/string_spec.rb
|
174
|
+
- spec/specs/template_processors_spec.rb
|
175
|
+
- spec/specs/template_visitor_spec.rb
|
176
|
+
homepage: http://www.developwithpassion.com
|
177
|
+
licenses: []
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project: expansions
|
196
|
+
rubygems_version: 1.8.21
|
197
|
+
signing_key:
|
198
|
+
specification_version: 3
|
199
|
+
summary: Simple Expansion Automation Utility
|
200
|
+
test_files:
|
201
|
+
- spec/spec_helper.rb
|
202
|
+
- spec/specs/array_spec.rb
|
203
|
+
- spec/specs/copy_spec.rb
|
204
|
+
- spec/specs/copy_to_target_spec.rb
|
205
|
+
- spec/specs/enumerable_extensions_spec.rb
|
206
|
+
- spec/specs/erb_template_file_spec.rb
|
207
|
+
- spec/specs/expansion_spec.rb
|
208
|
+
- spec/specs/file_merge_spec.rb
|
209
|
+
- spec/specs/file_spec.rb
|
210
|
+
- spec/specs/kernel_spec.rb
|
211
|
+
- spec/specs/mustache_template_file_spec.rb
|
212
|
+
- spec/specs/shell_action_against_file_spec.rb
|
213
|
+
- spec/specs/string_spec.rb
|
214
|
+
- spec/specs/template_processors_spec.rb
|
215
|
+
- spec/specs/template_visitor_spec.rb
|