Class: Spree::DummyGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spree::DummyGenerator
- Defined in:
- lib/generators/spree/dummy/dummy_generator.rb
Constant Summary collapse
- SPREE_GEMS =
%w(spree_admin spree_storefront spree_api spree_emails).freeze
- 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_config ⇒ Object
- #test_dummy_inject_extension_requirements ⇒ Object
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
83 84 85 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 83 def database @database end |
#lib_name ⇒ Object (readonly)
Returns the value of attribute lib_name.
82 83 84 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 82 def lib_name @lib_name end |
Class Method Details
.source_paths ⇒ Object
14 15 16 17 18 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 14 def self.source_paths paths = superclass.source_paths paths << File.('templates', __dir__) paths.flatten end |
Instance Method Details
#clean_up ⇒ Object
20 21 22 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 20 def clean_up remove_directory_if_exists(dummy_path) end |
#generate_test_dummy ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 28 def generate_test_dummy # calling slice on a Thor::CoreExtensions::HashWithIndifferentAccess # object has been known to return nil opts = {}.merge().slice(*PASSTHROUGH_OPTIONS) opts[:database] = 'sqlite3' if opts[:database].blank? opts[:force] = true opts[:skip_bundle] = true opts[:skip_git] = true opts[:skip_listen] = true opts[:skip_rc] = true opts[:skip_spring] = true opts[:skip_test] = true opts[:skip_bootsnap] = true opts[:skip_docker] = true opts[:skip_rubocop] = true opts[:skip_brakeman] = true opts[:skip_ci] = true opts[:skip_kamal] = true opts[:skip_devcontainer] = true opts[:skip_solid] = true puts 'Generating dummy Rails application...' invoke Rails::Generators::AppGenerator, [File.(dummy_path, destination_root)], opts inject_yaml_permitted_classes end |
#test_dummy_config ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 55 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/test.rb', "#{dummy_path}/config/environments/test.rb", force: true template 'initializers/devise.rb', "#{dummy_path}/config/initializers/devise.rb", force: true template "app/assets/config/manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true end |
#test_dummy_inject_extension_requirements ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/generators/spree/dummy/dummy_generator.rb', line 68 def test_dummy_inject_extension_requirements if DummyGeneratorHelper.inject_extension_requirements SPREE_GEMS.each do |gem| begin require "#{gem}" inside dummy_path do inject_require_for(gem) end rescue StandardError, LoadError end end end end |