Class: SpreeShowcase::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SpreeShowcase::Generators::InstallGenerator
- Defined in:
- lib/generators/spree_showcase/install/install_generator.rb
Instance Method Summary collapse
- #add_javascripts ⇒ Object
- #add_migrations ⇒ Object
- #add_overrides ⇒ Object
- #add_partials ⇒ Object
- #add_stylesheets ⇒ Object
- #complete ⇒ Object
- #copy_message ⇒ Object
- #messages ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_javascripts ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 25 def add_javascripts append_file 'app/assets/javascripts/store/all.js', "//= require jquery.flexslider\n" @source = "vendor/javascripts/jquery.flexslider.js" @dest = "vendor/assets/javascripts/store/jquery.flexslider.js" if copy_file(@source, @dest) << else << end end |
#add_migrations ⇒ Object
69 70 71 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 69 def add_migrations run 'bundle exec rake railties:install:migrations FROM=spree_showcase' end |
#add_overrides ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 15 def add_overrides @source = "overrides/showcase/add_showcase_to_home_layout.rb" @dest = "app/overrides/showcase/add_showcase_to_home_layout.rb" if copy_file(@source, @dest) << else << end end |
#add_partials ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 57 def add_partials puts %q{This partial is the template structure for displaying the slideshow and also includes the settings for the JavaScript plugin.} @source = "partials/_showcase.html.erb" @dest = "app/views/spree/slides/_showcase.html.erb" if copy_file(@source, @dest) << else << end end |
#add_stylesheets ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 36 def add_stylesheets inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_showcase\n", :before => /\*\//, :verbose => true @source = "stylesheets/store/showcase.css.scss" @dest = "app/assets/stylesheets/store/showcase.css.scss" if copy_file(@source, @dest) << self. else << self. end @source = "vendor/stylesheets/jquery.flexslider.css" @dest = "vendor/assets/stylesheets/store/jquery.flexslider.css" if copy_file(@source, @dest) << else << end puts "showcase.css styles are required by the extension and can be changed in anyway to fit your own _showcase.html.erb\n" end |
#complete ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 82 def complete puts "\n-------- Files copied --------\n" puts .join("\n") puts "\n---------------------------------\n" puts "\nEverything is done! To summarize, _showcase.html.erb => HTML template, showcase.css.scss & showcase.js.erb => assets. Edit these 3 files to fit run the slideshow." puts "\nPlease run rake assets:clean (IMPORTANT) to clear any precompiled assets from fresh install of Spree." end |
#copy_message ⇒ Object
10 11 12 13 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 10 def status = status.to_s.capitalize "Copy #{@source} into #{@dest}..." end |
#messages ⇒ Object
6 7 8 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 6 def @messages||= [] end |
#run_migrations ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/generators/spree_showcase/install/install_generator.rb', line 73 def run_migrations res = ask 'Would you like to run the migrations now? [Y/n]' if res == '' || res.downcase == 'y' run 'bundle exec rake db:migrate' else puts 'Skiping rake db:migrate, don\'t forget to run it!' end end |