lutaml-model 0.8.165 → 0.8.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3540b4bb5e740bd2f3bda909b1e570b822f82d04703cb11347e9b8124cda5538
4
- data.tar.gz: 29e6a45a50e57f6d8b6412e60251b26c118511b1fdbfa3091fb42fabd3b6d792
3
+ metadata.gz: 5e26cb512515f146956b2f1f1b601a9fd810ef0fdf606e98963001e28b6fe249
4
+ data.tar.gz: 72e5bbd3f54f084abb92c34d63442cb0dee383851a1f4a78580b48bdf3651b8f
5
5
  SHA512:
6
- metadata.gz: b3dce5f2bc083bf9b41ab3e1959ffb828294bfedc82d102fdae4e7419df1c3b18fb707fb19388317b9a5e8f95b910ed22b8b2c124ddf4be74c7b7e1ebf5ee8f6
7
- data.tar.gz: 854bd87449c9af4574ae68f44fc50ee61aa5d1906944e3a9c10c50fbc4fe8f762f6b5eec1ec48093106d7571775e9520dcf7358ff642af36a55bfe15bd3e0ac7
6
+ metadata.gz: 682c8dd4ea109bd97314cc01f32a4ea32f489176603e4a0a115679d2c6cd3f517490da31f72c6df6c5059389f12037827d9933cf35eeb7b8e33eb86cb31d1657
7
+ data.tar.gz: 98beef43e550b5cd69d76824a0c3a0a5cd266477aefd6382315ef0fdb06026b8fea0662e7f76b774c5094efe396140305f2b4146d82596c7d3f5b1e8969c92a7
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.165"
5
+ VERSION = "0.8.166"
6
6
  end
7
7
  end
@@ -23,8 +23,14 @@ module Lutaml
23
23
 
24
24
  results
25
25
  rescue *Lutaml::Model::Utils.yaml_parse_errors => e
26
+ results = parse_with_split(yamls)
27
+ # A stream that yields no valid document is invalid, not empty —
28
+ # raise so transports skip the file instead of registering a
29
+ # blank model.
30
+ raise e if results.empty?
31
+
26
32
  warn "Skipping invalid yaml: #{e.message}"
27
- parse_with_split(yamls)
33
+ results
28
34
  end
29
35
 
30
36
  def self.parse_with_split(yamls)
@@ -27,11 +27,22 @@ module Lutaml
27
27
  # Tolerant iteration (yeptris#921): the engine frames the
28
28
  # documents and reports failures per document; the host
29
29
  # never touches the YAML text.
30
+ invalid_seen = false
30
31
  # rubocop:disable-next Naming/VariableNumber -- upstream schema literal
31
32
  ::Yeptris::YAML.each_document(yamls, schema: :compat_11) do |doc, error|
32
- warn "Skipping invalid yaml: #{error.message}" if error
33
+ if error
34
+ invalid_seen = true
35
+ warn "Skipping invalid yaml: #{error.message}"
36
+ end
33
37
  results << doc unless error || doc.nil?
34
38
  end
39
+ # A stream that yields no valid document is invalid, not
40
+ # empty — raise so transports skip the file instead of
41
+ # registering a blank model.
42
+ if results.empty? && invalid_seen
43
+ raise Lutaml::Model::InvalidFormatError,
44
+ "no valid documents in the yaml stream"
45
+ end
35
46
  return results
36
47
  end
37
48
 
@@ -39,8 +50,11 @@ module Lutaml
39
50
  results = Yeptris::YAML.load_stream(yamls, schema: :compat_11)
40
51
  results.compact
41
52
  rescue Yeptris::ParseError => e
53
+ results = parse_with_split(yamls)
54
+ raise e if results.empty?
55
+
42
56
  warn "Skipping invalid yaml: #{e.message}"
43
- parse_with_split(yamls)
57
+ results
44
58
  end
45
59
 
46
60
  def self.require_engine
@@ -65,6 +65,13 @@ RSpec.describe Lutaml::Model::Yamls::StandardAdapter do
65
65
  end
66
66
  end
67
67
 
68
+ context "with a fully-invalid stream" do
69
+ it "raises instead of returning a blank document set" do
70
+ expect { described_class.parse("not: valid: yaml: [") }
71
+ .to raise_error(Psych::SyntaxError)
72
+ end
73
+ end
74
+
68
75
  context "with single document" do
69
76
  let(:single_yaml_doc) do
70
77
  <<~YAMLS
@@ -66,5 +66,15 @@ RSpec.describe Lutaml::Yamls::Adapter::YeptrisAdapter, if: Lutaml::Yamls::Adapte
66
66
  results = described_class.parse("name: John\nage: 30\n")
67
67
  expect(results).to eq([{ "name" => "John", "age" => 30 }])
68
68
  end
69
+
70
+ it "raises on a fully-invalid stream instead of returning a blank set" do
71
+ expect { described_class.parse("not: valid: yaml: [") }
72
+ .to raise_error(StandardError)
73
+ end
74
+
75
+ it "tolerates mixed streams but raises when nothing valid remains" do
76
+ results = described_class.parse("name: a\n---\nbad: [\n---\nname: c\n")
77
+ expect(results).to eq([{ "name" => "a" }, { "name" => "c" }])
78
+ end
69
79
  end
70
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.165
4
+ version: 0.8.166
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.