Sha256: f0ee142ddfcfd0bd2b3326f30e16eab6e7b1f41f3271058a0c1aab140e66a6d5

Contents?: true

Size: 1.68 KB

Versions: 18

Compression:

Stored size: 1.68 KB

Contents

class ClassGenerator < RubiGen::Base
  
  attr_reader :name, :package, :class_name, :src_dir
  
  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.empty?
    @name = args.shift
        
    @src_dir = args.shift unless args.empty?    
    @src_dir ||= "src"
    
    # Split com.foo.Bar into package ["com", "foo" ] and class_name "Bar"
    if @name.rindex(".")
      @package = @name[0...@name.rindex(".")] 
      @class_name = @name[@name.rindex(".")+1..-1]
    else
      @package = ""
      @class_name = @name
    end
    
    extract_options
  end

  def manifest
    record do |m|
      # Ensure appropriate folder(s) exists      
      
      dir = src_dir
      unless package.blank?
        dir = File.join(src_dir, package.split("."))
        m.directory dir 
      end
      
      m.template "Class.as", File.join(dir, class_name + ".as")
      
    end
  end

  protected
    def banner
      ""
    end

    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") { |options[:author]| }
      # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
    end
    
    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
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
airake-0.2.10 air_generators/class/class_generator.rb
airake-0.2.11 air_generators/class/class_generator.rb
airake-0.2.12 air_generators/class/class_generator.rb
airake-0.2.13 air_generators/class/class_generator.rb
airake-0.2.14 air_generators/class/class_generator.rb
airake-0.2.5 air_generators/class/class_generator.rb
airake-0.3.2 air_generators/class/class_generator.rb
airake-0.2.7 air_generators/class/class_generator.rb
airake-0.2.8 air_generators/class/class_generator.rb
airake-0.3.1 air_generators/class/class_generator.rb
airake-0.4.0 air_generators/class/class_generator.rb
airake-0.2.9 air_generators/class/class_generator.rb
airake-0.2.6 air_generators/class/class_generator.rb
airake-0.4.2 air_generators/class/class_generator.rb
airake-0.4.3 air_generators/class/class_generator.rb
airake-0.4.5 air_generators/class/class_generator.rb
airake-0.4.1 air_generators/class/class_generator.rb
airake-0.4.4 air_generators/class/class_generator.rb