Sha256: 4dfddd18294e5cf1553e8a65a194145a439346161b13f3e81be487397a95b84a

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

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

      def copy_files
        template 'base.js.coffee', 'app/assets/javascripts/base.js.coffee'
        template 'global.js.coffee', 'app/assets/javascripts/global.js.coffee'
      end

      def insert_load_order
        if File.exist?('app/assets/javascripts/application.js')
          inject_into_file 'app/assets/javascripts/application.js',  "\n//= require base", before: "\n//= require_tree ."
        elsif File.exist?('app/assets/javascripts/application.js.coffee')
          inject_into_file 'app/assets/javascripts/application.js.coffee', "\n#= require base", before: "\n#= require_tree ."
        end
      end

      def insert_layout_javascript
        say <<-RUBY
In order to complete installation, you must include the following helper BEFORE the closing body tag in the application layout:

<%= include_rails_script %>

        RUBY
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_script-0.0.7 lib/generators/rails_script/install/install_generator.rb