tap-gen 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +6 -0
- data/MIT-LICENSE +17 -18
- data/README +2 -6
- data/cmd/destroy.rb +13 -7
- data/cmd/generate.rb +14 -8
- data/lib/tap/generator/base.rb +13 -1
- data/lib/tap/generator/destroy.rb +1 -1
- data/lib/tap/generator/generate.rb +1 -1
- data/lib/tap/generator/generators/config.rb +14 -14
- data/lib/tap/generator/generators/generator.rb +3 -3
- data/lib/tap/generator/generators/resource.rb +2 -0
- data/lib/tap/generator/generators/root.rb +4 -8
- data/lib/tap/generator/version.rb +9 -0
- data/templates/tap/generator/generators/command/command.erb +1 -2
- data/templates/tap/generator/generators/root/Rapfile +1 -1
- metadata +8 -6
- data/lib/tap/generator/exe.rb +0 -33
data/History
CHANGED
data/MIT-LICENSE
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
Copyright (c) 2009, Regents of the University of Colorado.
|
2
2
|
|
3
|
-
|
4
|
-
obtaining a copy of this software and associated documentation
|
5
|
-
files (the "Software"), to deal in the Software without
|
6
|
-
restriction, including without limitation the rights to use,
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the
|
9
|
-
Software is furnished to do so, subject to the following
|
10
|
-
conditions:
|
3
|
+
Copyright (c) 2009, Simon Chiang.
|
11
4
|
|
12
|
-
|
13
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README
CHANGED
@@ -13,7 +13,6 @@ easy to configure, subclass, and distribute.
|
|
13
13
|
documentation, development, and bug tracking.
|
14
14
|
|
15
15
|
* Website[http://tap.rubyforge.org]
|
16
|
-
* Lighthouse[http://bahuvrihi.lighthouseapp.com/projects/9908-tap-task-application/tickets]
|
17
16
|
* Github[http://github.com/bahuvrihi/tap/tree/master]
|
18
17
|
* {Google Group}[http://groups.google.com/group/ruby-on-tap]
|
19
18
|
|
@@ -44,14 +43,11 @@ Roll it back:
|
|
44
43
|
|
45
44
|
== Installation
|
46
45
|
|
47
|
-
Tap-Generator is available as a gem on
|
48
|
-
RubyForge[http://rubyforge.org/projects/tap]. Use:
|
46
|
+
Tap-Generator is available as a gem on Gemcutter[http://gemcutter.org/gems/tap-gen].
|
49
47
|
|
50
48
|
% gem install tap-gen
|
51
49
|
|
52
50
|
== Info
|
53
51
|
|
54
|
-
|
55
|
-
Developer:: {Simon Chiang}[http://bahuvrihi.wordpress.com], {Biomolecular Structure Program}[http://biomol.uchsc.edu/], {Hansen Lab}[http://hsc-proteomics.uchsc.edu/hansenlab/]
|
56
|
-
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
52
|
+
Developer:: {Simon Chiang}[http://bahuvrihi.wordpress.com]
|
57
53
|
License:: {MIT-Style}[link:files/MIT-LICENSE.html]
|
data/cmd/destroy.rb
CHANGED
@@ -6,16 +6,22 @@
|
|
6
6
|
# % tap generate root --help
|
7
7
|
#
|
8
8
|
|
9
|
-
require 'tap/generator/
|
10
|
-
require 'tap/generator/destroy'
|
9
|
+
require 'tap/generator/base'
|
11
10
|
|
12
|
-
|
13
|
-
env.extend Tap::Generator::Exe
|
11
|
+
app = Tap::App.instance
|
14
12
|
|
15
|
-
|
13
|
+
if ARGV.empty? || ARGV == ['--help']
|
14
|
+
constants = app.env.constants
|
15
|
+
generators = constants.summarize do |constant|
|
16
|
+
constant.types['generator']
|
17
|
+
end
|
18
|
+
|
16
19
|
puts Lazydoc.usage(__FILE__)
|
17
20
|
puts
|
18
|
-
puts
|
19
|
-
puts env.manifest('generator').summarize
|
21
|
+
puts generators
|
20
22
|
exit(1)
|
21
23
|
end
|
24
|
+
|
25
|
+
generator = app.build('class' => ARGV.shift, 'spec' => ARGV)
|
26
|
+
generator.signal(:set).call([Tap::Generator::Destroy])
|
27
|
+
generator.call(*ARGV)
|
data/cmd/generate.rb
CHANGED
@@ -6,16 +6,22 @@
|
|
6
6
|
# % tap generate root --help
|
7
7
|
#
|
8
8
|
|
9
|
-
require 'tap/generator/
|
10
|
-
require 'tap/generator/generate'
|
9
|
+
require 'tap/generator/base'
|
11
10
|
|
12
|
-
|
13
|
-
env.extend Tap::Generator::Exe
|
11
|
+
app = Tap::App.instance
|
14
12
|
|
15
|
-
|
13
|
+
if ARGV.empty? || ARGV == ['--help']
|
14
|
+
constants = app.env.constants
|
15
|
+
generators = constants.summarize do |constant|
|
16
|
+
constant.types['generator']
|
17
|
+
end
|
18
|
+
|
16
19
|
puts Lazydoc.usage(__FILE__)
|
17
20
|
puts
|
18
|
-
puts
|
19
|
-
puts env.manifest('generator').summarize
|
21
|
+
puts generators
|
20
22
|
exit(1)
|
21
|
-
end
|
23
|
+
end
|
24
|
+
|
25
|
+
generator = app.build('class' => ARGV.shift, 'spec' => ARGV)
|
26
|
+
generator.signal(:set).call([Tap::Generator::Generate])
|
27
|
+
generator.call(*ARGV)
|
data/lib/tap/generator/base.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'tap'
|
2
2
|
require 'tap/generator/manifest'
|
3
3
|
require 'tap/generator/arguments'
|
4
|
+
require 'tap/generator/generate'
|
5
|
+
require 'tap/generator/destroy'
|
4
6
|
|
5
7
|
module Tap
|
6
8
|
module Generator
|
@@ -73,11 +75,15 @@ module Tap
|
|
73
75
|
lazy_attr :args, :manifest
|
74
76
|
lazy_register :manifest, Arguments
|
75
77
|
|
76
|
-
config :destination_root, Dir.pwd
|
78
|
+
config :destination_root, Dir.pwd, # The destination root directory
|
79
|
+
:long => :destination,
|
80
|
+
:short => :d
|
77
81
|
config :pretend, false, &c.flag # Run but rollback any changes.
|
78
82
|
config :force, false, &c.flag # Overwrite files that already exist.
|
79
83
|
config :skip, false, &c.flag # Skip files that already exist.
|
80
84
|
|
85
|
+
signal :set # Set this generator to generate or destroy
|
86
|
+
|
81
87
|
# The generator-specific templates directory. By default:
|
82
88
|
# 'templates/path/to/name' for 'lib/path/to/name.rb'
|
83
89
|
attr_accessor :template_dir
|
@@ -95,6 +101,12 @@ module Tap
|
|
95
101
|
@template_dir = File.expand_path("templates/#{self.class.to_s.underscore}")
|
96
102
|
end
|
97
103
|
|
104
|
+
def set(mod)
|
105
|
+
mod = app.env[mod] unless mod.class == Module
|
106
|
+
extend(mod)
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
98
110
|
# Builds the manifest, then executes the actions of the manifest.
|
99
111
|
# Process returns the results of iterate, which normally will be
|
100
112
|
# an array of files and directories created (or destroyed) by self.
|
@@ -16,15 +16,15 @@ module Tap::Generator::Generators
|
|
16
16
|
#
|
17
17
|
class Config < Tap::Generator::Base
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
indented_dump = Configurable::Utils.dump(
|
19
|
+
dump_nest_configs = lambda do |leader, nest_config, block|
|
20
|
+
configurations = nest_config.nest_class.configurations
|
21
|
+
indented_dump = Configurable::Utils.dump(configurations, &block).gsub(/^/, " ")
|
22
22
|
"#{leader}: \n#{indented_dump}"
|
23
23
|
end
|
24
24
|
|
25
|
-
doc_format = lambda do |key,
|
25
|
+
doc_format = lambda do |key, config|
|
26
26
|
# get the description
|
27
|
-
desc =
|
27
|
+
desc = config.attributes[:desc]
|
28
28
|
doc = desc.to_s
|
29
29
|
doc = desc.comment if doc.empty?
|
30
30
|
|
@@ -32,11 +32,11 @@ module Tap::Generator::Generators
|
|
32
32
|
lines = Lazydoc::Utils.wrap(doc, 50).collect {|line| "# #{line}"}
|
33
33
|
lines << "" unless lines.empty?
|
34
34
|
|
35
|
-
if
|
35
|
+
if config.kind_of?(Configurable::NestConfig)
|
36
36
|
leader = "#{lines.join("\n")}#{key}"
|
37
|
-
|
37
|
+
DUMP_NEST_CONFIGS[leader, config, DOC_FORMAT]
|
38
38
|
else
|
39
|
-
default =
|
39
|
+
default = config.default
|
40
40
|
|
41
41
|
# setup formatting
|
42
42
|
leader = default == nil ? '# ' : ''
|
@@ -45,11 +45,11 @@ module Tap::Generator::Generators
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
nodoc_format = lambda do |key,
|
49
|
-
if
|
50
|
-
|
48
|
+
nodoc_format = lambda do |key, config|
|
49
|
+
if config.kind_of?(Configurable::NestConfig)
|
50
|
+
DUMP_NEST_CONFIGS[key, config, NODOC_FORMAT]
|
51
51
|
else
|
52
|
-
default =
|
52
|
+
default = config.default
|
53
53
|
|
54
54
|
# setup formatting
|
55
55
|
leader = default == nil ? '# ' : ''
|
@@ -58,8 +58,8 @@ module Tap::Generator::Generators
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
# Dumps
|
62
|
-
|
61
|
+
# Dumps nested configurations.
|
62
|
+
DUMP_NEST_CONFIGS = dump_nest_configs
|
63
63
|
|
64
64
|
# Dumps configurations as YAML with documentation,
|
65
65
|
# used when the doc config is true.
|
@@ -8,9 +8,7 @@ module Tap::Generator::Generators
|
|
8
8
|
class Generator < Resource
|
9
9
|
|
10
10
|
def manifest(m, const_name)
|
11
|
-
super
|
12
|
-
|
13
|
-
const = Tap::Env::Constant.new(const_name.camelize)
|
11
|
+
const = super
|
14
12
|
|
15
13
|
# make the templates directory
|
16
14
|
m.directory path('templates', const.path)
|
@@ -21,6 +19,8 @@ module Tap::Generator::Generators
|
|
21
19
|
m.file path('templates', const.path, 'template_file.erb') do |file|
|
22
20
|
file << "# A sample template file.\nkey: <%= key %>\n"
|
23
21
|
end
|
22
|
+
|
23
|
+
const
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -36,7 +36,7 @@ module Tap::Generator::Generators
|
|
36
36
|
|
37
37
|
# ::args ROOT, PROJECT_NAME=basename(ROOT)
|
38
38
|
def manifest(m, root, project_name=nil)
|
39
|
-
r = Tap::Root.new(root)
|
39
|
+
r = Tap::Root.new(File.expand_path(root, destination_root))
|
40
40
|
project_name = File.basename(r.root) if project_name == nil
|
41
41
|
|
42
42
|
m.directory r.root
|
@@ -69,11 +69,9 @@ module Tap::Generator::Generators
|
|
69
69
|
|
70
70
|
m.file(r['History']) if history
|
71
71
|
m.file(r['tap.yml']) do |file|
|
72
|
-
Configurable::Utils.dump(Tap::Env.configurations, file) do |key,
|
73
|
-
default = delegate.default(false)
|
74
|
-
|
72
|
+
Configurable::Utils.dump(Tap::Env.configurations, file) do |key, config|
|
75
73
|
# get the description
|
76
|
-
desc =
|
74
|
+
desc = config.attributes[:desc]
|
77
75
|
doc = desc.to_s
|
78
76
|
doc = desc.comment if doc.empty?
|
79
77
|
|
@@ -81,10 +79,8 @@ module Tap::Generator::Generators
|
|
81
79
|
lines = Lazydoc::Utils.wrap(doc, 78).collect {|line| "# #{line}"}
|
82
80
|
lines << "" unless lines.empty?
|
83
81
|
|
84
|
-
# note: this causes order to be lost...
|
85
|
-
default = default.to_hash if delegate.is_nest?
|
86
|
-
|
87
82
|
# setup formatting
|
83
|
+
default = config.default
|
88
84
|
leader = key == 'root' || default == nil ? '# ' : ''
|
89
85
|
config = YAML.dump({key => default})[5..-1].strip.gsub(/\n+/, "\n#{leader}")
|
90
86
|
"#{lines.join("\n")}#{leader}#{config}\n\n"
|
@@ -3,7 +3,7 @@ require 'tap/declarations'
|
|
3
3
|
module <%= project_name.camelize %>
|
4
4
|
extend Rap::Declarations
|
5
5
|
|
6
|
-
# ::
|
6
|
+
# :: your basic goodnight moon task
|
7
7
|
# Says goodnight with a configurable message.
|
8
8
|
task(:goodnight, :obj, :message => 'goodnight') do |task, args|
|
9
9
|
puts "#{task.message} #{args.obj}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tap-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Chiang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.19.0
|
24
24
|
version:
|
25
25
|
description:
|
26
26
|
email: simon.a.chiang@gmail.com
|
@@ -38,7 +38,6 @@ files:
|
|
38
38
|
- lib/tap/generator/arguments.rb
|
39
39
|
- lib/tap/generator/base.rb
|
40
40
|
- lib/tap/generator/destroy.rb
|
41
|
-
- lib/tap/generator/exe.rb
|
42
41
|
- lib/tap/generator/generate.rb
|
43
42
|
- lib/tap/generator/generators/command.rb
|
44
43
|
- lib/tap/generator/generators/config.rb
|
@@ -49,6 +48,7 @@ files:
|
|
49
48
|
- lib/tap/generator/generators/task.rb
|
50
49
|
- lib/tap/generator/manifest.rb
|
51
50
|
- lib/tap/generator/preview.rb
|
51
|
+
- lib/tap/generator/version.rb
|
52
52
|
- tap.yml
|
53
53
|
- templates/tap/generator/generators/command/command.erb
|
54
54
|
- templates/tap/generator/generators/generator/resource.erb
|
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
- MIT-LICENSE
|
69
69
|
has_rdoc: true
|
70
70
|
homepage: http://tap.rubyforge.org/tap-gen
|
71
|
+
licenses: []
|
72
|
+
|
71
73
|
post_install_message:
|
72
74
|
rdoc_options:
|
73
75
|
- --main
|
@@ -93,9 +95,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
95
|
requirements: []
|
94
96
|
|
95
97
|
rubyforge_project: tap
|
96
|
-
rubygems_version: 1.3.
|
98
|
+
rubygems_version: 1.3.5
|
97
99
|
signing_key:
|
98
|
-
specification_version:
|
100
|
+
specification_version: 3
|
99
101
|
summary: Generators for Tap
|
100
102
|
test_files: []
|
101
103
|
|
data/lib/tap/generator/exe.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'tap/generator/base'
|
2
|
-
|
3
|
-
module Tap
|
4
|
-
module Generator
|
5
|
-
|
6
|
-
# Methods used by the generate and destroy commands.
|
7
|
-
module Exe
|
8
|
-
|
9
|
-
def run(mod, argv=ARGV)
|
10
|
-
if argv.empty? || argv == ['--help']
|
11
|
-
yield
|
12
|
-
end
|
13
|
-
|
14
|
-
name = argv.shift
|
15
|
-
env, const = seek('generator', name, false)
|
16
|
-
|
17
|
-
unless const
|
18
|
-
raise "unknown generator: #{name}"
|
19
|
-
end
|
20
|
-
|
21
|
-
generator = const.constantize.parse!(argv)
|
22
|
-
|
23
|
-
# do not reassign dir unless a template directory
|
24
|
-
# is found, otherwise you get an error
|
25
|
-
if template_dir = env.class_path(:templates, generator) {|dir| File.directory?(dir) }
|
26
|
-
generator.template_dir = template_dir
|
27
|
-
end
|
28
|
-
|
29
|
-
generator.extend(mod).process(*argv)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|