Sha256: 5479a16fa2d268be9008c69ad7949c64c52273d0f205d13b05a192a627a56e33

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

module Mousetrap

  # Mousetrap rails generators module
  module Generators

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

      # Copy keybindings scripts to assets folder. This coffescript file
      # provides unobtrusive way to use HTML5 data attributes for
      # binding click and focus events to DOM elements.
      def copy_mousetrap
        copy_file "keybindings.js.coffee", "app/assets/javascripts/keybindings.js.coffee"
      end

      # Inject mousetrap scripts to manifest file `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 mousetrap styles to manifest file `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

3 entries across 3 versions & 1 rubygems

Version Path
mousetrap-rails-1.4.6 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.12 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.11 lib/generators/mousetrap/install/install_generator.rb