Sha256: d08c3e7e683093fc912c0424f6d840638cdce29cabd18a35a1ab4e336fcc9faf

Contents?: true

Size: 885 Bytes

Versions: 8

Compression:

Stored size: 885 Bytes

Contents

module Spade
  class Environment
    def self.spade_dir=(spade_dir)
      @spade_dir = spade_dir
    end

    def self.spade_dir(*path)
      File.join(@spade_dir, *path)
    end

    def initialize
      self.class.spade_dir = File.join(ENV["HOME"], SPADE_DIR)
      FileUtils.mkdir_p(spade_dir)

      ENV["RUBYGEMS_HOST"] ||= "https://sproutcutter.heroku.com"
      Gem.sources.replace [ENV["RUBYGEMS_HOST"]]
      Gem.use_paths(spade_dir)
      Gem.source_index.refresh!

      spade_fetcher = Gem::SpecFetcher.new
      def spade_fetcher.cache_dir(uri)
        Spade::Environment.spade_dir("#{uri.host}%#{uri.port}", File.dirname(uri.path))
      end

      # Do it again, since it got overridden
      Gem.sources.replace [ENV["RUBYGEMS_HOST"]]

      Gem::SpecFetcher.fetcher = spade_fetcher
    end

    def spade_dir(*path)
      self.class.spade_dir(*path)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spade-0.0.8.1 lib/spade/environment.rb
spade-0.0.7 lib/spade/environment.rb
spade-0.0.6 lib/spade/environment.rb
spade-0.0.5 lib/spade/environment.rb
spade-0.0.4 lib/spade/environment.rb
spade-0.0.3 lib/spade/environment.rb
spade-0.0.2 lib/spade/environment.rb
spade-0.0.1 lib/spade/environment.rb