Class: Bootswatch::Generators::ImportGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Bootswatch::Generators::ImportGenerator
- Defined in:
- lib/generators/bootswatch/import/import_generator.rb
Instance Method Summary collapse
Instance Method Details
#import_less ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/bootswatch/import/import_generator.rb', line 23 def import_less stylesheets_dest_path = "app/assets/stylesheets/#{theme_directory}" empty_directory stylesheets_dest_path # let's auto backup if a custom variables.less already exists if File.exist?(File.join(stylesheets_dest_path,'variables.less')) File.rename(File.join(stylesheets_dest_path,'variables.less'), File.join(stylesheets_dest_path,'variables.less_bak')) end get File.join(theme_repo_url,'variables.less'), File.join(stylesheets_dest_path,'variables.less') # let's auto backup if a custom bootswatch.less already exists if File.exist?(File.join(stylesheets_dest_path,'bootswatch.less')) File.rename(File.join(stylesheets_dest_path,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.less_bak')) end get File.join(theme_repo_url,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.less') prepend_to_file File.join(stylesheets_dest_path,'bootswatch.less') do "@import \"base\";\n" end end |
#theme_directory ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/generators/bootswatch/import/import_generator.rb', line 11 def theme_directory if class_path.empty? theme_name else class_path.first end end |
#theme_name ⇒ Object
7 8 9 |
# File 'lib/generators/bootswatch/import/import_generator.rb', line 7 def theme_name file_name end |
#theme_repo_url ⇒ Object
19 20 21 |
# File 'lib/generators/bootswatch/import/import_generator.rb', line 19 def theme_repo_url "https://raw.github.com/thomaspark/bootswatch/gh-pages/#{theme_name}" end |