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 CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.3.0 / 2009-12-05
2
+
3
+ Updates for Tap-0.19.0
4
+
5
+ * manifest for resource generator now returns const
6
+
1
7
  == 0.2.0 / 2009-06-17
2
8
 
3
9
  Updates for Tap-0.18.0
@@ -1,22 +1,21 @@
1
1
  Copyright (c) 2009, Regents of the University of Colorado.
2
2
 
3
- Permission is hereby granted, free of charge, to any person
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
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
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
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
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
- Copyright (c) 2009, Regents of the University of Colorado.
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]
@@ -6,16 +6,22 @@
6
6
  # % tap generate root --help
7
7
  #
8
8
 
9
- require 'tap/generator/exe'
10
- require 'tap/generator/destroy'
9
+ require 'tap/generator/base'
11
10
 
12
- env = Tap::Env.instance
13
- env.extend Tap::Generator::Exe
11
+ app = Tap::App.instance
14
12
 
15
- env.run(Tap::Generator::Destroy, ARGV) do
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 "generators:"
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)
@@ -6,16 +6,22 @@
6
6
  # % tap generate root --help
7
7
  #
8
8
 
9
- require 'tap/generator/exe'
10
- require 'tap/generator/generate'
9
+ require 'tap/generator/base'
11
10
 
12
- env = Tap::Env.instance
13
- env.extend Tap::Generator::Exe
11
+ app = Tap::App.instance
14
12
 
15
- env.run(Tap::Generator::Generate, ARGV) do
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 "generators:"
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)
@@ -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 # The destination root directory
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.
@@ -1,7 +1,7 @@
1
1
  module Tap
2
2
  module Generator
3
3
 
4
- # A mixin defining how to run manifest actions in reverse.
4
+ # :startdoc::module A mixin defining how to run manifest actions in reverse.
5
5
  module Destroy
6
6
 
7
7
  # Iterates over the actions in reverse, and collects the results.
@@ -3,7 +3,7 @@ require 'tempfile'
3
3
  module Tap
4
4
  module Generator
5
5
 
6
- # A mixin defining how to run manifest actions.
6
+ # :startdoc::module A mixin defining how to run manifest actions.
7
7
  module Generate
8
8
 
9
9
  # Creates the target directory if it doesn't exist. When pretend is
@@ -16,15 +16,15 @@ module Tap::Generator::Generators
16
16
  #
17
17
  class Config < Tap::Generator::Base
18
18
 
19
- dump_delegates = lambda do |leader, delegate, block|
20
- nested_delegates = delegate.default(false).delegates
21
- indented_dump = Configurable::Utils.dump(nested_delegates, &block).gsub(/^/, " ")
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, delegate|
25
+ doc_format = lambda do |key, config|
26
26
  # get the description
27
- desc = delegate.attributes[: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 delegate.is_nest?
35
+ if config.kind_of?(Configurable::NestConfig)
36
36
  leader = "#{lines.join("\n")}#{key}"
37
- DUMP_DELEGATES[leader, delegate, DOC_FORMAT]
37
+ DUMP_NEST_CONFIGS[leader, config, DOC_FORMAT]
38
38
  else
39
- default = delegate.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, delegate|
49
- if delegate.is_nest?
50
- DUMP_DELEGATES[key, delegate, NODOC_FORMAT]
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 = delegate.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 a nested configuration.
62
- DUMP_DELEGATES = dump_delegates
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
@@ -18,6 +18,8 @@ module Tap::Generator::Generators
18
18
  m.directory File.dirname(test_path)
19
19
  m.template test_path, "test.erb", :const => const
20
20
  end
21
+
22
+ const
21
23
  end
22
24
  end
23
25
  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, delegate|
73
- default = delegate.default(false)
74
-
72
+ Configurable::Utils.dump(Tap::Env.configurations, file) do |key, config|
75
73
  # get the description
76
- desc = delegate.attributes[: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"
@@ -0,0 +1,9 @@
1
+ module Tap
2
+ module Generator
3
+ MAJOR = 0
4
+ MINOR = 3
5
+ TINY = 0
6
+
7
+ VERSION="#{MAJOR}.#{MINOR}.#{TINY}"
8
+ end
9
+ end
@@ -4,8 +4,7 @@
4
4
  # and application information, then exits.
5
5
  #
6
6
 
7
- env = Tap::Env.instance
8
- app = Tap::App.new
7
+ app = Tap::App.instance
9
8
 
10
9
  #
11
10
  # handle options
@@ -3,7 +3,7 @@ require 'tap/declarations'
3
3
  module <%= project_name.camelize %>
4
4
  extend Rap::Declarations
5
5
 
6
- # ::desc your basic goodnight moon task
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.2.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-06-17 00:00:00 -06:00
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.18.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.1
98
+ rubygems_version: 1.3.5
97
99
  signing_key:
98
- specification_version: 2
100
+ specification_version: 3
99
101
  summary: Generators for Tap
100
102
  test_files: []
101
103
 
@@ -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