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)


598
599
600
# File 'lib/toys/utils/git_cache.rb', line 598

def last_accessed
  @last_accessed
end

#last_updatedTime? (readonly)

The timestamp when this ref was last updated

Returns:

  • (Time, nil)


605
606
607
# File 'lib/toys/utils/git_cache.rb', line 605

def last_updated
  @last_updated
end

#refString (readonly)

The git ref

Returns:

  • (String)


584
585
586
# File 'lib/toys/utils/git_cache.rb', line 584

def ref
  @ref
end

#shaString (readonly)

The git sha last associated with the ref

Returns:

  • (String)


591
592
593
# File 'lib/toys/utils/git_cache.rb', line 591

def sha
  @sha
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


628
629
630
# File 'lib/toys/utils/git_cache.rb', line 628

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

#to_hHash

Convert this RefInfo to a hash suitable for JSON output

Returns:

  • (Hash)


612
613
614
615
616
617
618
619
620
# File 'lib/toys/utils/git_cache.rb', line 612

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