Sha256: 60ab5cd043c1787ec1a6dde034a95dc31a88af4b7e6fe77ab87bce99c7b4aeda

Contents?: true

Size: 1009 Bytes

Versions: 2

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

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

    def initialize(app_name:, assets:, styling:, database:)
      @app_name = app_name
      @assets = assets
      @styling = styling
      @database = 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}"
      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

2 entries across 2 versions & 1 rubygems

Version Path
rails_app-0.7.0 lib/rails_app/command.rb
rails_app-0.6.0 lib/rails_app/command.rb