Sha256: 9f3d023c86904766a8eb74e9e05d49f4797fcfbd6ce17681ada83e4c16dfd0c4

Contents?: true

Size: 1002 Bytes

Versions: 5

Compression:

Stored size: 1002 Bytes

Contents

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

      def copy_mousetrap
        copy_file "keybindings.js.coffee", "app/assets/javascripts/keybindings.js.coffee"
      end

      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

      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

5 entries across 5 versions & 1 rubygems

Version Path
mousetrap-rails-0.0.8 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.7 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.6 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.5 lib/generators/mousetrap/install/install_generator.rb
mousetrap-rails-0.0.4 lib/generators/mousetrap/install/install_generator.rb