Sha256: f16c8f270e270a51e2c8082cf91b7ef67ed721566829e1bd7921f09c8b3a2ea8

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module RailsApp
  class Command
    attr_reader :app_name, :bundling, :assets

    def initialize(app_name:, assets:, styling:)
      @app_name = app_name
      @assets = assets
      @styling = styling
    end

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

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

    def skip_spring
      "--skip-spring"
    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

3 entries across 3 versions & 1 rubygems

Version Path
rails_app-0.5.0 lib/rails_app/command.rb
rails_app-0.4.0 lib/rails_app/command.rb
rails_app-0.3.0 lib/rails_app/command.rb