Sha256: ed59c4c6bca6d8c233a661b276bc23897ab01ec84b31a48126641835c08d62ac

Contents?: true

Size: 879 Bytes

Versions: 7

Compression:

Stored size: 879 Bytes

Contents

module Apimaster::Generators
  class ModelGenerator < Create
    attr_reader :app_name, :module_name, :name

    def initialize(runtime_args, runtime_options = {})
      super
      raise 'Unknown app directory.' unless File.exists?('./Gemfile')
      @app_name     = File.basename(File.expand_path('./'))
      @module_name  = camelize(app_name)
      @name     = args[0]
      raise 'Undefined app name.' unless @app_name
    end

    def manifest
      record do |m|
        m.template "app/models/example.rb.erb", "app/models/#{name}.rb"
        m.template "test/unit/example_test.rb.erb", "test/unit/#{name}_test.rb"
        m.template "test/factory/example_factory.rb.erb", "test/factory/#{name}_factory.rb"
      end
    end

    private
      def banner
        <<-EOS
  Creates an Apimaster model.

  USAGE: apimaster model your_model_name"

  EOS
      end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
apimaster-0.1.4 lib/apimaster/generators/model_generator.rb
apimaster-0.1.3 lib/apimaster/generators/model_generator.rb
apimaster-0.1.2 lib/apimaster/generators/model_generator.rb
apimaster-0.1.1 lib/apimaster/generators/model_generator.rb
apimaster-0.0.7 lib/apimaster/generators/model_generator.rb
apimaster-0.0.6 lib/apimaster/generators/model_generator.rb
apimaster-0.0.5 lib/apimaster/generators/model_generator.rb