Class: RailsEngineToolkit::Actions::NewEngine
- Inherits:
-
Object
- Object
- RailsEngineToolkit::Actions::NewEngine
- Defined in:
- lib/rails_engine_toolkit/actions/new_engine.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv, stdin:, stdout:, root:, stderr: nil) ⇒ NewEngine
constructor
A new instance of NewEngine.
Constructor Details
#initialize(argv, stdin:, stdout:, root:, stderr: nil) ⇒ NewEngine
Returns a new instance of NewEngine.
6 7 8 9 10 11 12 13 |
# File 'lib/rails_engine_toolkit/actions/new_engine.rb', line 6 def initialize(argv, stdin:, stdout:, root:, stderr: nil) @engine_name = argv[0] @stdin = stdin @stdout = stdout @stderr = stderr @root = Pathname(root) @project = Project.new(@root) end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_engine_toolkit/actions/new_engine.rb', line 15 def call @project.validate_root! validate_engine_name! config = @project.config handle_broken_references! ensure_engine_does_not_exist! description = prompt_description(config.project_name) engine_class = Utils.classify(@engine_name) generate_engine!(config) rewrite_engine_files!(config, description, engine_class) create_ddd_structure!(config) mount_engine_route(engine_class) if config.mount_routes? Utils.safe_system('bundle', 'install', chdir: @root) @stdout.puts("Engine created: engines/#{@engine_name}") end |