Sha256: 463b2b833173ce67ad5b5e1dd05b458108dbbdd6497472936d04a52106919c65

Contents?: true

Size: 709 Bytes

Versions: 5

Compression:

Stored size: 709 Bytes

Contents

# Mechanism to cache gems
#
# Licensed under the MIT license
# Copyright (C) 2013-2014 Red Hat, Inc.

require 'fileutils'

module Polisher
  class GemCache
    DIR = "#{ENV['HOME']}/.polisher/gems"

    def self.create!
      FileUtils.mkdir_p(DIR) unless File.directory?(DIR)
    end

    def self.clear!
      FileUtils.rm_rf(DIR)
    end

    def self.path_for(name, version)
      "#{DIR}/#{name}-#{version}.gem"
    end

    def self.get(name, version)
      path = path_for(name, version)
      File.exists?(path) ? File.read(path) : nil
    end

    def self.set(name, version, gem)
      self.create!
      File.write(path_for(name, version), gem)
    end
  end # class GemCache
end # module Polisher

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
polisher-0.10.2 lib/polisher/gem_cache.rb
polisher-0.10.1 lib/polisher/gem_cache.rb
polisher-0.9.1 lib/polisher/gem_cache.rb
polisher-0.8.1 lib/polisher/gem_cache.rb
polisher-0.7.1 lib/polisher/gem_cache.rb