Class: Bootswatch::Fontawesome::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Bootswatch::Fontawesome::Generators::InstallGenerator
- Defined in:
- lib/generators/bootswatch/fontawesome/install/install_generator.rb
Constant Summary collapse
- DEFAULT_RAILS_APP_CSS_FILE =
'app/assets/stylesheets/application.css'
- DEFAULT_THEME_NAME =
'bootswatch'
Instance Method Summary collapse
- #add_assets ⇒ Object
- #add_stylesheets ⇒ Object
- #theme_info ⇒ Object
- #theme_name ⇒ Object
- #use_default_theme_name? ⇒ Boolean
Instance Method Details
#add_assets ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/bootswatch/fontawesome/install/install_generator.rb', line 30 def add_assets if use_default_theme_name? if File.exist?(DEFAULT_RAILS_APP_CSS_FILE) unless File.read(DEFAULT_RAILS_APP_CSS_FILE).include?('font-awesome') insert_into_file DEFAULT_RAILS_APP_CSS_FILE, " *= require #{theme_name}/font-awesome\n", :before => "*/" end end else if File.exist?("app/assets/stylesheets/#{theme_name}.css") unless File.read("app/assets/stylesheets/#{theme_name}.css").include?('font-awesome') insert_into_file "app/assets/stylesheets/#{theme_name}.css", " *= require #{theme_name}/font-awesome\n", :before => "*/" end end end end |
#add_stylesheets ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/bootswatch/fontawesome/install/install_generator.rb', line 59 def add_stylesheets stylesheets_dest_path = "app/assets/stylesheets/#{theme_name}" empty_directory stylesheets_dest_path less_variables = File.readlines(find_in_source_paths('variables.less')) less_imports = File.read(find_in_source_paths('font-awesome.less')).scan(Less::Rails::ImportProcessor::IMPORT_SCANNER).flatten.compact.uniq template 'font-awesome.less.tt', File.join(stylesheets_dest_path,'font-awesome.less'), {less_imports: less_imports, less_variables: less_variables, theme_name: theme_name, theme_info: theme_info} end |
#theme_info ⇒ Object
26 27 28 |
# File 'lib/generators/bootswatch/fontawesome/install/install_generator.rb', line 26 def theme_info "#{use_default_theme_name? ? 'bootstrap'.capitalize : theme_name.capitalize}" end |
#theme_name ⇒ Object
18 19 20 |
# File 'lib/generators/bootswatch/fontawesome/install/install_generator.rb', line 18 def theme_name file_name end |
#use_default_theme_name? ⇒ Boolean
22 23 24 |
# File 'lib/generators/bootswatch/fontawesome/install/install_generator.rb', line 22 def use_default_theme_name? theme_name === DEFAULT_THEME_NAME end |