Class: Toys::Utils::GitCache::SourceInfo
- Inherits:
-
Object
- Object
- Toys::Utils::GitCache::SourceInfo
- Includes:
- Comparable
- Defined in:
- lib/toys/utils/git_cache.rb
Overview
Information about shared source files provided from the cache.
Instance Attribute Summary collapse
-
#git_path ⇒ String
readonly
The path within the git repo.
-
#last_accessed ⇒ Time?
readonly
The timestamp when this ref was last accessed.
-
#sha ⇒ String
readonly
The git sha the source comes from.
-
#source ⇒ String
readonly
The path to the source file or directory.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Comparison function.
-
#to_h ⇒ Hash
Convert this SourceInfo to a hash suitable for JSON output.
Instance Attribute Details
#git_path ⇒ String (readonly)
The path within the git repo
238 239 240 |
# File 'lib/toys/utils/git_cache.rb', line 238 def git_path @git_path end |
#last_accessed ⇒ Time? (readonly)
The timestamp when this ref was last accessed
252 253 254 |
# File 'lib/toys/utils/git_cache.rb', line 252 def last_accessed @last_accessed end |
#sha ⇒ String (readonly)
The git sha the source comes from
231 232 233 |
# File 'lib/toys/utils/git_cache.rb', line 231 def sha @sha end |
#source ⇒ String (readonly)
The path to the source file or directory
245 246 247 |
# File 'lib/toys/utils/git_cache.rb', line 245 def source @source end |
Instance Method Details
#<=>(other) ⇒ Integer
Comparison function
275 276 277 278 |
# File 'lib/toys/utils/git_cache.rb', line 275 def <=>(other) result = sha <=> other.sha result.zero? ? git_path <=> other.git_path : result end |
#to_h ⇒ Hash
Convert this SourceInfo to a hash suitable for JSON output
259 260 261 262 263 264 265 266 267 |
# File 'lib/toys/utils/git_cache.rb', line 259 def to_h result = { "sha" => sha, "git_path" => git_path, "source" => source, } result["last_accessed"] = last_accessed.to_i if last_accessed result end |