Class: LazyModal::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/lazy_modal/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#inject_css_asset_fileObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/lazy_modal/install_generator.rb', line 21

def inject_css_asset_file
  %w(css scss sass).each do |ext|
    dest_file_path = "app/assets/stylesheets/application.#{ext}"
    if File.exist? "#{destination_root}/#{dest_file_path}"
      insert_into_file dest_file_path, :before => "*= require_self" do
        "*= require lazy_modal/application\n"
      end
      break
    end
  end
end

#inject_js_asset_fileObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/lazy_modal/install_generator.rb', line 9

def inject_js_asset_file
  %w(js coffee).each do |ext|
    dest_file_path = "app/assets/javascripts/application.#{ext}"
    if File.exist? "#{destination_root}/#{dest_file_path}"
      insert_into_file dest_file_path, :before => "//= require_tree" do
        "//= require lazy_modal/application\n"
      end
      break
    end
  end
end

#installObject



5
6
7
# File 'lib/generators/lazy_modal/install_generator.rb', line 5

def install
  route("mount LazyModal::Engine => '/'")
end