automatthew-rakegen 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +2 -1
- data/README +4 -4
- data/lib/rakegen.rb +41 -6
- data/lib/rakegen/polite_file.rb +1 -1
- data/rakegen.gemspec +7 -6
- data/test/test_polite_file.rb +1 -1
- data/test/test_rakegen.rb +10 -10
- metadata +5 -5
data/Manifest
CHANGED
@@ -2,6 +2,8 @@ CHANGELOG
|
|
2
2
|
lib/rakegen/polite_file.rb
|
3
3
|
lib/rakegen.rb
|
4
4
|
LICENSE
|
5
|
+
Manifest
|
6
|
+
rakegen.gemspec
|
5
7
|
README
|
6
8
|
test/helper.rb
|
7
9
|
test/test_polite_file.rb
|
@@ -12,4 +14,3 @@ test/testdata/app/one
|
|
12
14
|
test/testdata/app/six.textile
|
13
15
|
test/testdata/app/three.rb
|
14
16
|
test/testdata/app/two.txt
|
15
|
-
Manifest
|
data/README
CHANGED
@@ -12,8 +12,8 @@ Rakegen is a Rake extension for generating and updating projects from templates.
|
|
12
12
|
gen.executables = %w{ bin/waves-console bin/waves-server }
|
13
13
|
end
|
14
14
|
|
15
|
-
This will define a task named, naturally enough, "generate:app".
|
15
|
+
This will define a task named, naturally enough, "generate:app". If you define the generator in a rakefile, you can run it with <tt>rake generate:app</tt>. If you're building your own executable, you can call it from Ruby:
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
generator.invoke
|
18
|
+
|
19
|
+
Rakegen asks you before clobbering existing files.
|
data/lib/rakegen.rb
CHANGED
@@ -39,9 +39,26 @@ class Rakegen < Rake::TaskLib
|
|
39
39
|
|
40
40
|
attr_accessor :executables
|
41
41
|
|
42
|
-
# Create a
|
43
|
-
|
44
|
-
|
42
|
+
# Create a generator. The task_name becomes the primary Rake task, which has dependency
|
43
|
+
# tasks that get all the work done. You can use a string to supply a namespaced task name,
|
44
|
+
# such as "waves:app".
|
45
|
+
#
|
46
|
+
# In the required block, you must define the source and target directories. You may also define
|
47
|
+
# a list of excludes, a list of executables, assign variables for templates, and lambdas for processing
|
48
|
+
# different kinds of templates, keyed by the file extension.
|
49
|
+
#
|
50
|
+
# generator = Rakegen.new do |gen|
|
51
|
+
# gen.source = "some/place"
|
52
|
+
# gen.target = "some/where/else"
|
53
|
+
# gen.excludes = "**/*.yaml"
|
54
|
+
# gen.executables = %w{ bin/console bin/server }
|
55
|
+
# gen.template_assigns[:monkey] = "howler"
|
56
|
+
# gen.template_processors[:erb] = lambda { |src, tgt| MyErb.process(src, tgt) }
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
|
60
|
+
def initialize(task_name = :app)
|
61
|
+
@name = task_name
|
45
62
|
@excludes = []
|
46
63
|
@executables = []
|
47
64
|
@template_processors = {}
|
@@ -54,7 +71,10 @@ class Rakegen < Rake::TaskLib
|
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
57
|
-
yield self
|
74
|
+
yield self
|
75
|
+
|
76
|
+
raise "You must supply a source." unless @source
|
77
|
+
raise "You must supply a target." unless @target
|
58
78
|
|
59
79
|
Dir.chdir(@source) do
|
60
80
|
@files = Rake::FileList.new("**/*").exclude(*@excludes).to_a
|
@@ -75,6 +95,19 @@ class Rakegen < Rake::TaskLib
|
|
75
95
|
define
|
76
96
|
end
|
77
97
|
|
98
|
+
# Invoke the primary task. In other words, run the generator.
|
99
|
+
def invoke
|
100
|
+
Rake::Task[name].invoke
|
101
|
+
end
|
102
|
+
|
103
|
+
# A rake file-based task that assesses neededness of target files based on user confirmation,
|
104
|
+
# rather than relative timestamps. As with Rake#file, you can do arbitrary stuff
|
105
|
+
# in the block:
|
106
|
+
#
|
107
|
+
# polite_file "some/target/file" do
|
108
|
+
# str = File.read("/etc/profile").reverse
|
109
|
+
# File.write( "some/target/file", str)
|
110
|
+
# end
|
78
111
|
|
79
112
|
def polite_file(args, &block)
|
80
113
|
PoliteFileTask.define_task(args, &block)
|
@@ -85,12 +118,14 @@ class Rakegen < Rake::TaskLib
|
|
85
118
|
path ? File.join(@source, path) : @source
|
86
119
|
end
|
87
120
|
|
88
|
-
# If given a path, joins it to @
|
121
|
+
# If given a path, joins it to @target. Otherwise returns @target
|
89
122
|
def target(path=nil)
|
90
123
|
path ? File.join(@target, path) : @target
|
91
124
|
end
|
92
125
|
|
93
|
-
|
126
|
+
private
|
127
|
+
|
128
|
+
# Define all the generator's dependent tasks
|
94
129
|
def define
|
95
130
|
desc "Create or update project using Rakegen"
|
96
131
|
task name => @all_files.map { |f| target(f) }
|
data/lib/rakegen/polite_file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class PoliteFileTask < Rake::FileTask
|
2
2
|
|
3
|
-
# Is this file task needed? Yes if doesn't exist
|
3
|
+
# Is this file task needed? Yes if doesn't exist or if the user agrees to clobber.
|
4
4
|
def needed?
|
5
5
|
return true unless File.exist?(name)
|
6
6
|
return confirm?
|
data/rakegen.gemspec
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Rakegen-0.6.
|
2
|
+
# Gem::Specification for Rakegen-0.6.6
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{rakegen}
|
7
|
-
s.version = "0.6.
|
7
|
+
s.version = "0.6.6"
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
10
|
s.authors = ["Matthew King"]
|
11
|
-
s.date = %q{2008-09-
|
11
|
+
s.date = %q{2008-09-03}
|
12
12
|
s.description = %q{Generation and updation of projects from templates. Rake-powered, for sustainable blah blah.}
|
13
13
|
s.email = %q{automatthew@gmail.com}
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG", "lib/rakegen/polite_file.rb", "lib/rakegen.rb", "LICENSE", "README"]
|
15
|
-
s.files = ["CHANGELOG", "lib/rakegen/polite_file.rb", "lib/rakegen.rb", "LICENSE", "README", "test/helper.rb", "test/test_polite_file.rb", "test/test_rakegen.rb", "test/testdata/app/alpha/beta/five.erb", "test/testdata/app/four.erb", "test/testdata/app/one", "test/testdata/app/six.textile", "test/testdata/app/three.rb", "test/testdata/app/two.txt"
|
15
|
+
s.files = ["CHANGELOG", "lib/rakegen/polite_file.rb", "lib/rakegen.rb", "LICENSE", "Manifest", "rakegen.gemspec", "README", "test/helper.rb", "test/test_polite_file.rb", "test/test_rakegen.rb", "test/testdata/app/alpha/beta/five.erb", "test/testdata/app/four.erb", "test/testdata/app/one", "test/testdata/app/six.textile", "test/testdata/app/three.rb", "test/testdata/app/two.txt"]
|
16
16
|
s.has_rdoc = true
|
17
|
-
s.homepage = %q{}
|
17
|
+
s.homepage = %q{http://rakegen.rubyforge.org}
|
18
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rakegen", "--main", "README"]
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.rubyforge_project = %q{rakegen}
|
@@ -49,7 +49,7 @@ end
|
|
49
49
|
# require dep
|
50
50
|
# end
|
51
51
|
#
|
52
|
-
# Version = '0.6.
|
52
|
+
# Version = '0.6.6'
|
53
53
|
#
|
54
54
|
# task :default => [:test]
|
55
55
|
#
|
@@ -61,6 +61,7 @@ end
|
|
61
61
|
# p.summary = "Generation and updation of projects from templates. Rake-powered, for sustainable blah blah."
|
62
62
|
# p.author = "Matthew King"
|
63
63
|
# p.email = "automatthew@gmail.com"
|
64
|
+
# p.url = "http://rakegen.rubyforge.org"
|
64
65
|
# p.ignore_pattern = /^(\.git).+/
|
65
66
|
# p.test_pattern = "test/test_*.rb"
|
66
67
|
# p.dependencies << "rake"
|
data/test/test_polite_file.rb
CHANGED
@@ -33,7 +33,7 @@ context "A file_copy task" do
|
|
33
33
|
Rake::Task[@target].needed?.should == true
|
34
34
|
end
|
35
35
|
|
36
|
-
specify "should ask if file exists
|
36
|
+
specify "should ask if file exists" do
|
37
37
|
File.open(@target, "w") { |f| f.print "two" }
|
38
38
|
# run in shell and answer "n". Also, find better way to test.
|
39
39
|
puts "Answer no to the next prompt"
|
data/test/test_rakegen.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "helper")
|
2
2
|
|
3
|
-
context "Simple rakegen" do
|
3
|
+
context "A Simple rakegen" do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@target = File.join(TEST_DIR, "app_target")
|
@@ -37,36 +37,36 @@ context "Simple rakegen" do
|
|
37
37
|
rm_r @target if File.exist?(@target)
|
38
38
|
end
|
39
39
|
|
40
|
-
specify "
|
40
|
+
specify "includes all directories in the directories list" do
|
41
41
|
@generator.directories.to_a.should == @directories
|
42
42
|
# @generator.template_files.should == 1
|
43
43
|
end
|
44
44
|
|
45
|
-
specify "
|
45
|
+
specify "includes all non-erb files in the copy list" do
|
46
46
|
@generator.copy_files.to_a.should == @copy_files
|
47
47
|
end
|
48
|
-
|
49
|
-
specify "
|
48
|
+
|
49
|
+
specify "includes all .erb files in the template list" do
|
50
50
|
@generator.template_files.should == @template_files
|
51
51
|
end
|
52
52
|
|
53
|
-
specify "
|
53
|
+
specify "has an empty excludes list" do
|
54
54
|
@generator.excludes.should == ["**/two.*"]
|
55
55
|
end
|
56
56
|
|
57
|
-
specify "
|
57
|
+
specify "has an executables list" do
|
58
58
|
@generator.executables.should == ["one"]
|
59
59
|
end
|
60
60
|
|
61
|
-
specify "
|
61
|
+
specify "has a working erb template_processor" do
|
62
62
|
@generator.template_processors["erb"].should.respond_to :call
|
63
63
|
@generator.template_processors["erb"].call("#{TEST_APP}/four.erb", "#{TEST_DIR}/catch.txt")
|
64
64
|
File.open("#{TEST_DIR}/catch.txt", "r").read.should == "Yossarian jumped."
|
65
65
|
rm "#{TEST_DIR}/catch.txt"
|
66
66
|
end
|
67
67
|
|
68
|
-
specify "
|
69
|
-
|
68
|
+
specify "can copy or process all files and directories using #invoke" do
|
69
|
+
@generator.invoke
|
70
70
|
@copy_files.each do |f|
|
71
71
|
assert File.exist?(File.join(@target, f))
|
72
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automatthew-rakegen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew King
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -56,6 +56,8 @@ files:
|
|
56
56
|
- lib/rakegen/polite_file.rb
|
57
57
|
- lib/rakegen.rb
|
58
58
|
- LICENSE
|
59
|
+
- Manifest
|
60
|
+
- rakegen.gemspec
|
59
61
|
- README
|
60
62
|
- test/helper.rb
|
61
63
|
- test/test_polite_file.rb
|
@@ -66,10 +68,8 @@ files:
|
|
66
68
|
- test/testdata/app/six.textile
|
67
69
|
- test/testdata/app/three.rb
|
68
70
|
- test/testdata/app/two.txt
|
69
|
-
- Manifest
|
70
|
-
- rakegen.gemspec
|
71
71
|
has_rdoc: true
|
72
|
-
homepage:
|
72
|
+
homepage: http://rakegen.rubyforge.org
|
73
73
|
post_install_message:
|
74
74
|
rdoc_options:
|
75
75
|
- --line-numbers
|