automatthew-genitor 0.6.0 → 0.6.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/README +1 -1
- data/genitor.gemspec +3 -3
- data/lib/genitor.rb +13 -0
- data/test/test_genitor.rb +8 -2
- metadata +1 -1
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Genitor
|
2
2
|
|
3
|
-
Genitor is a Rake extension for generating and updating projects from templates. Give Genitor a source and a target, and it creates a rake task that will
|
3
|
+
Genitor is a Rake extension for generating and updating projects from templates. Give Genitor a source and a target, and it creates a rake task that will make the necessary directories and copy the template files to the target. Genitor processes .erb files by default, but you can register a template processing lambda for any file extension. Because Genitor is Rake-based, you can add your own dependencies and actions to any target file.
|
4
4
|
|
5
5
|
== Usage
|
6
6
|
|
data/genitor.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Genitor-0.6.
|
2
|
+
# Gem::Specification for Genitor-0.6.1
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{genitor}
|
7
|
-
s.version = "0.6.
|
7
|
+
s.version = "0.6.1"
|
8
8
|
|
9
9
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
10
|
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
# require dep
|
34
34
|
# end
|
35
35
|
#
|
36
|
-
# Version = '0.6.
|
36
|
+
# Version = '0.6.1'
|
37
37
|
#
|
38
38
|
# task :default => [:test]
|
39
39
|
#
|
data/lib/genitor.rb
CHANGED
@@ -31,6 +31,8 @@ class Genitor < Rake::TaskLib
|
|
31
31
|
attr_accessor :template_assigns
|
32
32
|
|
33
33
|
attr_accessor :excludes
|
34
|
+
|
35
|
+
attr_accessor :executables
|
34
36
|
|
35
37
|
# Create a Genitor task named <em>task_name</em>. Default task name is +app+.
|
36
38
|
def initialize(name=:app)
|
@@ -61,6 +63,8 @@ class Genitor < Rake::TaskLib
|
|
61
63
|
end
|
62
64
|
@copy_files = @files - @directories - @template_files
|
63
65
|
|
66
|
+
@target_executables = @executables.map { |f| target(f) }
|
67
|
+
|
64
68
|
define
|
65
69
|
end
|
66
70
|
|
@@ -106,6 +110,15 @@ class Genitor < Rake::TaskLib
|
|
106
110
|
source_file, target_file = source(file), target(file)
|
107
111
|
directory(target_file)
|
108
112
|
end
|
113
|
+
|
114
|
+
unless RUBY_PLATFORM =~ /mswin32/
|
115
|
+
@target_executables.each do |executable|
|
116
|
+
file executable do |task|
|
117
|
+
system "chmod +x #{task.name}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
109
122
|
end
|
110
123
|
|
111
124
|
end
|
data/test/test_genitor.rb
CHANGED
@@ -9,6 +9,7 @@ context "Simple genitor" do
|
|
9
9
|
gen.target = @target
|
10
10
|
gen.excludes << "**/two.*"
|
11
11
|
gen.template_assigns = {:verb => "jumped"}
|
12
|
+
gen.executables << "one"
|
12
13
|
end
|
13
14
|
|
14
15
|
@tasks = Rake.application.tasks.map { |t| t.name }
|
@@ -52,6 +53,10 @@ context "Simple genitor" do
|
|
52
53
|
@generator.excludes.should == ["**/two.*"]
|
53
54
|
end
|
54
55
|
|
56
|
+
specify "should have an executables list" do
|
57
|
+
@generator.executables.should == ["one"]
|
58
|
+
end
|
59
|
+
|
55
60
|
specify "should have a working erb template_processor" do
|
56
61
|
@generator.template_processors["erb"].should.respond_to :call
|
57
62
|
@generator.template_processors["erb"].call("#{TEST_APP}/four.erb", "#{TEST_DIR}/catch.txt")
|
@@ -65,12 +70,13 @@ context "Simple genitor" do
|
|
65
70
|
assert File.exist?(File.join(@target, f))
|
66
71
|
end
|
67
72
|
@directories.each do |dir|
|
68
|
-
assert File.directory?(
|
73
|
+
assert File.directory?(@generator.target(dir))
|
69
74
|
end
|
70
75
|
@template_files.each do |tf|
|
71
|
-
assert File.exist?(
|
76
|
+
assert File.exist?(@generator.target(tf.chomp(".erb")))
|
72
77
|
end
|
73
78
|
File.open(File.join(@target, "four"), "r").read.should == "Yossarian jumped."
|
79
|
+
assert File.executable?(@generator.target("one"))
|
74
80
|
end
|
75
81
|
|
76
82
|
|