Class: Cabriolet::RepairReport

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/repairer.rb

Overview

Repair report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, original_file:, repaired_file:, stats:, recovered_files: [], error: nil) ⇒ RepairReport



201
202
203
204
205
206
207
208
209
# File 'lib/cabriolet/repairer.rb', line 201

def initialize(success:, original_file:, repaired_file:, stats:,
recovered_files: [], error: nil)
  @success = success
  @original_file = original_file
  @repaired_file = repaired_file
  @stats = stats
  @recovered_files = recovered_files
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def error
  @error
end

#original_fileObject (readonly)

Returns the value of attribute original_file.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def original_file
  @original_file
end

#recovered_filesObject (readonly)

Returns the value of attribute recovered_files.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def recovered_files
  @recovered_files
end

#repaired_fileObject (readonly)

Returns the value of attribute repaired_file.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def repaired_file
  @repaired_file
end

#statsObject (readonly)

Returns the value of attribute stats.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def stats
  @stats
end

#successObject (readonly)

Returns the value of attribute success.



198
199
200
# File 'lib/cabriolet/repairer.rb', line 198

def success
  @success
end

Instance Method Details

#detailed_reportObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/cabriolet/repairer.rb', line 223

def detailed_report
  report = ["=" * 60]
  report << "Archive Repair Report"
  report << ("=" * 60)
  report << "Original: #{@original_file}"
  report << "Repaired: #{@repaired_file}"
  report << "Status: #{success? ? 'SUCCESS' : 'FAILED'}"
  report << ""
  report << "Statistics:"
  report << "  Recovered: #{@stats[:recovered]}"
  report << "  Partial:   #{@stats[:partial]}"
  report << "  Failed:    #{@stats[:failed]}"
  report << ""

  if @error
    report << "Error: #{@error}"
    report << ""
  end

  if @recovered_files.any?
    report << "Recovered Files:"
    @recovered_files.each { |f| report << "  - #{f}" }
    report << ""
  end

  report << ("=" * 60)
  report.join("\n")
end

#success?Boolean



211
212
213
# File 'lib/cabriolet/repairer.rb', line 211

def success?
  @success
end

#summaryObject



215
216
217
218
219
220
221
# File 'lib/cabriolet/repairer.rb', line 215

def summary
  if success?
    "Repair successful: #{@stats[:recovered]} files recovered, #{@stats[:failed]} failed"
  else
    "Repair failed: #{@error}"
  end
end