class InstallRubigenScriptsGenerator
Constants
- DEFAULT_SHEBANG
Attributes
path[R]
scopes[R]
Public Class Methods
new(runtime_args, runtime_options = {})
click to toggle source
Calls superclass method
RubiGen::Base.new
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 9 def initialize(runtime_args, runtime_options = {}) super usage if args.length < 2 # requires path and at least one scope @path = args.shift @destination_root = File.expand_path(path) @scopes = args.map { |scope| scope.to_sym } default_scopes extract_options end
Public Instance Methods
manifest()
click to toggle source
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 19 def manifest script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] } windows = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/) record do |m| # Ensure appropriate folder(s) exists m.directory "script" %w( generate destroy ).each do |file| m.template "script/#{file}", "script/#{file}", script_options m.template "script/win_script.cmd", "script/#{file}.cmd", :assigns => { :filename => file } if windows end end end
scopes_str()
click to toggle source
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 35 def scopes_str scopes.inspect end
Protected Instance Methods
add_options!(opts)
click to toggle source
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 50 def add_options!(opts) opts.separator '' opts.separator 'Options:' opts.on("-r", "--ruby=path", String, "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).", "Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v } opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.") end
default_scopes()
click to toggle source
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 66 def default_scopes if (scopes.map { |s| s.to_s } & %w[test_unit rspec test_spec mini_spec javascript_test]).blank? scopes << :test_unit end end
extract_options()
click to toggle source
# File generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb, line 59 def extract_options # for each option, extract it into a local variable (and create an "attr_reader :author" at the top) # Templates can access these value via the attr_reader-generated methods, but not the # raw instance variable value. # @author = options[:author] end