Sha256: ff57f06e9775a6b2a97b4771400bf840d23626fcee5d3cf73a40210404603ced

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module Mousetrap

  # Mousetrap rails generators module
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      desc "Copy Mousetrap default files"
      source_root File.expand_path('../templates', __FILE__)

      # Copy keybindings scripts to assets folder
      def copy_mousetrap
        copy_file "keybindings.js.coffee", "app/assets/javascripts/keybindings.js.coffee"
      end

      # Inject moustrap scripts to application.js
      def add_javascript_assets
        if File.exist?('app/assets/javascripts/application.js')
          insert_into_file "app/assets/javascripts/application.js", "//= require mousetrap\n", :after => "jquery_ujs\n"
        else
          copy_file "application.js", "app/assets/javascripts/application.js"
        end
      end

      # Inject moustrap styles to application.css
      def add_css_assets
        if File.exist?('app/assets/stylesheets/application.css')
          insert_into_file "app/assets/stylesheets/application.css", "*= require mousetrap\n ", :before => "*= require_tree ."
        else
          copy_file "application.css", "app/assets/stylesheets/application.css"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mousetrap-rails-0.0.10 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.9 lib/generators/mousetrap/install/install_generator.rb