Sha256: aa6ebac53a0baf330ee7f0bdf730e2d44ebd3f86c32aa003e3f0b6fe40d947bb

Contents?: true

Size: 1.01 KB

Versions: 28

Compression:

Stored size: 1.01 KB

Contents

module Rails
  module Generators
    class ConceptGenerator < NamedBase
      source_root File.expand_path('../templates', __FILE__)

      class_option :e, type: :string, desc: 'The template engine'
      argument :actions, type: :array, default: [], banner: 'action action2'

      check_class_collision suffix: 'Concept'


      def create_concept
        template 'concept.rb.erb', File.join('app/concepts', class_path, file_name, 'cell.rb')
      end

      def create_views
        states.each do |state|
          @state = state
          @path = File.join('app/concepts', class_path, file_name, 'views', "#{state}.#{template_engine}")
          template "view.#{template_engine}", @path
        end
      end

      hook_for :test_framework

      private

      def template_engine
        (options[:e] || Rails.application.config.app_generators.rails[:template_engine] || 'erb').to_s
      end

      # The show state is included by default
      def states
        (['show'] + actions).uniq
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
cells-rails-0.1.6 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.5 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.4 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.3 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.2 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.1 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.1.0 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.9 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.8 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.7 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.6 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.5 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.4 lib/rails/generators/concept/concept_generator.rb
cells-rails-0.0.3 lib/rails/generators/concept/concept_generator.rb
cells-4.0.5 lib/rails/generators/concept/concept_generator.rb
cells-4.0.4 lib/rails/generators/concept/concept_generator.rb
cells-4.0.3 lib/rails/generators/concept/concept_generator.rb
cells-4.0.2 lib/rails/generators/concept/concept_generator.rb
cells-4.0.1 lib/rails/generators/concept/concept_generator.rb
cells-4.0.0 lib/rails/generators/concept/concept_generator.rb