Sha256: f8230a9c92dc2470e3d3b57a3f140dd04832d3e4a0b7fb98ce1e2c1d2de697e3

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

module Ecm
  module Tags
    module Generators
      class InstallGenerator < Rails::Generators::Base
        desc 'Generates the initializer'

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

        attr_reader :base_controller_class_name

        def initialize(*args)
          super
          @base_controller_class_name = ENV.fetch('BASE_CONTROLLER_CLASS_NAME') { '::FrontendController' }
        end

        def generate_initializer
          template 'initializer.rb', 'config/initializers/ecm_tags.rb'
        end

        def generate_routes
          route File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
        end

        def add_helpers_to_application_controller
          inject_into_file 'app/controllers/application_controller.rb', before: "\nend" do
            File.read(File.join(File.expand_path('../templates', __FILE__), 'application_controller.source'))
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecm_tags-2.2.1 lib/generators/ecm/tags/install/install_generator.rb
ecm_tags-2.2.0 lib/generators/ecm/tags/install/install_generator.rb
ecm_tags-2.1.0 lib/generators/ecm/tags/install/install_generator.rb