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