prigner 0.1.1 → 0.2.0
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/CHANGELOG +29 -0
- data/README.rdoc +32 -42
- data/Rakefile +12 -8
- data/lib/prigner/builder.rb +8 -3
- data/lib/prigner/cli/new.rb +30 -8
- data/lib/prigner/cli.rb +1 -2
- data/lib/prigner/extensions.rb +14 -2
- data/lib/prigner/template.rb +31 -7
- data/lib/prigner.rb +2 -2
- data/prigner.gemspec +14 -5
- data/share/templates/bash/default/models/script.sh +45 -0
- data/share/templates/bash/default/models/scriptrc +2 -0
- data/share/templates/bash/default/specfile +18 -0
- data/share/templates/ruby/default/models/executable +23 -0
- data/share/templates/ruby/default/models/testhelper.rb +23 -0
- data/share/templates/ruby/default/specfile +20 -4
- data/share/templates/ruby/gem/models/README.rdoc +4 -0
- data/share/templates/ruby/gem/models/Rakefile +81 -148
- data/share/templates/ruby/gem/models/cli.rb +43 -0
- data/share/templates/ruby/gem/models/executable +23 -0
- data/share/templates/ruby/gem/models/gemspec +10 -8
- data/share/templates/ruby/gem/models/module.rb +24 -9
- data/share/templates/ruby/gem/models/testhelper.rb +23 -0
- data/share/templates/ruby/gem/specfile +20 -8
- data/test/builder_test.rb +15 -0
- data/test/fixtures/templates/shared/templates/ruby/default/models/cli.rb +0 -0
- data/test/fixtures/templates/shared/templates/ruby/default/models/executable +23 -0
- data/test/fixtures/templates/shared/templates/ruby/default/models/testhelper.rb +0 -0
- data/test/fixtures/templates/shared/templates/ruby/default/specfile +21 -9
- data/test/helpers.rb +8 -8
- data/test/spec_test.rb +18 -4
- data/test/template_test.rb +21 -6
- metadata +19 -10
- data/share/templates/ruby/gem/models/README.mkd +0 -5
- data/share/templates/ruby/gem/models/empty_test.rb +0 -16
- data/test/fixtures/templates/shared/templates/ruby/default/README.mkd +0 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
= Prigner v0.1.1 (2010-10-21) - Changelog
|
2
2
|
|
3
|
+
== 2010-10-27
|
4
|
+
|
5
|
+
* Releasing of version 0.2.0.
|
6
|
+
* Adding of template for Bash script.
|
7
|
+
* Fixes in error of the emtpy directories.
|
8
|
+
* Updates in shared templates.
|
9
|
+
|
10
|
+
== 2010-10-26
|
11
|
+
|
12
|
+
* Adjustments in CLI command.
|
13
|
+
* The 'new' command has been updated for handling of optional files.
|
14
|
+
* Small fixes in CLI module.
|
15
|
+
|
16
|
+
== 2010-10-25
|
17
|
+
|
18
|
+
* Fixes in the parsing of optional files.
|
19
|
+
|
20
|
+
== 2010-10-24
|
21
|
+
|
22
|
+
* Adding of optional models.
|
23
|
+
* Each option can include the itself list of models.
|
24
|
+
* Enhancements in library for handle the optional models.
|
25
|
+
* More core extensions.
|
26
|
+
|
27
|
+
== 2010-10-22
|
28
|
+
|
29
|
+
* Fixes in the tasks for releasing of packages.
|
30
|
+
* Checking of the tagged current version.
|
31
|
+
|
3
32
|
== 2010-10-21
|
4
33
|
|
5
34
|
* Releasing of version 0.1.1.
|
data/README.rdoc
CHANGED
@@ -7,14 +7,13 @@ short, a project template engine.
|
|
7
7
|
|
8
8
|
== Features
|
9
9
|
|
10
|
-
* Load and create all directories and files from
|
10
|
+
* Load and create all directories and files from template specification.
|
11
|
+
* The template specification is parsed to command line options.
|
11
12
|
* Default Ruby project templates.
|
12
13
|
* Ruby Gem.
|
13
14
|
* A simple project using setup.
|
14
|
-
* Script file with or without directory structure.
|
15
15
|
* Add common tasks and libraries.
|
16
16
|
* Tests.
|
17
|
-
* Deploy.
|
18
17
|
* Code for versioning.
|
19
18
|
|
20
19
|
== Installation
|
@@ -23,6 +22,10 @@ First, install Prigner stable through Gem:
|
|
23
22
|
|
24
23
|
gem install prigner
|
25
24
|
|
25
|
+
If you want try the developer source:
|
26
|
+
|
27
|
+
git clone http://github.com/codigorama/prigner.git
|
28
|
+
|
26
29
|
== Usage
|
27
30
|
|
28
31
|
Prigner create the most common Ruby projects through templates shared. To
|
@@ -30,55 +33,42 @@ generate new Gem project, run command using the following syntax:
|
|
30
33
|
|
31
34
|
prign new ruby:gem foo
|
32
35
|
|
33
|
-
foo
|
34
|
-
|--
|
35
|
-
|--
|
36
|
-
|-- README.mkd
|
37
|
-
|-- Rakefile
|
38
|
-
|-- bin
|
39
|
-
| `-- foo
|
40
|
-
|-- foo.gemspec
|
41
|
-
|-- lib
|
42
|
-
| |-- foo
|
36
|
+
foo/
|
37
|
+
|-- lib/
|
38
|
+
| |-- foo/
|
43
39
|
| `-- foo.rb
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
`-- helper.rb
|
48
|
-
|
49
|
-
This command will generate 'foo' Gem project structure. Or, you maybe create a
|
50
|
-
Ruby script or a UNIX-like program.
|
51
|
-
|
52
|
-
prign new bash:script bar
|
53
|
-
|
54
|
-
bar
|
55
|
-
|-- bar
|
56
|
-
`-- barrc
|
40
|
+
|-- CHANGELOG
|
41
|
+
|-- COPYING
|
42
|
+
`-- README.rdoc
|
57
43
|
|
58
|
-
|
44
|
+
This command will generate 'foo' Gem project structure. But all templates
|
45
|
+
offers options.
|
59
46
|
|
60
|
-
|
61
|
-
|-- bin
|
62
|
-
| `-- ducklet
|
63
|
-
`-- etc
|
64
|
-
`-- duckletrc
|
47
|
+
prign new ruby:gem --test --bin
|
65
48
|
|
66
|
-
|
49
|
+
foo/
|
50
|
+
|-- bin/
|
51
|
+
| `-- foo
|
52
|
+
|-- lib/
|
53
|
+
| |-- foo/
|
54
|
+
| `-- foo.rb
|
55
|
+
|-- test/
|
56
|
+
| |-- foo_test.rb
|
57
|
+
| `-- helper.rb
|
58
|
+
|-- CHANGELOG
|
59
|
+
|-- COPYING
|
60
|
+
`-- README.rdoc
|
67
61
|
|
68
|
-
|
62
|
+
Run <tt>prign list</tt> to view all available templates.
|
69
63
|
|
70
|
-
|
71
|
-
|
72
|
-
README.rdoc, CHANGELOG
|
73
|
-
* Gem project that include library directory, main module, test and
|
74
|
-
directories for fixtures.
|
75
|
-
* Sinatra basic application.
|
64
|
+
You can creates your own templates. Just save in your home directory
|
65
|
+
<tt>~/.prigner/templates/<your-template></tt>.
|
76
66
|
|
77
67
|
== Copyright
|
78
68
|
|
79
|
-
Written by
|
69
|
+
Written by {Hallison Batista}[http://github.com/hallison].
|
80
70
|
|
81
|
-
Prigner is Copyright (C) 2010, [
|
71
|
+
Prigner is Copyright (C) 2010, {Codigorama}[http://codigorama.com].
|
82
72
|
|
83
73
|
See COPYRIGHT file for more information about license.
|
84
74
|
|
data/Rakefile
CHANGED
@@ -74,10 +74,9 @@ end
|
|
74
74
|
# Documentation
|
75
75
|
# =============================================================================
|
76
76
|
|
77
|
-
CLOBBER << FileList["doc/*"]
|
77
|
+
CLOBBER << FileList["doc/api/*"]
|
78
78
|
|
79
79
|
file "doc/api/index.html" => FileList["lib/**/*.rb", "README.rdoc", "CHANGELOG"] do |filespec|
|
80
|
-
rm_rf "doc"
|
81
80
|
rdoc "--op", "doc/api",
|
82
81
|
"--charset", "utf8",
|
83
82
|
"--main", "'Prigner'",
|
@@ -159,7 +158,10 @@ end
|
|
159
158
|
CLOBBER << FileList["#{package_path.dirname}/*"]
|
160
159
|
|
161
160
|
task :tagged do
|
162
|
-
abort "The version #{version.tag}
|
161
|
+
abort "The gemspec not updated to version #{version.tag} (#{spec.version})" \
|
162
|
+
unless spec.version.to_s == version.tag
|
163
|
+
abort "The version #{version.tag} is not tagged." \
|
164
|
+
unless tag[1..-1] == version.tag
|
163
165
|
end
|
164
166
|
|
165
167
|
file specfile => FileList["{bin,lib,test}/**", "Rakefile"] do
|
@@ -202,13 +204,15 @@ task :package => [package(".gem"), package(".tar.gz")]
|
|
202
204
|
desc "Release gem package to repositories."
|
203
205
|
task :release => [ :tagged, :package ] do
|
204
206
|
sh "gem push #{package('.gem')}"
|
205
|
-
|
206
|
-
sh
|
207
|
-
|
208
|
-
|
207
|
+
[%w[release .gem], %w[file .tar.gz]].each do |file, ext|
|
208
|
+
sh <<-endsh.gsub(/^[ ]{6}/,"")
|
209
|
+
rubyforge add_#{file} #{spec.rubyforge_project} #{spec.name} #{spec.version} #{package(ext)}
|
210
|
+
endsh
|
209
211
|
end
|
210
212
|
if release_notes.exist?
|
211
|
-
sh
|
213
|
+
sh <<-endsh.gsub(/^[ ]{6}/,"")
|
214
|
+
rubyforge post_news #{spec.rubyforge_project} 'Prigner v#{spec.version} released' '#{release_notes.read}'
|
215
|
+
endsh
|
212
216
|
end
|
213
217
|
end
|
214
218
|
|
data/lib/prigner/builder.rb
CHANGED
@@ -31,15 +31,20 @@ class Prigner::Builder
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def make_project_files #:yields: path, info
|
35
|
-
@template.models.inject({}) do |hash, (model, basename)|
|
34
|
+
def make_project_files(option = :required) #:yields: path, info
|
35
|
+
@template.models[option.to_sym].inject({}) do |hash, (model, basename)|
|
36
36
|
file = basename.gsub(/\((.*?)\)/){ project.send($1) }
|
37
37
|
path = File.join(@project.path, file)
|
38
38
|
model.binder = Prigner::Binder.new(@project, @template.options)
|
39
39
|
model.write(path)
|
40
40
|
hash[no_pwd(model.file_written)] = File.stat(model.file_written)
|
41
41
|
hash
|
42
|
-
end
|
42
|
+
end if @template.models.has_key?(option.to_sym)
|
43
|
+
end
|
44
|
+
|
45
|
+
def make_project_files_for_option(option)
|
46
|
+
@template.initialize_models_for_option(option)
|
47
|
+
self.make_project_files(option)
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
data/lib/prigner/cli/new.rb
CHANGED
@@ -21,17 +21,20 @@ begin
|
|
21
21
|
|
22
22
|
end_banner
|
23
23
|
|
24
|
-
unless ARGV.empty?
|
25
|
-
arguments.parse!
|
26
|
-
|
24
|
+
unless ARGV.empty? or ARGV[0] =~ /^-.*?/
|
27
25
|
name = ARGV.shift
|
28
26
|
|
29
|
-
template = Prigner::Template.load(*name.split(":"))
|
30
|
-
|
31
|
-
if template
|
27
|
+
if template = Prigner::Template.load(*name.split(":"))
|
32
28
|
arguments.banner = <<-end_banner.gsub /^[ ]{10}/, ''
|
33
29
|
#{Prigner::Version}
|
34
30
|
|
31
|
+
Template:
|
32
|
+
#{template.mask} v#{template.spec.version}
|
33
|
+
|
34
|
+
#{template.spec.description}
|
35
|
+
|
36
|
+
Written by #{template.spec.author} <#{template.spec.email}>.
|
37
|
+
|
35
38
|
Usage:
|
36
39
|
#{program} #{command} #{template.mask} <path> [options]
|
37
40
|
|
@@ -51,6 +54,9 @@ begin
|
|
51
54
|
else
|
52
55
|
raise RuntimeError, "unable to load template '#{name}'"
|
53
56
|
end
|
57
|
+
|
58
|
+
arguments.parse!
|
59
|
+
|
54
60
|
end
|
55
61
|
|
56
62
|
path = unless ARGV.empty?
|
@@ -82,12 +88,28 @@ begin
|
|
82
88
|
|
83
89
|
status.start "Creating directories" do
|
84
90
|
builder.make_project_directories
|
85
|
-
end
|
91
|
+
end unless builder.template.directories.empty?
|
86
92
|
|
87
|
-
status.start "Writing files" do
|
93
|
+
status.start "Writing required files" do
|
88
94
|
builder.make_project_files
|
89
95
|
end
|
90
96
|
|
97
|
+
options_used = []
|
98
|
+
template.options.members.each do |optname|
|
99
|
+
option = template.options[optname]
|
100
|
+
if option.enabled and option.files.size > 0
|
101
|
+
builder.make_project_files_for_option(optname)
|
102
|
+
options_used << optname
|
103
|
+
end
|
104
|
+
end if template.options
|
105
|
+
|
106
|
+
for optional in options_used
|
107
|
+
status.start "Writing #{optional} files" do
|
108
|
+
builder.make_project_files_for_option(optional)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
91
113
|
end
|
92
114
|
|
93
115
|
rescue => error
|
data/lib/prigner/cli.rb
CHANGED
@@ -39,8 +39,7 @@ module Prigner::CLI
|
|
39
39
|
def self.run(*args)
|
40
40
|
command = args.shift if commands.include? args.first
|
41
41
|
raise RuntimeError, "unknown command '#{args.first}'" unless command
|
42
|
-
|
43
|
-
exec ruby, rubyopt, source(command), *args
|
42
|
+
exec ruby, source(command), *args
|
44
43
|
end
|
45
44
|
|
46
45
|
class Status
|
data/lib/prigner/extensions.rb
CHANGED
@@ -9,8 +9,6 @@ end
|
|
9
9
|
|
10
10
|
class Hash
|
11
11
|
|
12
|
-
alias has? has_key?
|
13
|
-
|
14
12
|
# Only symbolize all keys, including all key in sub-hashes.
|
15
13
|
def symbolize_keys
|
16
14
|
return self.clone if self.empty?
|
@@ -58,6 +56,8 @@ class Struct
|
|
58
56
|
end
|
59
57
|
|
60
58
|
class Pathname
|
59
|
+
|
60
|
+
# For compatibilities with Net::HTTP.get method.
|
61
61
|
def get(file)
|
62
62
|
result = self.join(file.gsub(/^\/(.*?)$/){$1})
|
63
63
|
def result.to_s
|
@@ -66,17 +66,29 @@ class Pathname
|
|
66
66
|
result
|
67
67
|
end
|
68
68
|
|
69
|
+
# For compatibilities with the Net::HTTPResponse.read_body method.
|
69
70
|
alias read_body read
|
70
71
|
|
72
|
+
# For compatibilities with the Net::HTTP.address method.
|
71
73
|
alias address expand_path
|
72
74
|
|
75
|
+
# For compatibilities with the Net::HTTP.port method.
|
73
76
|
def port
|
74
77
|
nil
|
75
78
|
end
|
76
79
|
|
80
|
+
# For compatibilities with the Net::HTTP.start method.
|
77
81
|
def start
|
78
82
|
block_given? ? (yield self) : self
|
79
83
|
end
|
80
84
|
|
81
85
|
end
|
82
86
|
|
87
|
+
class NilClass
|
88
|
+
|
89
|
+
# nil is empty? of course!
|
90
|
+
def empty?
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/prigner/template.rb
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
# project using +specfile+.
|
16
16
|
class Prigner::Template
|
17
17
|
|
18
|
+
Option = Struct.new(:enabled, :description, :files)
|
19
|
+
|
18
20
|
# Namespace of template.
|
19
21
|
attr_reader :namespace
|
20
22
|
|
@@ -52,7 +54,7 @@ class Prigner::Template
|
|
52
54
|
initialize_options
|
53
55
|
initialize_directories
|
54
56
|
initialize_models
|
55
|
-
rescue
|
57
|
+
rescue Errno::ENOENT => error
|
56
58
|
raise RuntimeError, error.message
|
57
59
|
end
|
58
60
|
|
@@ -90,6 +92,14 @@ class Prigner::Template
|
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
95
|
+
# If the option has list of files, then initialize all models.
|
96
|
+
def initialize_models_for_option(optname)
|
97
|
+
option = optname.to_sym
|
98
|
+
unless @options[option].files.empty?
|
99
|
+
@models[option] = parse_models(@options[option].files)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
93
103
|
private
|
94
104
|
|
95
105
|
# Return the specfile placed in template path.
|
@@ -102,24 +112,38 @@ class Prigner::Template
|
|
102
112
|
@spec = Prigner::Spec.load(specfile)
|
103
113
|
end
|
104
114
|
|
105
|
-
#
|
115
|
+
# The "+options+" attribute is a Hash that contains a list of the Option
|
116
|
+
# structure.
|
106
117
|
def initialize_options
|
107
|
-
@options = @spec.options.inject({}) do |options, (name,
|
108
|
-
options[name] =
|
118
|
+
@options = @spec.options.inject({}) do |options, (name, params)|
|
119
|
+
options[name] = Option.new
|
120
|
+
options[name].enabled = false
|
121
|
+
options[name].description = params["description"] || params
|
122
|
+
options[name].files = params["files"] || {}
|
109
123
|
options
|
110
124
|
end.to_struct if @spec.options
|
111
125
|
end
|
112
126
|
|
113
127
|
def initialize_directories
|
114
|
-
@directories = @spec.directories
|
128
|
+
@directories = @spec.directories || []
|
115
129
|
end
|
116
130
|
|
131
|
+
# All models are listed by a Hash and are indexed by "+required+" key and the
|
132
|
+
# option names.
|
117
133
|
def initialize_models
|
118
|
-
@models =
|
134
|
+
@models = {}
|
135
|
+
@models[:required] = parse_models(@spec.files) if @spec.files
|
136
|
+
end
|
137
|
+
|
138
|
+
# Parses a Hash that contains a pair of the model file name and the result
|
139
|
+
# output name.
|
140
|
+
def parse_models(hash)
|
141
|
+
hash.inject({}) do |models, (source, file)|
|
119
142
|
model = Prigner::Model.new(@path.join("models", source))
|
143
|
+
models ||= {}
|
120
144
|
models[model] = file ? file : source
|
121
145
|
models
|
122
|
-
end
|
146
|
+
end
|
123
147
|
end
|
124
148
|
|
125
149
|
end
|
data/lib/prigner.rb
CHANGED
data/prigner.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
#
|
15
15
|
|
16
16
|
#version
|
17
|
-
spec.version = "0.
|
18
|
-
spec.date = "2010-10-
|
17
|
+
spec.version = "0.2.0"
|
18
|
+
spec.date = "2010-10-27"
|
19
19
|
#
|
20
20
|
|
21
21
|
#dependencies
|
@@ -40,26 +40,35 @@ Gem::Specification.new do |spec|
|
|
40
40
|
"lib/prigner/project.rb",
|
41
41
|
"lib/prigner/template.rb",
|
42
42
|
"prigner.gemspec",
|
43
|
+
"share/templates/bash/default/models/script.sh",
|
44
|
+
"share/templates/bash/default/models/scriptrc",
|
45
|
+
"share/templates/bash/default/specfile",
|
43
46
|
"share/templates/ruby/default/models/CHANGELOG",
|
44
47
|
"share/templates/ruby/default/models/COPYING",
|
45
48
|
"share/templates/ruby/default/models/README.rdoc",
|
49
|
+
"share/templates/ruby/default/models/executable",
|
46
50
|
"share/templates/ruby/default/models/module.rb",
|
51
|
+
"share/templates/ruby/default/models/testhelper.rb",
|
47
52
|
"share/templates/ruby/default/specfile",
|
48
53
|
"share/templates/ruby/gem/models/CHANGELOG",
|
49
54
|
"share/templates/ruby/gem/models/COPYING",
|
50
|
-
"share/templates/ruby/gem/models/README.
|
55
|
+
"share/templates/ruby/gem/models/README.rdoc",
|
51
56
|
"share/templates/ruby/gem/models/Rakefile",
|
52
|
-
"share/templates/ruby/gem/models/
|
57
|
+
"share/templates/ruby/gem/models/cli.rb",
|
58
|
+
"share/templates/ruby/gem/models/executable",
|
53
59
|
"share/templates/ruby/gem/models/gemspec",
|
54
60
|
"share/templates/ruby/gem/models/module.rb",
|
61
|
+
"share/templates/ruby/gem/models/testhelper.rb",
|
55
62
|
"share/templates/ruby/gem/specfile",
|
56
63
|
"test/builder_test.rb",
|
57
64
|
"test/fixtures/model.rb.erb",
|
58
|
-
"test/fixtures/templates/shared/templates/ruby/default/README.mkd",
|
59
65
|
"test/fixtures/templates/shared/templates/ruby/default/models/README.mkd",
|
60
66
|
"test/fixtures/templates/shared/templates/ruby/default/models/Rakefile",
|
67
|
+
"test/fixtures/templates/shared/templates/ruby/default/models/cli.rb",
|
61
68
|
"test/fixtures/templates/shared/templates/ruby/default/models/empty_test.rb",
|
69
|
+
"test/fixtures/templates/shared/templates/ruby/default/models/executable",
|
62
70
|
"test/fixtures/templates/shared/templates/ruby/default/models/module.rb",
|
71
|
+
"test/fixtures/templates/shared/templates/ruby/default/models/testhelper.rb",
|
63
72
|
"test/fixtures/templates/shared/templates/ruby/default/specfile",
|
64
73
|
"test/fixtures/templates/shared/templates/ruby/sinatra/models/README.mkd",
|
65
74
|
"test/fixtures/templates/shared/templates/ruby/sinatra/models/Rakefile",
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#$ <%=project.name%> v0.1.0
|
3
|
+
#$
|
4
|
+
#$ Usage:
|
5
|
+
#$ <%=project.name%> [options] [args]
|
6
|
+
#$
|
7
|
+
#$ Options:
|
8
|
+
#$ -h,--help Show this message.
|
9
|
+
#$
|
10
|
+
|
11
|
+
function <%=project.name%> {
|
12
|
+
local path="${BASH_SOURCE%/*}/"
|
13
|
+
|
14
|
+
# This function show the message written in the header.
|
15
|
+
function __help {
|
16
|
+
local origin="$(1<${0})"
|
17
|
+
local comments="${origin}"
|
18
|
+
|
19
|
+
comments="${comments#\#!*\#\$}"
|
20
|
+
comments="${comments%\#\$*}"
|
21
|
+
comments="${comments//\#\$ }"
|
22
|
+
comments="${comments:1:${#comments}}"
|
23
|
+
|
24
|
+
test "${comments//\$}" != "${origin}" && echo "${comments//\#\$}"
|
25
|
+
}
|
26
|
+
function _h { __help; return 0; }
|
27
|
+
|
28
|
+
if [[ ${#} -eq 0 ]]; then
|
29
|
+
__help
|
30
|
+
exit 0
|
31
|
+
elif [[ ${1} =~ -.|-- ]]; then
|
32
|
+
source $path/<%=project.name%>rc
|
33
|
+
|
34
|
+
local option=""
|
35
|
+
|
36
|
+
[[ "${1}" =~ ^-.* ]] && option=${1//-/_}
|
37
|
+
|
38
|
+
shift 1
|
39
|
+
|
40
|
+
${option} ${@}
|
41
|
+
fi
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
<%=project.name%> ${@}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "<%=project.name%>"
|
5
|
+
|
6
|
+
ARGV.options do |args|
|
7
|
+
|
8
|
+
args.on "-s", "--set VALUE", String, "Set anything" do |anything|
|
9
|
+
puts "Setting anything to #{anything} ..."
|
10
|
+
end
|
11
|
+
|
12
|
+
args.on "-a", "--anything", TrueClass, "Do anything!" do |enabled|
|
13
|
+
puts "Enable to doing anything ..." if enabled
|
14
|
+
end
|
15
|
+
|
16
|
+
unless ARGV.empty?
|
17
|
+
args.parse!
|
18
|
+
else
|
19
|
+
puts args
|
20
|
+
exit 0
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# This code extracted from book "Ruby Best Practices" and the code be found
|
2
|
+
# in http://github.com/sandal/rbp/blob/master/testing/test_unit_extensions.rb
|
3
|
+
|
4
|
+
TEST_HOME = File.expand_path(File.dirname(__FILE__)) unless defined? TEST_HOME
|
5
|
+
FIXTURES = File.join(TEST_HOME, "fixtures") unless defined? FIXTURES
|
6
|
+
|
7
|
+
module Test::Unit
|
8
|
+
class TestCase
|
9
|
+
def self.should(description, &block)
|
10
|
+
test_name = "test_#{description.gsub(/\s+/,'_')}".downcase.to_sym
|
11
|
+
defined = instance_method(test_name) rescue false
|
12
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
13
|
+
if block_given?
|
14
|
+
define_method(test_name, &block)
|
15
|
+
else
|
16
|
+
define_method(test_name) do
|
17
|
+
flunk "No implementation provided for #{description}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -1,9 +1,24 @@
|
|
1
|
-
author
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
author:
|
2
|
+
Hallison Batista
|
3
|
+
email:
|
4
|
+
hallison@codigorama.com
|
5
|
+
version:
|
6
|
+
0.1.0
|
7
|
+
description:
|
8
|
+
Default template for Ruby projects.
|
5
9
|
|
6
10
|
options:
|
11
|
+
bin:
|
12
|
+
description:
|
13
|
+
Includes executable file.
|
14
|
+
files:
|
15
|
+
executable: bin/(project)
|
16
|
+
test:
|
17
|
+
description:
|
18
|
+
Includes test files.
|
19
|
+
files:
|
20
|
+
test.rb: test/(project)_test.rb
|
21
|
+
testhelper.rb: test/helper.rb
|
7
22
|
|
8
23
|
directories:
|
9
24
|
- lib/(project)
|
@@ -14,3 +29,4 @@ files:
|
|
14
29
|
README.rdoc:
|
15
30
|
module.rb : lib/(project).rb
|
16
31
|
|
32
|
+
# vim: filetype=yaml
|