Class: Toys::Utils::GitCache::RepoInfo
- Inherits:
-
Object
- Object
- Toys::Utils::GitCache::RepoInfo
- Includes:
- Comparable
- Defined in:
- lib/toys/utils/git_cache.rb
Overview
Information about a remote git repository in the cache.
This object is returned from #repo_info.
Instance Attribute Summary collapse
-
#base_dir ⇒ String
readonly
The base directory of this git repository's cache entry.
-
#last_accessed ⇒ Time?
readonly
The last time any cached data from this repo was accessed, or
nilif the information is unavailable. -
#remote ⇒ String
readonly
The git remote, usually a file system path or URL.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Comparison function.
-
#refs(ref: nil) ⇒ Array<RefInfo>
A list of git refs (branches, tags, shas) that have been accessed from this repo.
-
#sources(sha: nil, git_path: nil) ⇒ Array<SourceInfo>
A list of shared source files and directories accessed for this repo.
-
#to_h ⇒ Hash
Convert this RepoInfo to a hash suitable for JSON output.
Instance Attribute Details
#base_dir ⇒ String (readonly)
The base directory of this git repository's cache entry. This directory contains all cached data related to this repo. Deleting it effectively removes the repo from the cache.
548 549 550 |
# File 'lib/toys/utils/git_cache.rb', line 548 def base_dir @base_dir end |
#last_accessed ⇒ Time? (readonly)
The last time any cached data from this repo was accessed, or nil
if the information is unavailable.
563 564 565 |
# File 'lib/toys/utils/git_cache.rb', line 563 def last_accessed @last_accessed end |
#remote ⇒ String (readonly)
The git remote, usually a file system path or URL.
555 556 557 |
# File 'lib/toys/utils/git_cache.rb', line 555 def remote @remote end |
Instance Method Details
#<=>(other) ⇒ Integer
Comparison function
618 619 620 |
# File 'lib/toys/utils/git_cache.rb', line 618 def <=>(other) remote <=> other.remote end |
#refs(ref: nil) ⇒ Array<RefInfo>
A list of git refs (branches, tags, shas) that have been accessed from this repo.
573 574 575 576 |
# File 'lib/toys/utils/git_cache.rb', line 573 def refs(ref: nil) return @refs.dup if ref.nil? @refs.find_all { |elem| elem.ref == ref } end |
#sources(sha: nil, git_path: nil) ⇒ Array<SourceInfo>
A list of shared source files and directories accessed for this repo.
588 589 590 591 592 593 594 |
# File 'lib/toys/utils/git_cache.rb', line 588 def sources(sha: nil, git_path: nil) return @sources.dup if sha.nil? && git_path.nil? @sources.find_all do |elem| (sha.nil? || elem.sha == sha) && (git_path.nil? || elem.git_path == git_path) end end |
#to_h ⇒ Hash
Convert this RepoInfo to a hash suitable for JSON output
601 602 603 604 605 606 607 608 609 610 |
# File 'lib/toys/utils/git_cache.rb', line 601 def to_h result = { "remote" => remote, "base_dir" => base_dir, } result["last_accessed"] = last_accessed.to_i if last_accessed result["refs"] = refs.map(&:to_h) result["sources"] = sources.map(&:to_h) result end |