Sha256: 46df233c6d5f261e7bdf29abfd012de5b80318cc7c57fa6afd14edab8f3573f1

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

module RailsApp
  class Command
    attr_reader :app_name, :assets, :styling, :database

    def initialize(args)
      @app_name = args[:app_name]
      @assets = args[:assets]
      @styling = args[:styling]
      @database = args[:database]
    end

    def template
      File.join(__dir__, "template", "template.rb")
    end

    def run
      command = "rails new #{@app_name} --no-rc #{skip_spring} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}"
      command.squeeze!(" ")
      puts command
      system(command)
    end

    def skip_spring
      "--skip-spring"
    end

    def database_adapter
      "-d #{@database}" unless database == "sqlite3"
    end

    def javascript_bundling
      "-j esbuild"
    end

    def asset_management
      "-a propshaft" unless assets == "sprockets"
    end

    def styling_framework
      "--css #{@styling}"
    end

    def testing_framework
      "-T"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_app-0.8.0 lib/rails_app/command.rb