class Object

Constants

APP_ROOT
BASEDIRS

Installation skeleton. Intermediate directories are automatically created so don't sweat their absence here.

PROJECT_NAME
RAILS_ROOT
TMP_ROOT

Must set before requiring generator libs.

Public Class Methods

lookup_missing_generator(class_id) click to toggle source

Lookup missing generators using const_missing. This allows any generator to reference another without having to know its location: RubyGems, ~/.rubigen/generators, and APP_ROOT/generators.

# File lib/rubigen/lookup.rb, line 8
def lookup_missing_generator(class_id)
  if md = /(.+)Generator$/.match(class_id.to_s)
    name = md.captures.first.demodulize.underscore
    RubiGen::Base.active.lookup(name).klass
  else
    const_missing_before_generators(class_id)
  end
end
new(runtime_args, runtime_options = {}) click to toggle source
Calls superclass method
# File rubygems_generators/application_generator/templates/generator.rb, line 10
def initialize(runtime_args, runtime_options = {})
  super
  usage if args.empty?
  @destination_root = File.expand_path(args.shift)
  @name = base_name
  extract_options
end

Public Instance Methods

add_options!(opts) click to toggle source
# File rubygems_generators/application_generator/templates/generator.rb, line 44
def add_options!(opts)
  opts.separator ''
  opts.separator 'Options:'
  # For each option below, place the default
  # at the top of the file next to "default_options"
  # opts.on("-a", "--author=\"Your Name\"", String,
  #         "Some comment about this option",
  #         "Default: none") { |o| options[:author] = o }
  opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
end
banner() click to toggle source
convert_syntax(syntax, source) click to toggle source
# File script/txt2html, line 40
def convert_syntax(syntax, source)
  return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
end
extract_options() click to toggle source
# File rubygems_generators/application_generator/templates/generator.rb, line 55
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
manifest() click to toggle source
# File rubygems_generators/application_generator/templates/generator.rb, line 18
def manifest
  record do |m|
    # Ensure appropriate folder(s) exists
    m.directory ''
    BASEDIRS.each { |path| m.directory path }

    # Create stubs
    # m.template "template.rb",  "some_file_after_erb.rb"
    # m.template_copy_each ["template.rb", "template2.rb"]
    # m.file     "file",         "some_file_copied"
    # m.file_copy_each ["path/to/file", "path/to/file2"]

    m.dependency "install_rubigen_scripts", [destination_root, <%Q= scope_str %>],
      :shebang => options[:shebang], :collision => :force
  end
end