Class: FedoraMigrate::MigrationReport
- Inherits:
-
Object
- Object
- FedoraMigrate::MigrationReport
- Defined in:
- lib/fedora_migrate/migration_report.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #failed_objects ⇒ Object
- #failures ⇒ Object
-
#initialize(report = nil) ⇒ MigrationReport
constructor
A new instance of MigrationReport.
- #report_failures(output = String.new) ⇒ Object
- #save(path = nil) ⇒ Object
- #total_objects ⇒ Object
Constructor Details
#initialize(report = nil) ⇒ MigrationReport
Returns a new instance of MigrationReport.
6 7 8 |
# File 'lib/fedora_migrate/migration_report.rb', line 6 def initialize report=nil @results = report.nil? ? Hash.new : JSON.parse(File.read(report)) end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/fedora_migrate/migration_report.rb', line 4 def results @results end |
Instance Method Details
#empty? ⇒ Boolean
10 11 12 |
# File 'lib/fedora_migrate/migration_report.rb', line 10 def empty? results.empty? end |
#failed_objects ⇒ Object
14 15 16 |
# File 'lib/fedora_migrate/migration_report.rb', line 14 def failed_objects results.keys.map { |k| k unless results[k]["status"] }.compact end |
#failures ⇒ Object
18 19 20 |
# File 'lib/fedora_migrate/migration_report.rb', line 18 def failures failed_objects.count end |
#report_failures(output = String.new) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fedora_migrate/migration_report.rb', line 26 def report_failures output = String.new failed_objects.each do |k| output << "#{k}:\n\tobject: #{results[k]["object"]}\n\trelationships: #{results[k]["relationships"]}\n\n" end output end |
#save(path = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/fedora_migrate/migration_report.rb', line 33 def save path=nil json = JSON.load(results.to_json) file = path.nil? ? "report.json" : File.join(path,"report.json") File.write(file, JSON.pretty_generate(json)) end |
#total_objects ⇒ Object
22 23 24 |
# File 'lib/fedora_migrate/migration_report.rb', line 22 def total_objects results.keys.count end |