Sha256: eb47a1c9b2a86ab5da947931d567f3f8c7322c9530a56cd75f94e6f87c4878aa

Contents?: true

Size: 930 Bytes

Versions: 6

Compression:

Stored size: 930 Bytes

Contents

module Spring
  module Client
    class Rails < Command
      COMMANDS = %w(console runner generate destroy test)

      ALIASES = {
        "c" => "console",
        "r" => "runner",
        "g" => "generate",
        "d" => "destroy",
        "t" => "test"
      }

      def self.description
        "Run a rails command. The following sub commands will use Spring: #{COMMANDS.to_a.join ', '}."
      end

      def call
        command_name = ALIASES[args[1]] || args[1]

        if COMMANDS.include?(command_name)
          Run.call(["rails_#{command_name}", *args.drop(2)])
        elsif command_name&.start_with?("db:") && !command_name.start_with?("db:system")
          Run.call(["rake", *args.drop(1)])
        else
          require "spring/configuration"
          ARGV.shift
          load Dir.glob(Spring.application_root_path.join("{bin,script}/rails")).first
          exit
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spring-4.2.1 lib/spring/client/rails.rb
spring-4.2.0 lib/spring/client/rails.rb
spring-4.1.3 lib/spring/client/rails.rb
spring-4.1.2 lib/spring/client/rails.rb
spring-4.1.1 lib/spring/client/rails.rb
spring-4.1.0 lib/spring/client/rails.rb