yeptris 0.1.8.1 → 0.1.8.2

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: cce504357e9e57226d9b6011ee06517ece957d208069248c7d8cad4730e07bf3
4
- data.tar.gz: 4c9e00bc652956849708b2947762acfa89310122fedcce225390251ab079b4d1
3
+ metadata.gz: 417f0358e7e709bb927f0c6feb204284d406586b32256115c817bb064a3f1ce5
4
+ data.tar.gz: 0fb2d3897c2c71fd85b8dcd56dd560c6a72f0bb8506eeb08d7cbf49ed9b965d3
5
5
  SHA512:
6
- metadata.gz: 8c9f7bad9c4990646c33145483ddfe7f3b398c5293797704b666b6826129178573c48ff073a480c40c8ef659e11e3856d173565e2809f6dd16e016277a546af8
7
- data.tar.gz: 7ab59b9e81f80fdcbe13b67220d01eccc4104a06dbb9d653cc801dfa3f2c93e9a9093f55771d849c5031328ddea219012865fd9d38f1978a38645507e6f19709
6
+ metadata.gz: 0ee8112cefa23840c684eb5d629fb5f76fe3b71f2d6969c3bfbe3584318fd7007dd0f6938259b23341723d114134603e46e246c62cc3b435b9a323ae7de143a8
7
+ data.tar.gz: f9a6e05da30b27212dc1773c64edc32a1ee2dac6737f18be8dcddb2d63aad7ca4597e085fd7f8b47ff1472deb464d17ccf90cb45e9b9b9e3768925ae0b47b249
@@ -20,7 +20,7 @@ class Yeptris::Document
20
20
  end
21
21
 
22
22
  def self.parse(yaml, schema: :core_12, max_depth: 0)
23
- yaml = yaml.read if yaml.respond_to?(:read)
23
+ yaml = Yeptris.read_input(yaml)
24
24
  yaml = yaml.to_s
25
25
  doc =
26
26
  if schema == :core_12 && max_depth.zero?
@@ -41,7 +41,7 @@ class Yeptris::Document
41
41
  end
42
42
 
43
43
  def self.parse_json(json)
44
- json = json.read if json.respond_to?(:read)
44
+ json = Yeptris.read_input(json)
45
45
  json = json.to_s
46
46
  doc = Yeptris::FFI.yeptris_parse_json(json, json.bytesize, nil)
47
47
  raise Yeptris::ParseError,
@@ -205,7 +205,7 @@ module Yeptris
205
205
  end
206
206
 
207
207
  def materialize(yaml)
208
- yaml = yaml.read if yaml.respond_to?(:read)
208
+ yaml = Yeptris.read_input(yaml)
209
209
  yaml = yaml.to_s
210
210
  flat, arena = Materializer.drain(yaml, schema: @schema)
211
211
  walk(flat, arena)
@@ -21,7 +21,7 @@ module Yeptris
21
21
  end
22
22
 
23
23
  def parse(yaml, filename = nil)
24
- yaml = yaml.read if yaml.respond_to?(:read)
24
+ yaml = Yeptris.read_input(yaml)
25
25
  yaml = yaml.to_s
26
26
  @filename = filename
27
27
  flat, arena = Materializer.drain(yaml, schema: :compat_11)
data/lib/yeptris/psych.rb CHANGED
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "yeptris"
4
- require "yeptris/psych/handler"
5
- require "yeptris/psych/parser"
6
- require "yeptris/psych/coder_shim"
7
- require "yeptris/psych/visitors"
8
-
9
3
  # The Psych drop-in namespace (TODO.impl/15 phase C).
10
4
  #
11
5
  # `require "yeptris/psych"` rebinds the top-level Psych constant to
@@ -17,6 +11,15 @@ require "yeptris/psych/visitors"
17
11
  # document without materializing.
18
12
  module Yeptris
19
13
  module Psych
14
+ # Children load via autoload declared HERE — the immediate parent
15
+ # namespace's file (never internal requires).
16
+ autoload :Handler, "yeptris/psych/handler"
17
+ # Handlers (the Recorder submodule) lives in handler.rb too — its
18
+ # own entry so referencing Psych::Handlers triggers the load
19
+ autoload :Handlers, "yeptris/psych/handler"
20
+ autoload :Parser, "yeptris/psych/parser"
21
+ autoload :CoderShim, "yeptris/psych/coder_shim"
22
+ autoload :Visitors, "yeptris/psych/visitors"
20
23
  class Error < StandardError; end
21
24
  class SyntaxError < Error
22
25
  attr_reader :line, :column
@@ -29,7 +29,7 @@ module Yeptris
29
29
  module_function
30
30
 
31
31
  def load_all(yaml, schema: :compat_11)
32
- yaml = yaml.read if yaml.respond_to?(:read)
32
+ yaml = Yeptris.read_input(yaml)
33
33
  yaml = yaml.to_s
34
34
  vals_p = ::FFI::MemoryPointer.new(:pointer)
35
35
  count_p = ::FFI::MemoryPointer.new(:uint64)
@@ -60,7 +60,7 @@ module Yeptris
60
60
  # Semantics are IDENTICAL to the record walk — the two bodies are
61
61
  # maintained in lockstep; field-access shape is the only difference.
62
62
  def load_all_columns(yaml, schema: :compat_11)
63
- yaml = yaml.read if yaml.respond_to?(:read)
63
+ yaml = Yeptris.read_input(yaml)
64
64
  yaml = yaml.to_s
65
65
  cols = FFI::ValueColumns.new
66
66
  st = FFI.yeptris_value_drain_columns(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yeptris
4
- VERSION = "0.1.8.1"
4
+ VERSION = "0.1.8.2"
5
5
  end
data/lib/yeptris.rb CHANGED
@@ -3,14 +3,44 @@
3
3
  require "yeptris/version"
4
4
 
5
5
  module Yeptris
6
- # eager: nested constants (Yeptris::ParseError etc.) do NOT trigger
7
- # a parent-constant autoload, so the error hierarchy loads up front
8
- require_relative "yeptris/error"
6
+ # The error hierarchy lives in THIS file (the parent namespace's
7
+ # own file): nested constants do not trigger a parent-constant
8
+ # autoload, and the law forbids internal requires — defining the
9
+ # hierarchy here makes it eager by construction.
10
+
11
+ # The base error for everything this library raises deliberately.
12
+ class Error < StandardError; end
13
+
14
+ # The input is not valid YAML (or valid for the requested mode).
15
+ # message carries the C parser's line/column detail.
16
+ class ParseError < Error; end
17
+
18
+ # A handle was used after its document was freed. Raised, never a
19
+ # segfault: the Document is the sole C-memory owner and every Node
20
+ # checks liveness through it.
21
+ class FreedError < Error; end
22
+
23
+ # Building a document from a Ruby object graph hit something the
24
+ # builder refuses (cycles, unsupported objects).
25
+ class DumpError < Error; end
26
+
27
+ # Input coercion — the ONE place the input boundary is typed
28
+ # (no respond_to? duck-probing): IO-like objects read, Strings
29
+ # pass through, anything else must be stringable and is.
30
+ def self.read_input(source)
31
+ case source
32
+ when String then source
33
+ when IO, StringIO then source.read
34
+ else source.to_s
35
+ end
36
+ end
37
+
9
38
  autoload :Document, "yeptris/document"
10
39
  autoload :Node, "yeptris/node"
11
40
  autoload :YAML, "yeptris/yaml"
12
41
  autoload :Materializer, "yeptris/materializer"
13
42
  autoload :ValueML, "yeptris/valueml"
43
+ autoload :Psych, "yeptris/psych"
14
44
  end
15
45
 
16
46
  # Eager native-library resolution (leptris-ruby lesson): fail at
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.1
4
+ version: 0.1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -35,7 +35,6 @@ files:
35
35
  - README.adoc
36
36
  - lib/yeptris.rb
37
37
  - lib/yeptris/document.rb
38
- - lib/yeptris/error.rb
39
38
  - lib/yeptris/ffi.rb
40
39
  - lib/yeptris/materializer.rb
41
40
  - lib/yeptris/node.rb
data/lib/yeptris/error.rb DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Yeptris
4
- # The base error for everything this library raises deliberately.
5
- class Error < StandardError; end
6
-
7
- # The input is not valid YAML (or valid for the requested mode).
8
- # message carries the C parser's line/column detail.
9
- class ParseError < Error; end
10
-
11
- # A handle was used after its document was freed. Raised, never a
12
- # segfault: the Document is the sole C-memory owner and every Node
13
- # checks liveness through it.
14
- class FreedError < Error; end
15
-
16
- # Building a document from a Ruby object graph hit something the
17
- # builder refuses (cycles, unsupported objects).
18
- class DumpError < Error; end
19
- end