Sha256: 1b7d6c218fa01c348d824d3510c4811268348be079b191e6697b9876dc844a37

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

class ComponentGeneratorGenerator < RubiGen::Base
  
  default_options 
  
  attr_reader :name, :class_name, :generator_type, :generator_path
  
  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.empty?
    @name           = args.shift
    @class_name     = "#{name}_generator".camelize
    @generator_type = args.shift # optional
    @generator_path = @generator_type ? "#{generator_type}_generators" : "generators"
    extract_options
  end

  def manifest
    path = "#{generator_path}/#{name}"
    record do |m|
      # Ensure appropriate generators folder exists
      m.directory "#{path}/templates"
      m.directory "test"

      # Generator stub
      m.template "generator.rb",              "#{path}/#{name}_generator.rb"
      m.template "test.rb",                   "test/test_#{name}_generator.rb"
      m.file     "test_generator_helper.rb",  "test/test_generator_helper.rb"
      m.file     "usage",                     "#{path}/USAGE"
      m.readme   'readme'
    end
  end

  protected
    def banner
      <<-EOS
Creates a generator stub within your RubyGem.

USAGE: #{$0} #{spec.name} name [generator_type]
EOS
    end

    def add_options!(opts)
      # opts.separator ''
      # opts.separator 'Options:'
      # opts.on("-a", "--author=\"Your Name\"", String,
      #         "Generated app file will include your name.",
      #         "Default: none") { |options[:author]| }
    end
    
    def extract_options
    end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
newgem-0.13.2 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.13.1 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.13.0 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.13.4 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.13.3 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.14.0 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.14.1 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.14.2 rubygems_generators/component_generator/component_generator_generator.rb
newgem-0.13.5 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.2.1 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.2.3 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.1.0 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.1.1 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.2.4 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.2.2 rubygems_generators/component_generator/component_generator_generator.rb
rubigen-1.2.0 rubygems_generators/component_generator/component_generator_generator.rb