Class: StructuredDataToSql::Json::ExporterManifest
- Inherits:
-
Object
- Object
- StructuredDataToSql::Json::ExporterManifest
- Defined in:
- lib/structured_data_to_sql/json/exporter_manifest.rb
Overview
Reads the Khoros exporter's manifest.json (kept beside the ndjson/
directory) just far enough to scope quality signals to the latest run.
Everything is best-effort: a missing or unparsable manifest yields an
instance with problem set and no runs; nothing here ever raises.
Defined Under Namespace
Classes: Run
Constant Summary collapse
- FILENAME =
"manifest.json"
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#problem ⇒ Object
readonly
Returns the value of attribute problem.
-
#runs ⇒ Object
readonly
Returns the value of attribute runs.
Class Method Summary collapse
- .load(path) ⇒ Object
-
.locate(source) ⇒ Object
Looks in the source directory itself and in its parent, so both
export/ndjsonandexport/work as the conversion source.
Instance Method Summary collapse
- #errors_total ⇒ Object
- #gaps_total ⇒ Object
-
#initialize(path) ⇒ ExporterManifest
constructor
A new instance of ExporterManifest.
- #latest_completed ⇒ Object
Constructor Details
#initialize(path) ⇒ ExporterManifest
Returns a new instance of ExporterManifest.
60 61 62 63 64 65 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 60 def initialize(path) @path = Pathname(path) @runs = [] @problem = nil parse end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
33 34 35 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 33 def path @path end |
#problem ⇒ Object (readonly)
Returns the value of attribute problem.
33 34 35 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 33 def problem @problem end |
#runs ⇒ Object (readonly)
Returns the value of attribute runs.
33 34 35 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 33 def runs @runs end |
Class Method Details
.load(path) ⇒ Object
54 55 56 57 58 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 54 def self.load(path) return nil if path.nil? new(path) end |
.locate(source) ⇒ Object
Looks in the source directory itself and in its parent, so both
export/ndjson and export/ work as the conversion source.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 37 def self.locate(source) source = source.first if source.is_a?(Array) return nil unless source.is_a?(String) || source.is_a?(Pathname) base = Pathname(source) base = base.dirname if base.file? return nil unless base.directory? [base, base.parent].each do |directory| candidate = directory.join(FILENAME) return candidate if candidate.file? end nil rescue SystemCallError nil end |
Instance Method Details
#errors_total ⇒ Object
71 72 73 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 71 def errors_total @runs.sum(&:errors) end |
#gaps_total ⇒ Object
75 76 77 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 75 def gaps_total @runs.sum(&:gaps) end |
#latest_completed ⇒ Object
67 68 69 |
# File 'lib/structured_data_to_sql/json/exporter_manifest.rb', line 67 def latest_completed @runs.reverse.find(&:completed?) end |