Class: Metro::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/metro/install/install_generator.rb', line 10

def add_assets
  if File.exist?('app/assets/javascripts/application.js')
    insert_into_file "app/assets/javascripts/application.js", "//= require metro-ui\n", :after => "jquery_ujs\n"
  else
    copy_file "application.js", "app/assets/javascripts/application.js"
  end

  if File.exist?('app/assets/stylesheets/application.css')
    content = File.read("app/assets/stylesheets/application.css")
    unless content.match(/require_tree\s+\.\s*$/)
      style_require_block = " *= require metro_ui_and_overrides\n"
      insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
    end
  else
    copy_file "application.css", "app/assets/stylesheets/application.css"
  end

end

#add_metro_uiObject



29
30
31
# File 'lib/generators/metro/install/install_generator.rb', line 29

def add_metro_ui
  copy_file "metro_ui_and_overrides.less", "app/assets/stylesheets/metro_ui_and_overrides.css.less"
end

#cleanup_legacyObject



33
34
35
# File 'lib/generators/metro/install/install_generator.rb', line 33

def cleanup_legacy
  gsub_file("app/assets/stylesheets/application.css", %r|\s*\*=\s*metro-ui/modern\s*\n|, "")
end