class CodeCache::Repo

Attributes

cache[RW]
url[RW]

Public Class Methods

new(url, options = {}) click to toggle source
# File lib/code_cache/repo.rb, line 11
def initialize(url, options = {})
  cache_dir = Dir.tmpdir() if RbConfig::CONFIG['host_os'].include? "ming" 
  @cache = options[:cache] || cache_dir || '/tmp/code_cache'
  @url = url
  
  check_repo(url)
end

Public Instance Methods

create_cache(revision) click to toggle source
# File lib/code_cache/repo.rb, line 19
def create_cache(revision)
  if !Dir.exist? location_in_cache(revision)
    FileUtils.mkdir_p @cache
  end
end
location_in_cache( revision = nil ) click to toggle source

Calculates the location of a cached checkout

# File lib/code_cache/repo.rb, line 26
def location_in_cache( revision = nil )
  begin
    elements = [cache, repo_type, split_url, revision].flatten.compact.collect { |i| i.to_s } 
    File.join( elements )
  rescue => e
    raise CacheCalculationError.new(e.msg + e.backtrace.to_s)
  end
end
repo_type() click to toggle source
# File lib/code_cache/repo.rb, line 35
def repo_type
  self.class.to_s.split('::').last.downcase
end