Sha256: b18077236220f3286b1a56cbb149f7b9fa8a516edf70878eed37b1c5963c6675

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

require 'rails'

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

      desc "Installs Alchemy into your App."

      class_option :skip_demo_files,
        type: :boolean,
        default: false,
        desc: "Skip creation of demo element, page and application layout."

      source_root File.expand_path('files', File.dirname(__FILE__))

      def create_view_dirs
        %w(elements page_layouts).each do |dir|
          empty_directory Rails.root.join("app/views/alchemy/#{dir}")
        end
      end

      def copy_config
        copy_file "#{config_path}/config.yml",
          Rails.root.join("config/alchemy/config.yml")
      end

      def copy_yml_files
        %w(elements page_layouts).each do |file|
          template "#{current_path}/templates/#{file}.yml.tt",
            Rails.root.join("config/alchemy/#{file}.yml")
        end
      end

      def copy_demo_views
        return if @options[:skip_demo_files]

        copy_file "application.html.erb",
          Rails.root.join("app/views/layouts/application.html.erb")
        copy_file "alchemy.elements.css.scss",
          Rails.root.join("app/assets/stylesheets/alchemy.elements.css.scss")

        [
          "_article_editor.html.erb",
          "_article_view.html.erb"
        ].each do |file|
          copy_file file, Rails.root.join("app/views/alchemy/elements/#{file}")
        end

        copy_file "_standard.html.erb",
          Rails.root.join("app/views/alchemy/page_layouts/_standard.html.erb")

        %w(de en es).each do |locale|
          copy_file "alchemy.#{locale}.yml",
            Rails.root.join("config/locales/alchemy.#{locale}.yml")
        end
      end

      private

      def config_path
        @_config_path ||= File.expand_path('../../../../../config/alchemy', current_path)
      end

      def current_path
        @_current_path ||= File.dirname(__FILE__)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 lib/rails/generators/alchemy/install/install_generator.rb
lc_alchemy_cms-3.2.1 lib/rails/generators/alchemy/install/install_generator.rb
lc_alchemy_cms-3.2.0 lib/rails/generators/alchemy/install/install_generator.rb
alchemy_cms-3.2.0 lib/rails/generators/alchemy/install/install_generator.rb
alchemy_cms-3.2.0.rc1 lib/rails/generators/alchemy/install/install_generator.rb