Module: Parslet::Toml::Merge
- Extended by:
- Merge
- Included in:
- Merge
- Defined in:
- lib/parslet/toml/merge.rb,
lib/parslet/toml/merge/version.rb
Defined Under Namespace
Modules: Version
Constant Summary collapse
Class Method Summary collapse
- .available_toml_backends ⇒ Object
- .match_toml_owners(template, destination) ⇒ Object
- .merge_toml(template_source, destination_source, dialect, backend: nil) ⇒ Object
- .parse_toml(source, dialect, backend: nil) ⇒ Object
- .toml_backend_feature_profile(backend: nil) ⇒ Object
- .toml_feature_profile ⇒ Object
- .toml_plan_context(backend: nil) ⇒ Object
- .unsupported_feature_result(message) ⇒ Object
Class Method Details
.available_toml_backends ⇒ Object
18 19 20 |
# File 'lib/parslet/toml/merge.rb', line 18 def available_toml_backends [BACKEND] end |
.match_toml_owners(template, destination) ⇒ Object
57 58 59 |
# File 'lib/parslet/toml/merge.rb', line 57 def match_toml_owners(template, destination) ::Toml::Merge.match_toml_owners(template, destination) end |
.merge_toml(template_source, destination_source, dialect, backend: nil) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/parslet/toml/merge.rb', line 61 def merge_toml(template_source, destination_source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND.id : backend.to_s return unsupported_feature_result("Unsupported TOML backend #{requested}.") unless requested == BACKEND.id ::Toml::Merge.merge_toml_with_parser(template_source, destination_source, dialect) do |source, parse_dialect| parse_toml(source, parse_dialect, backend: BACKEND.id) end end |
.parse_toml(source, dialect, backend: nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/parslet/toml/merge.rb', line 46 def parse_toml(source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND.id : backend.to_s return unsupported_feature_result("Unsupported TOML backend #{requested}.") unless requested == BACKEND.id return unsupported_feature_result("Unsupported TOML dialect #{dialect}.") unless dialect == "toml" syntax_result = TreeHaver.parse_with_parslet(source, grammar_class: TOML::Parslet) return { ok: false, diagnostics: syntax_result[:diagnostics], policies: [] } unless syntax_result[:ok] ::Toml::Merge.analyze_toml_source(source, dialect) end |
.toml_backend_feature_profile(backend: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/parslet/toml/merge.rb', line 22 def toml_backend_feature_profile(backend: nil) requested = backend.to_s.empty? ? BACKEND.id : backend.to_s return unsupported_feature_result("Unsupported TOML backend #{requested}.") unless requested == BACKEND.id toml_feature_profile.merge( backend: BACKEND.id, backend_ref: BACKEND.to_h ) end |
.toml_feature_profile ⇒ Object
14 15 16 |
# File 'lib/parslet/toml/merge.rb', line 14 def toml_feature_profile ::Toml::Merge.toml_feature_profile end |
.toml_plan_context(backend: nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/parslet/toml/merge.rb', line 32 def toml_plan_context(backend: nil) profile = toml_backend_feature_profile(backend: backend) return profile if profile[:ok] == false { family_profile: toml_feature_profile, feature_profile: { backend: profile[:backend], supports_dialects: false, supported_policies: profile[:supported_policies] } } end |
.unsupported_feature_result(message) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/parslet/toml/merge.rb', line 70 def unsupported_feature_result() { ok: false, diagnostics: [{ severity: "error", category: "unsupported_feature", message: }], policies: [] } end |