Sha256: 3befda96ea4f8bbc3b6a7d57e4f586df03aa704ac134322e7db1892ec1d8fa1a

Contents?: true

Size: 1.1 KB

Versions: 23

Compression:

Stored size: 1.1 KB

Contents

require 'rails'

module Alchemy
  module Generators
    class ViewsGenerator < ::Rails::Generators::Base
      ALCHEMY_VIEWS = %w(breadcrumb language_links messages_mailer navigation)

      desc "Generates Alchemy views for #{ALCHEMY_VIEWS.to_sentence}."

      class_option :only,
        type: :array,
        default: nil,
        desc: "List of views to copy. Available views are #{ALCHEMY_VIEWS.to_sentence}."

      class_option :except,
        type: :array,
        default: nil,
        desc: "List of views not to copy. Available views are #{ALCHEMY_VIEWS.to_sentence}."

      source_root File.expand_path("../../../../../app/views/alchemy", File.dirname(__FILE__))

      def copy_alchemy_views
        views_to_copy.each do |dir|
          directory dir, Rails.root.join('app/views/alchemy', dir)
        end
      end

      private

      def views_to_copy
        if @options['except']
          ALCHEMY_VIEWS - @options['except']
        elsif @options['only']
          ALCHEMY_VIEWS.select { |v| @options['only'].include?(v) }
        else
          ALCHEMY_VIEWS
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
alchemy_cms-4.0.6 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.7 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.6 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.5 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.4 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.3 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.5 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.2 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.1 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.4 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.0 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.3 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.2 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.0.rc2 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.0.rc1 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.1 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-4.0.0.beta lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.6.0 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.5.0 lib/rails/generators/alchemy/views/views_generator.rb
alchemy_cms-3.4.2 lib/rails/generators/alchemy/views/views_generator.rb