Class: CoffeeMiddleware::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ResourceHelpers
Defined in:
lib/generators/coffee_middleware/install/install_generator.rb

Instance Method Summary collapse

Methods included from ResourceHelpers

#application_name, #coffee_middleware_path, #js_app_name

Instance Method Details

#create_app_fileObject



28
29
30
# File 'lib/generators/coffee_middleware/install/install_generator.rb', line 28

def create_app_file
  template "app.coffee", "app/assets/javascripts/application/#{application_name.underscore}.js.coffee"
end

#create_dir_layoutObject



21
22
23
24
25
26
# File 'lib/generators/coffee_middleware/install/install_generator.rb', line 21

def create_dir_layout
  %W{models views}.each do |dir|
    empty_directory "app/assets/javascripts/application/#{dir}"
    create_file "app/assets/javascripts/application/#{dir}/.gitkeep" unless options[:skip_git]
  end
end

#inject_middlewareObject



15
16
17
18
19
# File 'lib/generators/coffee_middleware/install/install_generator.rb', line 15

def inject_middleware
  inject_into_file "app/assets/javascripts/application.js", :after => "//= require jquery_ujs" do
    "\n//= require underscore\n//= require backbone\n//= require coffee_middleware\n//= require application/#{application_name.underscore}"
  end
end