Sha256: eaa628df7ba879f1be21cf98a1f434fd5e1d1f3c987d1df974bde73b3628cc15

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Draper
  class InstallGenerator < Rails::Generators::Base

    desc <<-DESC
    Description:
        Generate application and spec decorators in your application.
    DESC

    class_option "test-framework", :type => :string, :default => "rspec", :aliases => "-t", :desc => "Test framework to be invoked"

    source_root File.expand_path('../templates', __FILE__)

    def build_application_decorator
      empty_directory 'app/decorators'
      template 'application_decorator.rb', File.join('app/decorators', 'application_decorator.rb')
    end

    def build_decorator_tests
      case options["test-framework"]
        when "rspec"
          build_application_decorator_spec
        when "test_unit"
          build_application_decorator_test
      end
    end

    private
    def build_application_decorator_spec
      empty_directory 'spec/decorators'
      template 'application_decorator_spec.rb', File.join('spec/decorators', 'application_decorator_spec.rb')
    end

    def build_application_decorator_test
      empty_directory 'test/decorators/'
      template 'application_decorator_test.rb', File.join('test/decorators', 'application_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/install/install_generator.rb
draper-0.11.0 lib/generators/draper/install/install_generator.rb