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
- #empty? ⇒ Boolean
- #failed_objects ⇒ Object
- #failures ⇒ Object
-
#initialize(path = nil) ⇒ MigrationReport
constructor
A new instance of MigrationReport.
- #reload ⇒ Object
- #report_failures(output = String.new) ⇒ 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.
8 9 10 11 12 |
# File 'lib/fedora_migrate/migration_report.rb', line 8 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.
4 5 6 |
# File 'lib/fedora_migrate/migration_report.rb', line 4 def path @path end |
#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
18 19 20 |
# File 'lib/fedora_migrate/migration_report.rb', line 18 def empty? results.empty? end |
#failed_objects ⇒ Object
22 23 24 |
# File 'lib/fedora_migrate/migration_report.rb', line 22 def failed_objects results.keys.map { |k| k unless results[k]["status"] }.compact end |
#failures ⇒ Object
26 27 28 |
# File 'lib/fedora_migrate/migration_report.rb', line 26 def failures failed_objects.count end |
#reload ⇒ Object
14 15 16 |
# File 'lib/fedora_migrate/migration_report.rb', line 14 def reload @results = load_results_from_directory end |
#report_failures(output = String.new) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/fedora_migrate/migration_report.rb', line 34 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(pid, report) ⇒ Object
Receives and individual report and writes it to the MigrationReport directory
42 43 44 45 46 |
# File 'lib/fedora_migrate/migration_report.rb', line 42 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
30 31 32 |
# File 'lib/fedora_migrate/migration_report.rb', line 30 def total_objects results.keys.count end |