Sha256: 9f7c00afc1836c77749d17a1d4b7741414554cdb89880071cf54192cb18db4e9

Contents?: true

Size: 1.1 KB

Versions: 51

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "rails"

module Alchemy
  module Generators
    class ViewsGenerator < ::Rails::Generators::Base
      ALCHEMY_VIEWS = %w[breadcrumb language_links messages_mailer]

      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", __dir__)

      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

51 entries across 51 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.8 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.1.13 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.0.16 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.3.4 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.3.3 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.3.2 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.7 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.3.1 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.3.0 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.6 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.5 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.1.12 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.0.15 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.4 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.1.11 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.3 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.1.10 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.2.2 lib/generators/alchemy/views/views_generator.rb
alchemy_cms-7.1.9 lib/generators/alchemy/views/views_generator.rb