Skip to content
Browse files

fix dummy hooks and add tweak install generator

  • Loading branch information...
1 parent 406d401 commit 053dc5b6d45ed8397162356cc99fb702abf4d275 @citrus committed Jan 24, 2012
View
28 lib/generators/spree_wholesale/install/install_generator.rb
@@ -1,28 +0,0 @@
-module SpreeWholesale
- module Generators
- class InstallGenerator < Rails::Generators::Base
- def add_javascripts
- append_file "app/assets/javascripts/store/all.js", "//= require wholesaler_address\n"
- append_file "app/assets/javascripts/admin/all.js", "//= require wholesaler_address\n"
- end
-
- def add_stylesheets
- inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/wholesale\n", :before => /\*\//, :verbose => true
- inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/wholesalers\n", :before => /\*\//, :verbose => true
- end
-
- def add_migrations
- run 'bundle exec rake railties:install:migrations FROM=spree_wholesale'
- end
-
- 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
- end
- end
-end
View
41 lib/generators/spree_wholesale/install_generator.rb
@@ -0,0 +1,41 @@
+module SpreeWholesale
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+
+ class_option :skip_migrations, :type => :boolean, :default => false, :description => "Skips the `run_migrations` step"
+
+ desc "Installs required stylesheets, javascripts and migrations for spree_wholesale"
+
+ def add_javascripts
+ append_file "app/assets/javascripts/store/all.js", "//= require wholesaler_address\n"
+ append_file "app/assets/javascripts/admin/all.js", "//= require wholesaler_address\n"
+ end
+
+ def add_stylesheets
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/wholesale\n", :before => /\*\//, :verbose => true
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/wholesalers\n", :before => /\*\//, :verbose => true
+ end
+
+ def install_migrations
+ puts "Copying migrations..."
+ cmd = "bundle exec rake railties:install:migrations FROM=spree_wholesale"
+ silence_stream(STDOUT) do
+ silence_warnings do
+ run cmd
+ end
+ end
+ end
+
+ def run_migrations
+ return if options[:skip_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 "Skipping rake db:migrate, don't forget to run it!"
+ end
+ end
+
+ end
+ end
+end
View
2 test/dummy_hooks/after_migrate.rb.sample
@@ -1,2 +1,2 @@
# assume wholesale prices
-rake "db:migrate db:seed db:sample spree_wholesale:assume_wholesale_prices", :env => "development"
+rake "db:migrate db:seed spree_sample:load spree_wholesale:create_role spree_wholesale:assume_wholesale_prices", :env => "development"
View
15 test/dummy_hooks/before_migrate.rb
@@ -1,2 +1,13 @@
-rake "spree_core:install spree_auth:install spree_sample:install"
-run "rails g spree_wholesale:install"
+run "rails g spree:site"
+
+# remove all stylesheets except core
+%w(admin store).each do |ns|
+ js = "app/assets/javascripts/#{ns}/all.js"
+ css = "app/assets/stylesheets/#{ns}/all.css"
+ remove_file js
+ remove_file css
+ template "#{ns}/all.js", js
+ template "#{ns}/all.css", css
+end
+
+run "rails g spree_wholesale:install --skip_migrations"
View
3 test/dummy_hooks/templates/admin/all.css
@@ -0,0 +1,3 @@
+/*
+*= require admin/spree_core
+*/
View
1 test/dummy_hooks/templates/admin/all.js
@@ -0,0 +1 @@
+//= require admin/spree_core
View
3 test/dummy_hooks/templates/store/all.css
@@ -0,0 +1,3 @@
+/*
+*= require store/spree_core
+*/
View
1 test/dummy_hooks/templates/store/all.js
@@ -0,0 +1 @@
+//= require store/spree_core

0 comments on commit 053dc5b

Please sign in to comment.
Something went wrong with that request. Please try again.