Class: Suma::SchemaComparer
- Inherits:
-
Object
- Object
- Suma::SchemaComparer
- Defined in:
- lib/suma/schema_comparer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#reference_schema ⇒ Object
readonly
Returns the value of attribute reference_schema.
-
#trial_schema ⇒ Object
readonly
Returns the value of attribute trial_schema.
Instance Method Summary collapse
- #compare ⇒ Object
-
#initialize(trial_schema, reference_schema, options = {}) ⇒ SchemaComparer
constructor
A new instance of SchemaComparer.
Constructor Details
#initialize(trial_schema, reference_schema, options = {}) ⇒ SchemaComparer
Returns a new instance of SchemaComparer.
10 11 12 13 14 |
# File 'lib/suma/schema_comparer.rb', line 10 def initialize(trial_schema, reference_schema, = {}) @trial_schema = trial_schema @reference_schema = reference_schema @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/suma/schema_comparer.rb', line 8 def @options end |
#reference_schema ⇒ Object (readonly)
Returns the value of attribute reference_schema.
8 9 10 |
# File 'lib/suma/schema_comparer.rb', line 8 def reference_schema @reference_schema end |
#trial_schema ⇒ Object (readonly)
Returns the value of attribute trial_schema.
8 9 10 |
# File 'lib/suma/schema_comparer.rb', line 8 def trial_schema @trial_schema end |
Instance Method Details
#compare ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/suma/schema_comparer.rb', line 16 def compare validate_inputs trial_stepmod = [:trial_stepmod] || detect_repo_root(trial_schema) reference_stepmod = [:reference_stepmod] || detect_repo_root(reference_schema) out_dir = Dir.mktmpdir("eengine-compare-") result = Eengine::Wrapper.compare( trial_schema, reference_schema, mode: [:mode] || "resource", trial_stepmod: trial_stepmod, reference_stepmod: reference_stepmod, out_dir: out_dir, ) unless result[:has_changes] FileUtils.rm_rf(out_dir) if File.directory?(out_dir) return nil end unless result[:xml_path] raise Suma::CompilationError, "XML output not found" end convert_to_change_yaml(result[:xml_path], out_dir) ensure FileUtils.rm_rf(out_dir) if out_dir && File.directory?(out_dir) end |