templater 0.1.6 → 0.2
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/README +13 -7
- data/Rakefile +30 -0
- data/lib/templater.rb +4 -2
- data/lib/templater/actions/action.rb +43 -0
- data/lib/templater/actions/empty_directory.rb +16 -14
- data/lib/templater/actions/file.rb +16 -21
- data/lib/templater/actions/template.rb +13 -22
- data/lib/templater/cli/generator.rb +13 -9
- data/lib/templater/core_ext/string.rb +1 -1
- data/lib/templater/description.rb +61 -0
- data/lib/templater/discovery.rb +16 -9
- data/lib/templater/generator.rb +115 -137
- data/lib/templater/spec/helpers.rb +1 -1
- data/spec/actions/empty_directory_spec.rb +105 -0
- data/spec/actions/file_spec.rb +112 -0
- data/spec/actions/template_spec.rb +141 -0
- data/spec/generator/actions_spec.rb +92 -43
- data/spec/generator/arguments_spec.rb +7 -3
- data/spec/generator/empty_directories_spec.rb +12 -4
- data/spec/generator/files_spec.rb +17 -26
- data/spec/generator/templates_spec.rb +17 -28
- data/spec/spec_helper.rb +24 -1
- metadata +18 -6
- data/lib/templater/proxy.rb +0 -62
- data/spec/empty_directory_spec.rb +0 -97
- data/spec/file_spec.rb +0 -97
- data/spec/template_spec.rb +0 -137
@@ -101,7 +101,7 @@ describe Templater::Generator, '.argument' do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should assign an argument when a block appended to an argument does not throw :invalid" do
|
104
|
-
@generator_class.argument(0, :monkey) do
|
104
|
+
@generator_class.argument(0, :monkey) do |argument|
|
105
105
|
1 + 1
|
106
106
|
end
|
107
107
|
@generator_class.argument(1, :elephant) do
|
@@ -118,8 +118,10 @@ describe Templater::Generator, '.argument' do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should raise an error with the throw message, when a block is appended to an argument and throws :invalid" do
|
121
|
-
@generator_class.argument(0, :monkey) do
|
122
|
-
|
121
|
+
@generator_class.argument(0, :monkey) do |argument|
|
122
|
+
if argument != 'monkey'
|
123
|
+
throw :invalid, 'this is not a valid monkey, bad monkey!'
|
124
|
+
end
|
123
125
|
end
|
124
126
|
|
125
127
|
lambda { @generator_class.new('/tmp', {}, 'blah') }.should raise_error(Templater::ArgumentError, 'this is not a valid monkey, bad monkey!')
|
@@ -127,6 +129,8 @@ describe Templater::Generator, '.argument' do
|
|
127
129
|
instance = @generator_class.new('/tmp')
|
128
130
|
|
129
131
|
lambda { instance.monkey = :anything }.should raise_error(Templater::ArgumentError, 'this is not a valid monkey, bad monkey!')
|
132
|
+
|
133
|
+
lambda { instance.monkey = 'monkey' }.should_not raise_error
|
130
134
|
end
|
131
135
|
|
132
136
|
end
|
@@ -26,8 +26,8 @@ describe Templater::Generator, ".empty_directory" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should add an empty directory with a block" do
|
29
|
-
@generator_class.empty_directory(:my_empty_directory) do
|
30
|
-
destination "gurr#{Process.pid.to_s}.rb"
|
29
|
+
@generator_class.empty_directory(:my_empty_directory) do |action|
|
30
|
+
action.destination = "gurr#{Process.pid.to_s}.rb"
|
31
31
|
end
|
32
32
|
@instance = @generator_class.new('/tmp/destination')
|
33
33
|
|
@@ -36,8 +36,8 @@ describe Templater::Generator, ".empty_directory" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should add an empty directory with a complex block" do
|
39
|
-
@generator_class.empty_directory(:my_empty_directory) do
|
40
|
-
destination 'gurr'
|
39
|
+
@generator_class.empty_directory(:my_empty_directory) do |action|
|
40
|
+
action.destination = 'gurr' / "gurr#{something}.rb"
|
41
41
|
end
|
42
42
|
@instance = @generator_class.new('/tmp/destination')
|
43
43
|
|
@@ -54,6 +54,14 @@ describe Templater::Generator, ".empty_directory" do
|
|
54
54
|
@instance.empty_directory(:my_empty_directory).destination.should == "/tmp/destination/template/%some_method%.rb"
|
55
55
|
@instance.empty_directory(:my_empty_directory).should be_an_instance_of(Templater::Actions::EmptyDirectory)
|
56
56
|
end
|
57
|
+
|
58
|
+
it "should pass options on to the empty_directory" do
|
59
|
+
@generator_class.empty_directory(:my_empty_directory, 'path/to/destination.rb', :before => :monkey, :after => :donkey)
|
60
|
+
@instance = @generator_class.new('/tmp/destination')
|
61
|
+
|
62
|
+
@instance.empty_directory(:my_empty_directory).options[:before].should == :monkey
|
63
|
+
@instance.empty_directory(:my_empty_directory).options[:after].should == :donkey
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
67
|
describe Templater::Generator, '#empty_directories' do
|
@@ -4,14 +4,13 @@ describe Templater::Generator, '.file' do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@generator_class = Class.new(Templater::Generator)
|
7
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
7
8
|
end
|
8
9
|
|
9
10
|
it "should add a file with source and destination" do
|
10
11
|
@generator_class.file(:my_template, 'path/to/source.rbt', 'path/to/destination.rb')
|
11
12
|
@instance = @generator_class.new('/tmp/destination')
|
12
13
|
|
13
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
14
|
-
|
15
14
|
@instance.file(:my_template).source.should == '/tmp/source/path/to/source.rbt'
|
16
15
|
@instance.file(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
17
16
|
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
@@ -21,36 +20,31 @@ describe Templater::Generator, '.file' do
|
|
21
20
|
@generator_class.file(:my_template, 'path/to/file.rb')
|
22
21
|
@instance = @generator_class.new('/tmp/destination')
|
23
22
|
|
24
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
25
|
-
|
26
23
|
@instance.file(:my_template).source.should == '/tmp/source/path/to/file.rb'
|
27
24
|
@instance.file(:my_template).destination.should == '/tmp/destination/path/to/file.rb'
|
28
25
|
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
29
26
|
end
|
30
27
|
|
31
28
|
it "should add a file with a block" do
|
32
|
-
@generator_class.file(:my_file) do
|
33
|
-
source 'blah.rbt'
|
34
|
-
destination "gurr#{Process.pid.to_s}.rb"
|
29
|
+
@generator_class.file(:my_file) do |file|
|
30
|
+
file.source = 'blah.rbt'
|
31
|
+
file.destination = "gurr#{Process.pid.to_s}.rb"
|
35
32
|
end
|
36
33
|
@instance = @generator_class.new('/tmp/destination')
|
37
34
|
|
38
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
39
|
-
|
40
35
|
@instance.file(:my_file).source.should == '/tmp/source/blah.rbt'
|
41
36
|
@instance.file(:my_file).destination.should == "/tmp/destination/gurr#{Process.pid.to_s}.rb"
|
42
37
|
@instance.file(:my_file).should be_an_instance_of(Templater::Actions::File)
|
43
38
|
end
|
44
39
|
|
45
40
|
it "should add a file with a complex block" do
|
46
|
-
@generator_class.file(:my_file) do
|
47
|
-
source 'blah'
|
48
|
-
destination 'gurr'
|
41
|
+
@generator_class.file(:my_file) do |file|
|
42
|
+
file.source = 'blah' / 'blah.rbt'
|
43
|
+
file.destination = 'gurr' / "gurr#{something}.rb"
|
49
44
|
end
|
50
45
|
@instance = @generator_class.new('/tmp/destination')
|
51
46
|
|
52
47
|
@instance.stub!(:something).and_return('anotherthing')
|
53
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
54
48
|
|
55
49
|
@instance.file(:my_file).source.should == '/tmp/source/blah/blah.rbt'
|
56
50
|
@instance.file(:my_file).destination.should == "/tmp/destination/gurr/gurranotherthing.rb"
|
@@ -61,7 +55,6 @@ describe Templater::Generator, '.file' do
|
|
61
55
|
@generator_class.file(:my_template, 'template/%some_method%.rbt', 'template/%another_method%.rb')
|
62
56
|
@instance = @generator_class.new('/tmp/destination')
|
63
57
|
|
64
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
65
58
|
@instance.should_not_receive(:some_method)
|
66
59
|
@instance.should_receive(:another_method).at_least(:once).and_return('beast')
|
67
60
|
|
@@ -74,11 +67,17 @@ describe Templater::Generator, '.file' do
|
|
74
67
|
@generator_class.file(:my_template, 'template/blah.rbt', 'template/%some_method%.rb')
|
75
68
|
@instance = @generator_class.new('/tmp/destination')
|
76
69
|
|
77
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
78
|
-
|
79
70
|
@instance.file(:my_template).destination.should == "/tmp/destination/template/%some_method%.rb"
|
80
71
|
@instance.file(:my_template).should be_an_instance_of(Templater::Actions::File)
|
81
72
|
end
|
73
|
+
|
74
|
+
it "should pass options on to the file" do
|
75
|
+
@generator_class.file(:my_template, 'path/to/destination.rb', :before => :monkey, :after => :donkey)
|
76
|
+
@instance = @generator_class.new('/tmp/destination')
|
77
|
+
|
78
|
+
@instance.file(:my_template).options[:before].should == :monkey
|
79
|
+
@instance.file(:my_template).options[:after].should == :donkey
|
80
|
+
end
|
82
81
|
end
|
83
82
|
|
84
83
|
describe Templater::Generator, '.file_list' do
|
@@ -116,11 +115,7 @@ describe Templater::Generator, '#files' do
|
|
116
115
|
|
117
116
|
before do
|
118
117
|
@generator_class = Class.new(Templater::Generator)
|
119
|
-
@generator_class.
|
120
|
-
def source_root
|
121
|
-
'/tmp/source'
|
122
|
-
end
|
123
|
-
end
|
118
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
124
119
|
end
|
125
120
|
|
126
121
|
it "should return all files" do
|
@@ -163,11 +158,7 @@ describe Templater::Generator, '#file' do
|
|
163
158
|
|
164
159
|
before do
|
165
160
|
@generator_class = Class.new(Templater::Generator)
|
166
|
-
@generator_class.
|
167
|
-
def source_root
|
168
|
-
'/tmp/source'
|
169
|
-
end
|
170
|
-
end
|
161
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
171
162
|
end
|
172
163
|
|
173
164
|
it "should find a file by name" do
|
@@ -4,14 +4,13 @@ describe Templater::Generator, '.template' do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@generator_class = Class.new(Templater::Generator)
|
7
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
7
8
|
end
|
8
9
|
|
9
10
|
it "should add a template with source and destination" do
|
10
11
|
@generator_class.template(:my_template, 'path/to/source.rbt', 'path/to/destination.rb')
|
11
12
|
@instance = @generator_class.new('/tmp/destination')
|
12
13
|
|
13
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
14
|
-
|
15
14
|
@instance.template(:my_template).source.should == '/tmp/source/path/to/source.rbt'
|
16
15
|
@instance.template(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
17
16
|
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
@@ -21,8 +20,6 @@ describe Templater::Generator, '.template' do
|
|
21
20
|
@generator_class.template(:my_template, '/path/to/source.rbt', '/path/to/destination.rb')
|
22
21
|
@instance = @generator_class.new('/tmp/destination')
|
23
22
|
|
24
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
25
|
-
|
26
23
|
@instance.template(:my_template).source.should == '/path/to/source.rbt'
|
27
24
|
@instance.template(:my_template).destination.should == '/path/to/destination.rb'
|
28
25
|
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
@@ -32,36 +29,31 @@ describe Templater::Generator, '.template' do
|
|
32
29
|
@generator_class.template(:my_template, 'path/to/destination.rb')
|
33
30
|
@instance = @generator_class.new('/tmp/destination')
|
34
31
|
|
35
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
36
|
-
|
37
32
|
@instance.template(:my_template).source.should == '/tmp/source/path/to/destination.rbt'
|
38
33
|
@instance.template(:my_template).destination.should == '/tmp/destination/path/to/destination.rb'
|
39
34
|
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
40
35
|
end
|
41
36
|
|
42
37
|
it "should add a template with a block" do
|
43
|
-
@generator_class.template(:my_template) do
|
44
|
-
source 'blah.rbt'
|
45
|
-
destination "gurr#{Process.pid.to_s}.rb"
|
38
|
+
@generator_class.template(:my_template) do |template|
|
39
|
+
template.source = 'blah.rbt'
|
40
|
+
template.destination = "gurr#{Process.pid.to_s}.rb"
|
46
41
|
end
|
47
42
|
@instance = @generator_class.new('/tmp/destination')
|
48
43
|
|
49
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
50
|
-
|
51
44
|
@instance.template(:my_template).source.should == '/tmp/source/blah.rbt'
|
52
45
|
@instance.template(:my_template).destination.should == "/tmp/destination/gurr#{Process.pid.to_s}.rb"
|
53
46
|
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
54
47
|
end
|
55
48
|
|
56
49
|
it "should add a template with a complex block" do
|
57
|
-
@generator_class.template(:my_template) do
|
58
|
-
source 'blah'
|
59
|
-
destination 'gurr'
|
50
|
+
@generator_class.template(:my_template) do |template|
|
51
|
+
template.source = 'blah' / 'blah.rbt'
|
52
|
+
template.destination = 'gurr' / "gurr#{something}.rb"
|
60
53
|
end
|
61
54
|
@instance = @generator_class.new('/tmp/destination')
|
62
55
|
|
63
56
|
@instance.stub!(:something).and_return('anotherthing')
|
64
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
65
57
|
|
66
58
|
@instance.template(:my_template).source.should == '/tmp/source/blah/blah.rbt'
|
67
59
|
@instance.template(:my_template).destination.should == "/tmp/destination/gurr/gurranotherthing.rb"
|
@@ -72,7 +64,6 @@ describe Templater::Generator, '.template' do
|
|
72
64
|
@generator_class.template(:my_template, 'template/%some_method%.rbt', 'template/%another_method%.rb')
|
73
65
|
@instance = @generator_class.new('/tmp/destination')
|
74
66
|
|
75
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
76
67
|
@instance.should_not_receive(:some_method)
|
77
68
|
@instance.should_receive(:another_method).at_least(:once).and_return('beast')
|
78
69
|
|
@@ -85,12 +76,18 @@ describe Templater::Generator, '.template' do
|
|
85
76
|
@generator_class.template(:my_template, 'template/blah.rbt', 'template/%some_method%.rb')
|
86
77
|
@instance = @generator_class.new('/tmp/destination')
|
87
78
|
|
88
|
-
@instance.stub!(:source_root).and_return('/tmp/source')
|
89
|
-
|
90
79
|
@instance.template(:my_template).destination.should == "/tmp/destination/template/%some_method%.rb"
|
91
80
|
@instance.template(:my_template).should be_an_instance_of(Templater::Actions::Template)
|
92
81
|
end
|
93
82
|
|
83
|
+
it "should pass options on to the template" do
|
84
|
+
@generator_class.template(:my_template, 'path/to/destination.rb', :before => :monkey, :after => :donkey)
|
85
|
+
@instance = @generator_class.new('/tmp/destination')
|
86
|
+
|
87
|
+
@instance.template(:my_template).options[:before].should == :monkey
|
88
|
+
@instance.template(:my_template).options[:after].should == :donkey
|
89
|
+
end
|
90
|
+
|
94
91
|
end
|
95
92
|
|
96
93
|
describe Templater::Generator, '.template_list' do
|
@@ -128,11 +125,7 @@ describe Templater::Generator, '#templates' do
|
|
128
125
|
|
129
126
|
before do
|
130
127
|
@generator_class = Class.new(Templater::Generator)
|
131
|
-
@generator_class.
|
132
|
-
def source_root
|
133
|
-
'/tmp/source'
|
134
|
-
end
|
135
|
-
end
|
128
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
136
129
|
end
|
137
130
|
|
138
131
|
it "should return all templates" do
|
@@ -175,11 +168,7 @@ describe Templater::Generator, '#template' do
|
|
175
168
|
|
176
169
|
before do
|
177
170
|
@generator_class = Class.new(Templater::Generator)
|
178
|
-
@generator_class.
|
179
|
-
def source_root
|
180
|
-
'/tmp/source'
|
181
|
-
end
|
182
|
-
end
|
171
|
+
@generator_class.stub!(:source_root).and_return('/tmp/source')
|
183
172
|
end
|
184
173
|
|
185
174
|
it "should find a template by name" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,4 +12,27 @@ end
|
|
12
12
|
require 'templater.rb'
|
13
13
|
require 'rubygems'
|
14
14
|
require 'spec'
|
15
|
-
require 'fileutils'
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
class MatchActionNames
|
18
|
+
def initialize(*names)
|
19
|
+
@names = names.map{|n| n.to_s}
|
20
|
+
end
|
21
|
+
|
22
|
+
def matches?(actual)
|
23
|
+
@actual = actual
|
24
|
+
@actual.map{|a| a.name.to_s}.sort == @names.sort
|
25
|
+
end
|
26
|
+
|
27
|
+
def failure_message
|
28
|
+
"expected #{@actual.inspect} to have action names #{@names.inspect}, but they didn't"
|
29
|
+
end
|
30
|
+
|
31
|
+
def negative_failure_message
|
32
|
+
"expected #{@actual.inspect} not to have action names #{@names.inspect}, but they did"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def have_names(*names)
|
37
|
+
MatchActionNames.new(*names)
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: templater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,7 +9,7 @@ autorequire: templater
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-09 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.1.2
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: extlib
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.5
|
44
|
+
version:
|
35
45
|
description: File generation system
|
36
46
|
email: jonas.nicklas@gmail.com
|
37
47
|
executables: []
|
@@ -49,6 +59,7 @@ files:
|
|
49
59
|
- TODO
|
50
60
|
- lib/templater
|
51
61
|
- lib/templater/actions
|
62
|
+
- lib/templater/actions/action.rb
|
52
63
|
- lib/templater/actions/empty_directory.rb
|
53
64
|
- lib/templater/actions/file.rb
|
54
65
|
- lib/templater/actions/template.rb
|
@@ -60,17 +71,19 @@ files:
|
|
60
71
|
- lib/templater/core_ext
|
61
72
|
- lib/templater/core_ext/kernel.rb
|
62
73
|
- lib/templater/core_ext/string.rb
|
74
|
+
- lib/templater/description.rb
|
63
75
|
- lib/templater/discovery.rb
|
64
76
|
- lib/templater/generator.rb
|
65
77
|
- lib/templater/manifold.rb
|
66
|
-
- lib/templater/proxy.rb
|
67
78
|
- lib/templater/spec
|
68
79
|
- lib/templater/spec/helpers.rb
|
69
80
|
- lib/templater.rb
|
81
|
+
- spec/actions
|
82
|
+
- spec/actions/empty_directory_spec.rb
|
83
|
+
- spec/actions/file_spec.rb
|
84
|
+
- spec/actions/template_spec.rb
|
70
85
|
- spec/core_ext
|
71
86
|
- spec/core_ext/string_spec.rb
|
72
|
-
- spec/empty_directory_spec.rb
|
73
|
-
- spec/file_spec.rb
|
74
87
|
- spec/generator
|
75
88
|
- spec/generator/actions_spec.rb
|
76
89
|
- spec/generator/arguments_spec.rb
|
@@ -97,7 +110,6 @@ files:
|
|
97
110
|
- spec/results/simple_erb.rbs
|
98
111
|
- spec/spec_helper.rb
|
99
112
|
- spec/spec_helpers_spec.rb
|
100
|
-
- spec/template_spec.rb
|
101
113
|
- spec/templater_spec.rb
|
102
114
|
- spec/templates
|
103
115
|
- spec/templates/erb.rbt
|
data/lib/templater/proxy.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module Templater
|
2
|
-
|
3
|
-
class Proxy #:nodoc:
|
4
|
-
|
5
|
-
def initialize(generator, action={})
|
6
|
-
@generator = generator
|
7
|
-
@block = action[:block]
|
8
|
-
@source, @destination = action[:source], action[:destination]
|
9
|
-
@name = action[:name]
|
10
|
-
end
|
11
|
-
|
12
|
-
def source(*source)
|
13
|
-
@source = ::File.join(*source)
|
14
|
-
end
|
15
|
-
|
16
|
-
def destination(*dest)
|
17
|
-
@destination = ::File.join(*dest)
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_template
|
21
|
-
instance_eval(&@block) if @block
|
22
|
-
Templater::Actions::Template.new(@generator, @name, get_source, get_destination)
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_file
|
26
|
-
instance_eval(&@block) if @block
|
27
|
-
Templater::Actions::File.new(@name, get_source, get_destination)
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_empty_directory
|
31
|
-
instance_eval(&@block) if @block
|
32
|
-
Templater::Actions::EmptyDirectory.new(@name, get_destination)
|
33
|
-
end
|
34
|
-
|
35
|
-
def method_missing(method, *args, &block)
|
36
|
-
if @generator
|
37
|
-
@generator.send(method, *args, &block)
|
38
|
-
else
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
protected
|
44
|
-
|
45
|
-
def get_source
|
46
|
-
::File.expand_path(@source.to_s, @generator.source_root)
|
47
|
-
end
|
48
|
-
|
49
|
-
def get_destination
|
50
|
-
::File.expand_path(convert_encoded_instructions(@destination.to_s), @generator.destination_root)
|
51
|
-
end
|
52
|
-
|
53
|
-
def convert_encoded_instructions(filename)
|
54
|
-
filename.gsub(/%.*?%/) do |string|
|
55
|
-
instruction = string.match(/%(.*?)%/)[1]
|
56
|
-
@generator.respond_to?(instruction) ? @generator.send(instruction) : string
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|