Class: GitCache::SourceInfo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/git_cache/repo_info.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)


202
203
204
# File 'lib/git_cache/repo_info.rb', line 202

def git_path
  @git_path
end

#last_accessedTime? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


216
217
218
# File 'lib/git_cache/repo_info.rb', line 216

def last_accessed
  @last_accessed
end

#shaString (readonly)

The git sha the source comes from

Returns:

  • (String)


195
196
197
# File 'lib/git_cache/repo_info.rb', line 195

def sha
  @sha
end

#sourceString (readonly)

The path to the source file or directory

Returns:

  • (String)


209
210
211
# File 'lib/git_cache/repo_info.rb', line 209

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


239
240
241
242
# File 'lib/git_cache/repo_info.rb', line 239

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)


223
224
225
226
227
228
229
230
231
# File 'lib/git_cache/repo_info.rb', line 223

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