Class: ToolGenerator

Inherits:
Sprout::Generator::NamedBase
  • Object
show all
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

Instance Method Details

#executablesObject



42
43
44
# File 'lib/sprout/generators/tool/tool_generator.rb', line 42

def executables
  options[:executables]
end

#gem_versionObject



38
39
40
# File 'lib/sprout/generators/tool/tool_generator.rb', line 38

def gem_version
  options[:gem_version]
end

#major_versionObject



50
51
52
# File 'lib/sprout/generators/tool/tool_generator.rb', line 50

def major_version
  gem_version.split('.')[0]
end

#manifestObject

: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_versionObject



54
55
56
# File 'lib/sprout/generators/tool/tool_generator.rb', line 54

def minor_version
  gem_version.split('.')[1]
end

#sprout_specObject



46
47
48
# File 'lib/sprout/generators/tool/tool_generator.rb', line 46

def sprout_spec
  options[:sprout_spec]
end

#tiny_versionObject



58
59
60
# File 'lib/sprout/generators/tool/tool_generator.rb', line 58

def tiny_version
  gem_version.split('.')[2]
end

#tool_nameObject



62
63
64
# File 'lib/sprout/generators/tool/tool_generator.rb', line 62

def tool_name
  @tool_name ||= class_name.downcase
end