Sha256: ce0a414ede19d15b8e29e1b8646284c14afc05c07fd7ebf3d030c4e3fc9c8add

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Merb::Generators
  
  class RubossResourceGenerator < Generator
    
    desc <<-DESC
      Generates a new ruboss resource.
    DESC
    
    first_argument :name, :required => true, :desc => "resource name (singular)"
    second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated resource model properties in form of name:type. Example: state:string"

    option :testing_framework, :desc => 'Testing framework to use (one of: rspec, test_unit)'
    option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
    
    invoke :model do |generator|
      generator.new(destination_root, options, model_name, attributes)
    end
    
    invoke :ruboss_resource_controller do |generator|
      generator.new(destination_root, options, controller_name, attributes)
    end
    
    def controller_name
      name.pluralize
    end
    
    def model_name
      name
    end

    def after_generation
      STDOUT << message("Don't forget to set your resource route in config/router.rb for instance: resources :#{model_name.downcase}s ")
    end
  end
  
  add :ruboss_resource, RubossResourceGenerator
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dima-ruboss4ruby-1.0.5 merb_generators/ruboss_resource.rb