nestedtext 3.1.0 → 3.2.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/nestedtext/core_ext.rb +8 -0
- data/lib/nestedtext/decode.rb +3 -3
- data/lib/nestedtext/encode.rb +4 -4
- data/lib/nestedtext/version.rb +1 -1
- data/lib/nestedtext.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e19886916af03f3d5ef28b374957b529721fc1302aefa86d37483052dfcc96e
|
4
|
+
data.tar.gz: 7b0b78e029f5138341ea101567d2668c97a9681bef2f2830282ad00341b80c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a89a05ec0fba9ad2a397b16454b93de78751dda15d369b2a0704fc0e87bd426741b872a58fa236ff7814953eb6faa1a0681ac755c5eed4244560925863bfa5
|
7
|
+
data.tar.gz: 45e701d977422c34fc3ef2923b4a54c2bcb617fe973a867c343b7e16df94607ae0f2b5b22e515824e2245cdb4289b11fc88a11bdf12cc420e7552517c89e681a
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.2.0] - 2022-01-27
|
10
|
+
### Changed
|
11
|
+
- Switch from rdoc formatting syntax to Markdown with Redcarpet to be able to render README.md properly.
|
12
|
+
|
9
13
|
## [3.1.0] - 2022-01-27
|
10
14
|
### Changed
|
11
15
|
- Switch from rdoc to YARD to match rubydoc.info that is used automatically for Gems uploaded to rubygems.org.
|
data/lib/nestedtext/core_ext.rb
CHANGED
@@ -7,14 +7,22 @@ require "nestedtext/encode_helpers"
|
|
7
7
|
# Or both: add encoding/decoding of more native classes, and allow decoding + applying a schema with 3rd party.
|
8
8
|
# Or encourage using Marshal from core?
|
9
9
|
|
10
|
+
# Extended with the `#to_nt` method.
|
10
11
|
class String include NestedText::NTEncodeMixin; end
|
12
|
+
|
13
|
+
# Extended with the `#to_nt` method.
|
11
14
|
class Array include NestedText::NTEncodeMixin; end
|
15
|
+
|
16
|
+
# Extended with the `#to_nt` method.
|
12
17
|
class Hash include NestedText::NTEncodeMixin; end
|
13
18
|
|
19
|
+
# Extended with NestedText support.
|
14
20
|
class NilClass
|
15
21
|
include NestedText::NTEncodeMixin
|
16
22
|
|
23
|
+
# Adds support for encoding and decoding nil.
|
17
24
|
def self.nt_create(_data) = nil
|
18
25
|
|
26
|
+
# Adds support for encoding and decoding nil.
|
19
27
|
def encode_nt_with() = ""
|
20
28
|
end
|
data/lib/nestedtext/decode.rb
CHANGED
@@ -10,7 +10,7 @@ module NestedText
|
|
10
10
|
# Decode a NestedText string to Ruby objects.
|
11
11
|
#
|
12
12
|
# @param ntstring [String] The string containing NestedText to be decoded.
|
13
|
-
# @param top_class [String] Force the top level returned object to be of this type. Supported values are
|
13
|
+
# @param top_class [String] Force the top level returned object to be of this type. Supported values are `Object`, `Array`, `Hash` and `String`.
|
14
14
|
# @param strict [Boolean] If strict mode should be used.
|
15
15
|
#
|
16
16
|
# @return [Object, nil] The parsed object.
|
@@ -25,13 +25,13 @@ module NestedText
|
|
25
25
|
# Decode a NestedText stored in a given file.
|
26
26
|
#
|
27
27
|
# @param filename [String] The file path to read NestedText to decode from.
|
28
|
-
# @param top_class [String] Force the top level returned object to be of this type. Supported values are
|
28
|
+
# @param top_class [String] Force the top level returned object to be of this type. Supported values are `Object`, `Array`, `Hash` and `String`.
|
29
29
|
# @param strict [Boolean] If strict mode should be used.
|
30
30
|
#
|
31
31
|
# @return [Object, nil] The parsed object.
|
32
32
|
#
|
33
33
|
# @raise [NestedText::Error] if anything went wrong.
|
34
|
-
# @raise [IOError] on issue opening
|
34
|
+
# @raise [IOError] on issue opening `filename` for reading in text mode.
|
35
35
|
def self.load_file(filename, top_class: Object, strict: false)
|
36
36
|
raise Errors::WrongInputTypeError.new([String], filename) unless !filename.nil? && filename.is_a?(String)
|
37
37
|
|
data/lib/nestedtext/encode.rb
CHANGED
@@ -13,7 +13,7 @@ module NestedText
|
|
13
13
|
#
|
14
14
|
# @return A String containing NestedText data.
|
15
15
|
# @raise [NestedText::Error] if anything went wrong.
|
16
|
-
# @raise Whatever the
|
16
|
+
# @raise Whatever the `io` can raise, if supplied.
|
17
17
|
def self.dump(obj, io: nil, indentation: 4, strict: false)
|
18
18
|
raise Errors::DumpBadIOError, io unless io.nil? || io.respond_to?(:write) && io.respond_to?(:fsync)
|
19
19
|
|
@@ -28,15 +28,15 @@ module NestedText
|
|
28
28
|
|
29
29
|
# Encode a Ruby object to a NestedText file.
|
30
30
|
|
31
|
-
# Apart from
|
31
|
+
# Apart from `filename`, this method behaves exactly like dump.
|
32
32
|
#
|
33
33
|
# @param (see dump)
|
34
|
-
# @param filename [String] The file path to write the NestedText result to. The conventional file extension is
|
34
|
+
# @param filename [String] The file path to write the NestedText result to. The conventional file extension is `.nt`.
|
35
35
|
#
|
36
36
|
#
|
37
37
|
# @return (see dump)
|
38
38
|
# @raise (see dump)
|
39
|
-
# @raise [IOError] on issues opening the
|
39
|
+
# @raise [IOError] on issues opening the `filename` for writing in text mode.
|
40
40
|
#
|
41
41
|
def self.dump_file(obj, filename, **kwargs)
|
42
42
|
raise Errors::DumpFileBadPathError, filename unless filename.is_a? String
|
data/lib/nestedtext/version.rb
CHANGED
data/lib/nestedtext.rb
CHANGED