Class: Toys::Utils::GitCache::RefInfo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/toys/utils/git_cache.rb

Overview

Information about a git ref used in a cache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_accessedTime? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


173
174
175
# File 'lib/toys/utils/git_cache.rb', line 173

def last_accessed
  @last_accessed
end

#last_updatedTime? (readonly)

The timestamp when this ref was last updated

Returns:

  • (Time, nil)


180
181
182
# File 'lib/toys/utils/git_cache.rb', line 180

def last_updated
  @last_updated
end

#refString (readonly)

The git ref

Returns:

  • (String)


159
160
161
# File 'lib/toys/utils/git_cache.rb', line 159

def ref
  @ref
end

#shaString (readonly)

The git sha last associated with the ref

Returns:

  • (String)


166
167
168
# File 'lib/toys/utils/git_cache.rb', line 166

def sha
  @sha
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


203
204
205
# File 'lib/toys/utils/git_cache.rb', line 203

def <=>(other)
  ref <=> other.ref
end

#to_hHash

Convert this RefInfo to a hash suitable for JSON output

Returns:

  • (Hash)


187
188
189
190
191
192
193
194
195
# File 'lib/toys/utils/git_cache.rb', line 187

def to_h
  result = {
    "ref" => ref,
    "sha" => sha,
  }
  result["last_accessed"] = last_accessed.to_i if last_accessed
  result["last_updated"] = last_updated.to_i if last_updated
  result
end