class FedoraMigrate::MigrationReport
Constants
- DEFAULT_PATH
Attributes
path[RW]
results[RW]
Public Class Methods
new(path = nil)
click to toggle source
# 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
Public Instance Methods
failed_objects()
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 19 def failed_objects results.keys.map { |k| k unless results[k]["status"] }.compact end
failures()
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 23 def failures failed_objects.count end
reload()
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 13 def reload @results = load_results_from_directory end
report_failures(output = '')
click to toggle source
# 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)
click to toggle source
Receives and individual report and writes it to the MigrationReport
directory
# 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()
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 27 def total_objects results.keys.count end
Private Instance Methods
file_from_pid(pid)
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 58 def file_from_pid(pid) pid.tr(':', "_") + ".json" end
load_results_from_directory(assembled = {})
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 47 def load_results_from_directory(assembled = {}) Dir.glob(File.join(path, "*.json")).each do |file| assembled[pid_from_file(file)] = JSON.parse(File.read(file)) end assembled end
pid_from_file(file)
click to toggle source
# File lib/fedora_migrate/migration_report.rb, line 54 def pid_from_file(file) File.basename(file, ".*").tr('_', ":") end