Sha256: 6d5ea57d1dbfe0c1174428888dc4c381b702eadacb411b8c5b9c8074971bc67a

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

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

      self.environment_matchers = {
        :default     => "test",
        /^test($|:)/ => "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

3 entries across 3 versions & 1 rubygems

Version Path
spring-1.0.0 lib/spring/commands/rake.rb
spring-0.9.2 lib/spring/commands/rake.rb
spring-0.9.1 lib/spring/commands/rake.rb