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.
9 10 11 12 13 14 |
# File 'lib/code_cache/repo.rb', line 9 def initialize(url, = {}) @cache = [:cache] || '/tmp/code_cache' @url = url check_repo(url) end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
7 8 9 |
# File 'lib/code_cache/repo.rb', line 7 def cache @cache end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/code_cache/repo.rb', line 7 def url @url end |
Instance Method Details
#create_cache(revision) ⇒ Object
16 17 18 19 20 |
# File 'lib/code_cache/repo.rb', line 16 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
23 24 25 26 27 28 29 30 |
# File 'lib/code_cache/repo.rb', line 23 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
32 33 34 |
# File 'lib/code_cache/repo.rb', line 32 def repo_type self.class.to_s.split('::').last.downcase end |