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)


228
229
230
# File 'lib/toys/utils/git_cache.rb', line 228

def git_path
  @git_path
end

#last_accessedTime (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time)


242
243
244
# File 'lib/toys/utils/git_cache.rb', line 242

def last_accessed
  @last_accessed
end

#shaString (readonly)

The git sha the source comes from

Returns:

  • (String)


221
222
223
# File 'lib/toys/utils/git_cache.rb', line 221

def sha
  @sha
end

#sourceString (readonly)

The path to the source file or directory

Returns:

  • (String)


235
236
237
# File 'lib/toys/utils/git_cache.rb', line 235

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


265
266
267
268
# File 'lib/toys/utils/git_cache.rb', line 265

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)


249
250
251
252
253
254
255
256
257
# File 'lib/toys/utils/git_cache.rb', line 249

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