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_accessed ⇒ Time? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


756
757
758
# File 'lib/toys/utils/git_cache.rb', line 756

def last_accessed
  @last_accessed
end

#last_updated ⇒ Time? (readonly)

The timestamp when this ref was last updated

Returns:

  • (Time, nil)


763
764
765
# File 'lib/toys/utils/git_cache.rb', line 763

def last_updated
  @last_updated
end

#ref ⇒ String (readonly)

The git ref

Returns:

  • (String)


742
743
744
# File 'lib/toys/utils/git_cache.rb', line 742

def ref
  @ref
end

#sha ⇒ String (readonly)

The git sha last associated with the ref

Returns:

  • (String)


749
750
751
# File 'lib/toys/utils/git_cache.rb', line 749

def sha
  @sha
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


786
787
788
# File 'lib/toys/utils/git_cache.rb', line 786

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

#to_h ⇒ Hash

Convert this RefInfo to a hash suitable for JSON output

Returns:

  • (Hash)


770
771
772
773
774
775
776
777
778
# File 'lib/toys/utils/git_cache.rb', line 770

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