Class: Yobi::BackupOutcome
- Inherits:
-
Struct
- Object
- Struct
- Yobi::BackupOutcome
- Defined in:
- lib/yobi/repository/backup.rb,
sig/yobi.rbs
Overview
The outcome of one Repository#backup call.
Constant Summary collapse
- COMMAND_OUTPUT_LINE_PATTERN =
Matches Restic's own log line format for stderr relayed from a
source: [:stdin_from_command, ...]command's own subprocess. /\Asubprocess [^:]+: (.*)/
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
Returns the value of attribute exit_code.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
-
#command_output ⇒ Array<String>
The
source: [:stdin_from_command, ...]subprocess's own stderr, if any, de-prefixed. - #errors ⇒ Enumerable<Yobi::BackupError>
-
#partial? ⇒ Boolean
True if the backup completed with some files skipped.
-
#report ⇒ Hash
Restic's own
"summary"fields, with"backup_start"/"backup_end"parsed intoTime. - #success? ⇒ Boolean
Instance Attribute Details
#exit_code ⇒ Object
Returns the value of attribute exit_code
123 124 125 |
# File 'lib/yobi/repository/backup.rb', line 123 def exit_code @exit_code end |
#output ⇒ Object
Returns the value of attribute output
123 124 125 |
# File 'lib/yobi/repository/backup.rb', line 123 def output @output end |
Instance Method Details
#command_output ⇒ Array<String>
The source: [:stdin_from_command, ...] subprocess's own stderr, if any, de-prefixed.
146 147 148 149 150 151 |
# File 'lib/yobi/repository/backup.rb', line 146 def command_output @command_output ||= output.each_line.filter_map do |line| match = COMMAND_OUTPUT_LINE_PATTERN.match(line) match[1] if match end end |
#errors ⇒ Enumerable<Yobi::BackupError>
139 140 141 |
# File 'lib/yobi/repository/backup.rb', line 139 def errors @errors ||= BackupErrors.new(output) end |
#partial? ⇒ Boolean
Returns true if the backup completed with some files skipped.
134 135 136 |
# File 'lib/yobi/repository/backup.rb', line 134 def partial? exit_code == 3 end |
#report ⇒ Hash
Returns Restic's own "summary" fields, with "backup_start"/"backup_end" parsed into Time.
154 155 156 157 158 159 160 161 162 |
# File 'lib/yobi/repository/backup.rb', line 154 def report @report ||= begin hash = summary_hash hash.merge( "backup_start" => (Time.parse(hash["backup_start"]) if hash["backup_start"]), "backup_end" => (Time.parse(hash["backup_end"]) if hash["backup_end"]) ) end end |
#success? ⇒ Boolean
129 130 131 |
# File 'lib/yobi/repository/backup.rb', line 129 def success? exit_code.zero? end |