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_pathString (readonly)

The path within the git repo

Returns:

  • (String)


731
732
733
# File 'lib/toys/utils/git_cache.rb', line 731

def git_path
  @git_path
end

#last_accessedTime? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


745
746
747
# File 'lib/toys/utils/git_cache.rb', line 745

def last_accessed
  @last_accessed
end

#shaString (readonly)

The git sha the source comes from

Returns:

  • (String)


724
725
726
# File 'lib/toys/utils/git_cache.rb', line 724

def sha
  @sha
end

#sourceString (readonly)

The path to the source file or directory

Returns:

  • (String)


738
739
740
# File 'lib/toys/utils/git_cache.rb', line 738

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


768
769
770
771
# File 'lib/toys/utils/git_cache.rb', line 768

def <=>(other)
  result = sha <=> other.sha
  result.zero? ? git_path <=> other.git_path : result
end

#to_hHash

Convert this SourceInfo to a hash suitable for JSON output

Returns:

  • (Hash)


752
753
754
755
756
757
758
759
760
# File 'lib/toys/utils/git_cache.rb', line 752

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