Class: FedoraMigrate::MigrationReport
- Inherits:
-
Object
- Object
- FedoraMigrate::MigrationReport
- Defined in:
- lib/fedora_migrate/migration_report.rb
Constant Summary collapse
- DEFAULT_PATH =
"migration_report".freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #failed_objects ⇒ Object
- #failures ⇒ Object
-
#initialize(path = nil) ⇒ MigrationReport
constructor
A new instance of MigrationReport.
- #reload ⇒ Object
- #report_failures(output = '') ⇒ Object
-
#save(pid, report) ⇒ Object
Receives and individual report and writes it to the MigrationReport directory.
- #total_objects ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ MigrationReport
Returns a new instance of MigrationReport.
7 8 9 10 11 |
# File 'lib/fedora_migrate/migration_report.rb', line 7 def initialize(path = nil) @path = path.nil? ? DEFAULT_PATH : path FileUtils.mkdir_p(@path) reload end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/fedora_migrate/migration_report.rb', line 3 def path @path end |
#results ⇒ Object
Returns the value of attribute results.
3 4 5 |
# File 'lib/fedora_migrate/migration_report.rb', line 3 def results @results end |
Instance Method Details
#failed_objects ⇒ Object
19 20 21 |
# File 'lib/fedora_migrate/migration_report.rb', line 19 def failed_objects results.keys.map { |k| k unless results[k]["status"] }.compact end |
#failures ⇒ Object
23 24 25 |
# File 'lib/fedora_migrate/migration_report.rb', line 23 def failures failed_objects.count end |
#reload ⇒ Object
13 14 15 |
# File 'lib/fedora_migrate/migration_report.rb', line 13 def reload @results = load_results_from_directory end |
#report_failures(output = '') ⇒ Object
31 32 33 34 35 36 |
# File 'lib/fedora_migrate/migration_report.rb', line 31 def report_failures(output = '') failed_objects.each do |k| output << "#{k}:\n\tobject: #{results[k]['object']}\n\trelationships: #{results[k]['relationships']}\n\n" end output end |
#save(pid, report) ⇒ Object
Receives and individual report and writes it to the MigrationReport directory
39 40 41 42 43 |
# File 'lib/fedora_migrate/migration_report.rb', line 39 def save(pid, report) file = File.join(path, file_from_pid(pid)) json = JSON.load(report.to_json) File.write(file, JSON.pretty_generate(json)) end |
#total_objects ⇒ Object
27 28 29 |
# File 'lib/fedora_migrate/migration_report.rb', line 27 def total_objects results.keys.count end |