Class: Toys::Utils::GitCache::SourceInfo

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

Overview

Information about shared source files provided from the cache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#git_path ⇒ String (readonly)

The path within the git repo

Returns:

  • (String)


821
822
823
# File 'lib/toys/utils/git_cache.rb', line 821

def git_path
  @git_path
end

#last_accessed ⇒ Time? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


835
836
837
# File 'lib/toys/utils/git_cache.rb', line 835

def last_accessed
  @last_accessed
end

#sha ⇒ String (readonly)

The git sha the source comes from

Returns:

  • (String)


814
815
816
# File 'lib/toys/utils/git_cache.rb', line 814

def sha
  @sha
end

#source ⇒ String (readonly)

The path to the source file or directory

Returns:

  • (String)


828
829
830
# File 'lib/toys/utils/git_cache.rb', line 828

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


858
859
860
861
# File 'lib/toys/utils/git_cache.rb', line 858

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

Returns:

  • (Hash)


842
843
844
845
846
847
848
849
850
# File 'lib/toys/utils/git_cache.rb', line 842

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