Class: ToolGenerator
- Inherits:
-
Sprout::Generator::NamedBase
- Object
- Sprout::Generator::NamedBase
- ToolGenerator
- Defined in:
- lib/sprout/generators/tool/tool_generator.rb
Overview
Generate a new Sprout tool project. This generator can be executed as follows:
sprout -n developer Flex3SDK
Instance Method Summary collapse
- #executables ⇒ Object
- #gem_version ⇒ Object
- #major_version ⇒ Object
-
#manifest ⇒ Object
:nodoc:.
- #minor_version ⇒ Object
- #sprout_spec ⇒ Object
- #tiny_version ⇒ Object
- #tool_name ⇒ Object
Instance Method Details
#executables ⇒ Object
42 43 44 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 42 def executables [:executables] end |
#gem_version ⇒ Object
38 39 40 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 38 def gem_version [:gem_version] end |
#major_version ⇒ Object
50 51 52 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 50 def major_version gem_version.split('.')[0] end |
#manifest ⇒ Object
:nodoc:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 12 def manifest record do |m| # Create outer directory m.directory tool_name m.directory File.join(tool_name, 'bin') unless executables.size == 0 # Create rakefile m.template 'rakefile.erb', File.join(tool_name, 'rakefile.rb') # Create version.rb file version_path = File.join(tool_name, 'lib', 'sprout', tool_name) m.directory version_path m.template 'version.erb', File.join(version_path, 'version.rb') # Copy sprout.spec to new project new_spec = File.join(tool_name, 'sprout.spec') m.template 'sprout.spec', new_spec # Create rubygem binaries for each executable executables.each do |binary| target = File.join(tool_name, 'bin', File.basename(binary)) m.template 'binary.erb', target, :assigns => { :binary => binary } end end end |
#minor_version ⇒ Object
54 55 56 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 54 def minor_version gem_version.split('.')[1] end |
#sprout_spec ⇒ Object
46 47 48 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 46 def sprout_spec [:sprout_spec] end |
#tiny_version ⇒ Object
58 59 60 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 58 def tiny_version gem_version.split('.')[2] end |
#tool_name ⇒ Object
62 63 64 |
# File 'lib/sprout/generators/tool/tool_generator.rb', line 62 def tool_name @tool_name ||= class_name.downcase end |