Class: Textus::Handlers::Read::BlameEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/handlers/read/blame_entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(manifest:, orchestration:) ⇒ BlameEntry

Returns a new instance of BlameEntry.



5
6
7
8
# File 'lib/textus/handlers/read/blame_entry.rb', line 5

def initialize(manifest:, orchestration:)
  @manifest = manifest
  @orchestration = orchestration
end

Instance Method Details

#call(command, call) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/textus/handlers/read/blame_entry.rb', line 10

def call(command, call)
  root = @manifest.data.root
  audit = @orchestration.audit_entries(key: command.key, limit: command.limit, call: call)
  return audit if audit.failure?

  audit_rows = audit.value.fetch("rows")

  path = resolve_path(command.key)
  return Value::Result.success(audit_rows.map { |row| row.merge("git" => nil) }) unless git_tracked?(path, root: root)

  Value::Result.success(audit_rows.map { |row| row.merge("git" => git_commit_at(path, timestamp: row["ts"], root: root)) })
end