Class: Spree::DummyGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spree::DummyGenerator
- Defined in:
- lib/generators/spree/dummy/dummy_generator.rb
Direct Known Subclasses
Constant Summary collapse
- PASSTHROUGH_OPTIONS =
[ :skip_active_record, :skip_javascript, :database, :javascript, :quiet, :pretend, :force, :skip ]
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#lib_name ⇒ Object
readonly
Returns the value of attribute lib_name.
Class Method Summary collapse
Instance Method Summary collapse
- #clean_up ⇒ Object
- #generate_test_dummy ⇒ Object
- #test_dummy_clean ⇒ Object
- #test_dummy_config ⇒ Object
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
63 64 65 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 63 def database @database end |
#lib_name ⇒ Object (readonly)
Returns the value of attribute lib_name.
62 63 64 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 62 def lib_name @lib_name end |
Class Method Details
.source_paths ⇒ Object
10 11 12 13 14 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 10 def self.source_paths paths = self.superclass.source_paths paths << File.('../templates', __FILE__) paths.flatten end |
Instance Method Details
#clean_up ⇒ Object
16 17 18 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 16 def clean_up remove_directory_if_exists(dummy_path) end |
#generate_test_dummy ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 24 def generate_test_dummy opts = ( || {}).slice(*PASSTHROUGH_OPTIONS) opts[:database] = 'sqlite3' if opts[:database].blank? opts[:force] = true opts[:skip_bundle] = true opts[:old_style_hash] = true puts "Generating dummy Rails application..." invoke Rails::Generators::AppGenerator, [ File.(dummy_path, destination_root) ], opts end |
#test_dummy_clean ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 47 def test_dummy_clean inside dummy_path do remove_file ".gitignore" remove_file "doc" remove_file "Gemfile" remove_file "lib/tasks" remove_file "app/assets/images/rails.png" remove_file "public/index.html" remove_file "public/robots.txt" remove_file "README" remove_file "test" remove_file "vendor" end end |
#test_dummy_config ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 36 def test_dummy_config @lib_name = [:lib_name] @database = [:database] template "rails/database.yml", "#{dummy_path}/config/database.yml", :force => true template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true template "rails/script/rails", "#{dummy_path}/spec/dummy/script/rails", :force => true end |