Sha256: 70c1ac05f92990390c1e09aa4b60299c99adffdb24fa212ab60211447009060d

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

module ActiveadminAddons
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)

      def create_initializer
        template "initializer.rb", "config/initializers/activeadmin_addons.rb"
      end

      def add_javascripts
        file_path = 'app/assets/javascripts/active_admin.js.coffee'
        line_to_add = "#= require activeadmin_addons/all\n"
        reference = "#= require active_admin/base\n"
        inject_into_file(file_path, line_to_add, after: reference)
      end

      def add_stylesheets
        file_path = 'app/assets/stylesheets/active_admin'
        line_to_add = "//= require activeadmin_addons/all\n"

        begin
          prepend_file("#{file_path}.scss", line_to_add)
        rescue Errno::ENOENT
          prepend_file("#{file_path}.css.scss", line_to_add)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin_addons-0.12.0 lib/generators/activeadmin_addons/install/install_generator.rb
activeadmin_addons-0.11.0 lib/generators/activeadmin_addons/install/install_generator.rb