Sha256: 8045a99912296074c5cf3467b6503f54957bfd646dafff9fe70528e178667848

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

module Spring
  module Commands
    class Rake
      class << self
        attr_accessor :environment_matchers
      end

      self.environment_matchers = {
        :default                     => "test",
        /^(test|spec|cucumber)($|:)/ => "test"
      }

      def env(args)
        # This is an adaption of the matching that Rake itself does.
        # See: https://github.com/jimweirich/rake/blob/3754a7639b3f42c2347857a0878beb3523542aee/lib/rake/application.rb#L691-L692
        if env = args.grep(/^(RAILS|RACK)_ENV=(.*)$/m).last
          return env.split("=").last
        end

        self.class.environment_matchers.each do |matcher, environment|
          return environment if matcher === (args.first || :default)
        end

        nil
      end

      def exec_name
        "rake"
      end
    end

    Spring.register_command "rake", Rake.new
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spring-0.9.0 lib/spring/commands/rake.rb