Sha256: 7e78f7fe6539634c8bcf7899a6bd989ca8668b3c75154e22f76b6c8416ec9934
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Draper class DecoratorGenerator < Rails::Generators::Base desc <<-DESC Description: Generate a decorator for the given model. Example: rails g draper:decorator Article generates: "app/decorators/article_decorator" "spec/decorators/article_decorator_spec" DESC argument :resource_name, :type => :string class_option "test-framework", :type => :string, :default => "rspec", :aliases => "-t", :desc => "Test framework to be invoked" source_root File.expand_path('../templates', __FILE__) DECORATORS_ROOT = 'app/decorators/' def build_model_decorator template 'decorator.rb', "#{DECORATORS_ROOT}#{resource_name.singularize}_decorator.rb" end def build_decorator_tests case options["test-framework"] when "rspec" build_decorator_spec when "test_unit" build_decorator_test end end private def build_decorator_spec empty_directory 'spec/decorators' template 'decorator_spec.rb', File.join('spec/decorators', "#{resource_name.singularize}_decorator_spec.rb") end def build_decorator_test empty_directory 'test/decorators/' template 'decorator_test.rb', File.join('test/decorators', "#{resource_name.singularize}_decorator_test.rb") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
draper-0.11.1 | lib/generators/draper/decorator/decorator_generator.rb |
draper-0.11.0 | lib/generators/draper/decorator/decorator_generator.rb |