Sha256: 42a9e472392e41522f33f137d822040ab83c9e01ca12e67e2bf3dba61f77b5e0

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'rails/generators'

module Bootstrap
  module ComponentHelper
    module Generators
      class InstallGenerator < ::Rails::Generators::Base

        desc "This generator installs Bootstrap Helper to Asset Pipeline"

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

        def add_assets

          copy_file "index.css.scss", "app/assets/stylesheets/bootstrap_component_helper/index.css.scss"
          copy_file "index.js", "app/assets/javascripts/bootstrap_component_helper/index.js"

          js_manifest = 'app/assets/javascripts/application.js'

          if File.exist?(js_manifest)
            insert_into_file js_manifest, :before => "//= require_tree .\n" do
              <<-JS
//= require bootstrap_component_helper
              JS
            end
          end

          css_manifest = 'app/assets/stylesheets/application.css'

          if File.exist?(css_manifest)
            insert_into_file css_manifest, :before => " *= require_self\n" do
              <<-CSS
 *= require bootstrap_component_helper
              CSS
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap-component-helper-0.2.3.2 lib/generators/bootstrap/component_helper/install/install_generator.rb