Class: RailsApp::Command
- Inherits:
-
Object
- Object
- RailsApp::Command
- Defined in:
- lib/rails_app/command.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#styling ⇒ Object
readonly
Returns the value of attribute styling.
Instance Method Summary collapse
- #asset_management ⇒ Object
- #database_adapter ⇒ Object
-
#initialize(app_name, args) ⇒ Command
constructor
A new instance of Command.
- #javascript_bundling ⇒ Object
- #run ⇒ Object
- #skip_action_cable ⇒ Object
- #skip_action_mailbox ⇒ Object
- #skip_action_mailer ⇒ Object
- #skip_action_storage ⇒ Object
- #skip_action_text ⇒ Object
- #skip_spring ⇒ Object
- #styling_framework ⇒ Object
- #template ⇒ Object
- #testing_framework ⇒ Object
Constructor Details
#initialize(app_name, args) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails_app/command.rb', line 5 def initialize(app_name, args) # puts "args: #{args}" @app_name = app_name @assets = args[:assets] @styling = args[:styling] @database = args[:database] @skip_spring = args[:skip_spring] @skip_action_mailer = args[:action_mailer] @skip_action_mailbox = args[:action_mailbox] @skip_action_text = args[:action_text] @skip_action_storage = args[:action_storage] @skip_action_cable = args[:action_cable] end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
3 4 5 |
# File 'lib/rails_app/command.rb', line 3 def app_name @app_name end |
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
3 4 5 |
# File 'lib/rails_app/command.rb', line 3 def assets @assets end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
3 4 5 |
# File 'lib/rails_app/command.rb', line 3 def database @database end |
#styling ⇒ Object (readonly)
Returns the value of attribute styling.
3 4 5 |
# File 'lib/rails_app/command.rb', line 3 def styling @styling end |
Instance Method Details
#asset_management ⇒ Object
62 63 64 |
# File 'lib/rails_app/command.rb', line 62 def asset_management "-a propshaft" unless assets == "sprockets" end |
#database_adapter ⇒ Object
54 55 56 |
# File 'lib/rails_app/command.rb', line 54 def database_adapter "-d #{@database}" unless database == "sqlite3" end |
#javascript_bundling ⇒ Object
58 59 60 |
# File 'lib/rails_app/command.rb', line 58 def javascript_bundling "-j esbuild" end |
#run ⇒ Object
23 24 25 26 27 28 |
# File 'lib/rails_app/command.rb', line 23 def run command = "rails new #{@app_name} --no-rc #{skip_spring} #{skip_action_mailer} #{skip_action_mailbox} #{skip_action_text} #{skip_action_text} #{skip_action_cable} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}" command.squeeze!(" ") # puts command system(command) end |
#skip_action_cable ⇒ Object
50 51 52 |
# File 'lib/rails_app/command.rb', line 50 def skip_action_cable "--skip-action-cable" if @skip_action_cable == true end |
#skip_action_mailbox ⇒ Object
38 39 40 |
# File 'lib/rails_app/command.rb', line 38 def skip_action_mailbox "--skip-action-mailbox" if @skip_action_mailbox == true end |
#skip_action_mailer ⇒ Object
34 35 36 |
# File 'lib/rails_app/command.rb', line 34 def skip_action_mailer "--skip-action-mailer" if @skip_action_mailer == true end |
#skip_action_storage ⇒ Object
46 47 48 |
# File 'lib/rails_app/command.rb', line 46 def skip_action_storage "--skip-active-storage" if @skip_action_storage == true end |
#skip_action_text ⇒ Object
42 43 44 |
# File 'lib/rails_app/command.rb', line 42 def skip_action_text "--skip-action-text" if @skip_action_text == true end |
#skip_spring ⇒ Object
30 31 32 |
# File 'lib/rails_app/command.rb', line 30 def skip_spring "--skip-spring" if @skip_spring == true end |
#styling_framework ⇒ Object
66 67 68 |
# File 'lib/rails_app/command.rb', line 66 def styling_framework "--css #{@styling}" end |
#template ⇒ Object
19 20 21 |
# File 'lib/rails_app/command.rb', line 19 def template File.join(__dir__, "template", "template.rb") end |
#testing_framework ⇒ Object
70 71 72 |
# File 'lib/rails_app/command.rb', line 70 def testing_framework "-T" end |