Class: Yobi::BackupOutcome

Inherits:
Object
  • Object
show all
Defined in:
lib/yobi/repository/backup.rb,
sig/yobi.rbs

Overview

The outcome of one Yobi::Repository#backup call.

Constant Summary collapse

COMMAND_OUTPUT_LINE_PATTERN =

:nodoc:

Returns:

  • (Regexp)
/\Asubprocess [^:]+: (.*)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution) ⇒ BackupOutcome

:nodoc:

Parameters:

  • execution (execution)


134
135
136
# File 'lib/yobi/repository/backup.rb', line 134

def initialize(execution) # :nodoc:
  @output = execution[:output]
end

Instance Attribute Details

#outputResticOutput (readonly)

The Yobi::ResticOutput backing this outcome.

Returns:



132
133
134
# File 'lib/yobi/repository/backup.rb', line 132

def output
  @output
end

Instance Method Details

#command_outputvoid #command_outputEnumerator[String, void]

The source: [:stdin_from_command, ...] subprocess's own stderr, if any, de-prefixed.

Overloads:

  • #command_outputvoid

    This method returns an undefined value.

  • #command_outputEnumerator[String, void]

    Returns:

    • (Enumerator[String, void])

Yields:

Yield Parameters:

  • line (String)

Yield Returns:

  • (void)


152
153
154
155
156
157
158
159
# File 'lib/yobi/repository/backup.rb', line 152

def command_output
  return enum_for(:command_output) unless block_given?

  output.stderr_lines.each do |line|
    match = COMMAND_OUTPUT_LINE_PATTERN.match(line)
    yield match[1] if match
  end
end

#errorsResticOutput::LazyList[BackupError]

Every Yobi::BackupError message from the run.



139
140
141
# File 'lib/yobi/repository/backup.rb', line 139

def errors
  @errors ||= output.messages("error")
end

#inspectString

Returns:

  • (String)


466
# File 'sig/yobi.rbs', line 466

def inspect: () -> String

#messagesResticOutput::LazyList[BackupStatus | BackupError | BackupVerboseStatus | BackupSummary | Hash[String, untyped]]

Every message from the run, in file order, each wrapped in its own Yobi::BackupStatus / Yobi::BackupError / Yobi::BackupVerboseStatus / Yobi::BackupSummary.



146
147
148
# File 'lib/yobi/repository/backup.rb', line 146

def messages
  @messages ||= output.messages
end

#pretty_print(q) ⇒ Object



167
168
169
170
171
172
173
174
# File 'lib/yobi/repository/backup.rb', line 167

def pretty_print(q)
  q.object_group(self) do
    q.breakable
    q.text("(has errors)") if errors.any?
    q.breakable
    q.pp summary
  end
end

#summaryBackupSummary Also known as: report

The Yobi::BackupSummary of Restic's own "summary" fields.

Returns:



162
163
164
# File 'lib/yobi/repository/backup.rb', line 162

def summary
  @summary ||= output.messages("summary").first || BackupSummary.new({})
end