Class: Furatto::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Furatto::Generators::InstallGenerator
- Defined in:
- lib/generators/furatto/install_generator.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
Instance Method Summary collapse
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
10 11 12 |
# File 'lib/generators/furatto/install_generator.rb', line 10 def app_name @app_name end |
Instance Method Details
#add_assets ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/furatto/install_generator.rb', line 12 def add_assets app = ::Rails.application @app_name = app.class.to_s.split("::").first # rails_ujs breaks, need to incorporate rails-behavior plugin for this to work seamlessly # gsub_file "app/assets/javascripts/application#{detect_js_format[0]}", /\/\/= require jquery\n/, "" insert_into_file "app/assets/javascripts/application#{detect_js_format[0]}", "#{detect_js_format[1]} require furatto\n", :after => "jquery_ujs\n" settings_file = File.join(File.dirname(__FILE__),"..", "..", "..", "vendor", "assets", "stylesheets", "furatto", "_settings.scss") create_file "app/assets/stylesheets/furatto_overrides.scss", File.read(settings_file) append_to_file "app/assets/stylesheets/furatto_overrides.scss", "\n@import 'furatto';\n" insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "\n#{detect_css_format[1]} require furatto_overrides\n", :after => "require_self" end |
#create_layout ⇒ Object
39 40 41 |
# File 'lib/generators/furatto/install_generator.rb', line 39 def create_layout template 'application.html.erb', "app/views/layouts/#{layout_file_name}.html.erb" end |
#detect_css_format ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/generators/furatto/install_generator.rb', line 31 def detect_css_format return ['.css', ' *='] if File.exist?('app/assets/stylesheets/application.css') return ['.css.sass', ' //='] if File.exist?('app/assets/stylesheets/application.css.sass') return ['.sass', ' //='] if File.exist?('app/assets/stylesheets/application.sass') return ['.css.scss', ' //='] if File.exist?('app/assets/stylesheets/application.css.scss') return ['.scss', ' //='] if File.exist?('app/assets/stylesheets/application.scss') end |
#detect_js_format ⇒ Object
25 26 27 28 29 |
# File 'lib/generators/furatto/install_generator.rb', line 25 def detect_js_format return ['.coffee', '#='] if File.exist?('app/assets/javascripts/application.coffee') return ['.js.coffee', '#='] if File.exist?('app/assets/javascripts/application.js.coffee') return ['.js', '//='] if File.exist?('app/assets/javascripts/application.js') end |