Class: Cabriolet::ModificationReport

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

Overview

Modification report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, original:, output:, modifications: 0, added: 0, updated: 0, removed: 0, renamed: 0, error: nil) ⇒ ModificationReport

Returns a new instance of ModificationReport.



276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/cabriolet/modifier.rb', line 276

def initialize(success:, original:, output:, modifications: 0, added: 0, updated: 0, removed: 0, renamed: 0,
               error: nil)
  @success = success
  @original = original
  @output = output
  @modifications = modifications
  @added = added
  @updated = updated
  @removed = removed
  @renamed = renamed
  @error = error
end

Instance Attribute Details

#addedObject (readonly)

Returns the value of attribute added.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def added
  @added
end

#errorObject (readonly)

Returns the value of attribute error.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def error
  @error
end

#modificationsObject (readonly)

Returns the value of attribute modifications.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def modifications
  @modifications
end

#originalObject (readonly)

Returns the value of attribute original.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def original
  @original
end

#outputObject (readonly)

Returns the value of attribute output.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def output
  @output
end

#removedObject (readonly)

Returns the value of attribute removed.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def removed
  @removed
end

#renamedObject (readonly)

Returns the value of attribute renamed.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def renamed
  @renamed
end

#successObject (readonly)

Returns the value of attribute success.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def success
  @success
end

#updatedObject (readonly)

Returns the value of attribute updated.



273
274
275
# File 'lib/cabriolet/modifier.rb', line 273

def updated
  @updated
end

Instance Method Details

#detailed_reportObject



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/cabriolet/modifier.rb', line 301

def detailed_report
  report = ["=" * 60]
  report << "Archive Modification Report"
  report << ("=" * 60)
  report << "Original: #{@original}"
  report << "Output:   #{@output}"
  report << "Status:   #{success? ? 'SUCCESS' : 'FAILED'}"
  report << ""

  if success?
    report << "Modifications:"
    report << "  Added:   #{@added}"
    report << "  Updated: #{@updated}"
    report << "  Removed: #{@removed}"
    report << "  Renamed: #{@renamed}"
    report << "  Total:   #{@modifications}"
  else
    report << "Error: #{@error}"
  end

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

#success?Boolean

Returns:

  • (Boolean)


289
290
291
# File 'lib/cabriolet/modifier.rb', line 289

def success?
  @success
end

#summaryObject



293
294
295
296
297
298
299
# File 'lib/cabriolet/modifier.rb', line 293

def summary
  if success?
    "Modified #{@modifications} items: +#{@added} ~#{@updated} -#{@removed}#{@renamed}"
  else
    "Modification failed: #{@error}"
  end
end