Class: CodeCache::Repo
- Inherits:
-
Object
- Object
- CodeCache::Repo
- Defined in:
- lib/code_cache/repo.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #create_cache(revision) ⇒ Object
-
#initialize(url, options = {}) ⇒ Repo
constructor
A new instance of Repo.
-
#location_in_cache(revision = nil) ⇒ Object
Calculates the location of a cached checkout.
- #repo_type ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Repo
Returns a new instance of Repo.
11 12 13 14 15 16 17 |
# File 'lib/code_cache/repo.rb', line 11 def initialize(url, = {}) cache_dir = Dir.tmpdir() if RbConfig::CONFIG['host_os'].include? "ming" @cache = [:cache] || cache_dir || '/tmp/code_cache' @url = url check_repo(url) end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
9 10 11 |
# File 'lib/code_cache/repo.rb', line 9 def cache @cache end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/code_cache/repo.rb', line 9 def url @url end |
Instance Method Details
#create_cache(revision) ⇒ Object
19 20 21 22 23 |
# 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) ⇒ Object
Calculates the location of a cached checkout
26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
35 36 37 |
# File 'lib/code_cache/repo.rb', line 35 def repo_type self.class.to_s.split('::').last.downcase end |