nestedtext 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfafdf3e9638459777da2f7209954955473758103c72533b58a66cc23f4020e3
4
- data.tar.gz: 400fd879811f4d09c193da219ffa0ff61853ee0e51baac386c58b7016dfbe354
3
+ metadata.gz: b8601948a65f9660f63e8f84838452cd440219f3b188c09c0418d0dd557f1bfc
4
+ data.tar.gz: 8dd84452b7610602be994fb39d2d4c54e9c1912e901950257bc5db890ca6f92c
5
5
  SHA512:
6
- metadata.gz: 708025814b4038b1b5c6eea70378762e1155ae73e933cc902a17d26d4ce3efbb2a5b52f7d535c385818e34484fe12278f981c253469d80a875e97aa8f25b20c1
7
- data.tar.gz: fe87505719301bf79a71cdef1c9d89d71f9058318f5f59f1305ac79b0b69007b79976d6e288a4846824c6cc89323021b4b29df56b8f14f534cd59906d55b0843
6
+ metadata.gz: b94b31da3ac93c342a635d3ad7cc719af5c4f24567214aaf492ecc3db8153bbf744dec6525b46f7303f6ea9f6b5bf8639725e447d54854570a5cc59a41c39b9f
7
+ data.tar.gz: 2de78ff35eb164a9463160aad408ad44293a325a17b4d51881c6f8e48539b2fef2c304e4ebf58c99dc27ea716ff3e50d242b6f5a61c815f691e679d347fc67b6
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.1.0] - 2022-01-27
10
+ ### Changed
11
+ - Switch from rdoc to YARD to match rubydoc.info that is used automatically for Gems uploaded to rubygems.org.
12
+
9
13
  ## [3.0.0] - 2022-01-27
10
14
  ### Added
11
15
  - API documentation generated with rdoc.
data/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  A ruby library for the human friendly data format [NestedText](https://nestedtext.org/).
18
18
 
19
- <a href="#" ><img src="https://raw.githubusercontent.com/erikw/nestedtext-ruby/main/img/logo.webp" align="right" width="420px" alt="Project logo" /></a>
19
+ <a href="#" ><img src="img/logo.webp" align="right" width="420px" alt="Project logo" /></a>
20
20
 
21
21
  Provided is support for decoding a NestedText file or string to Ruby data structures, as well as encoding Ruby objects to a NestedText file or string. Furthermore there is support for serialization and deserialization of custom classes. The supported language version of the data format can be see in the badge above. This implementation pass all the [official tests](https://github.com/KenKundert/nestedtext_tests).
22
22
 
@@ -111,7 +111,7 @@ NestedText::dump_file(data, "path/to/data.nt")
111
111
  ### `#to_nt` Convenience
112
112
  To make it more convenient, the Ruby Core is extended with a `#to_nt` method on the supported types that will dump a String of the data structure. Here's an IRB session showing how it works:
113
113
 
114
- ```irb
114
+ ```ruby
115
115
  irb> require 'nestedtext'
116
116
  irb> puts "a\nstring".to_nt
117
117
  > a
@@ -120,7 +120,10 @@ irb> puts ["i1", "i2", "i3"].to_nt
120
120
  - i1
121
121
  - i2
122
122
  - i3
123
- irb> puts({"k1" => "v1", "multiline\nkey" => "v2", "k3" => ["a", "list"]}.to_nt)
123
+ irb> hash = {"k1" => "v1",
124
+ "multiline\nkey" => "v2",
125
+ "k3" => ["a", "list"]}
126
+ irb> puts hash.to_nt
124
127
  k1: v1
125
128
  : multiline
126
129
  : key
@@ -9,13 +9,13 @@ require "stringio"
9
9
  module NestedText
10
10
  # Decode a NestedText string to Ruby objects.
11
11
  #
12
- # [ntstring] The string containing NestedText to be decoded.
13
- # [top_class] Force the top level returned object to be of this type. Supported values are +Object+, +Array+, +Hash+ and +String+. Default is +Object+.
14
- # [strict] If strict mode should be used. +true+ or +false+. Default is +false+
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 +Object+, +Array+, +Hash+ and +String+.
14
+ # @param strict [Boolean] If strict mode should be used.
15
15
  #
16
- # Returns the parsed object.
16
+ # @return [Object, nil] The parsed object.
17
17
  #
18
- # Raises NestedText::Error if anything went wrong.
18
+ # @raise [NestedText::Error] if anything went wrong.
19
19
  def self.load(ntstring, top_class: Object, strict: false)
20
20
  raise Errors::WrongInputTypeError.new([String], ntstring) unless ntstring.nil? || ntstring.is_a?(String)
21
21
 
@@ -23,16 +23,15 @@ module NestedText
23
23
  end
24
24
 
25
25
  # Decode a NestedText stored in a given file.
26
-
27
- # [filename] The file path to read NestedText to decode from.
28
- # [top_class] Force the top level returned object to be of this type. Supported values are +Object+, +Array+, +Hash+ and +String+. Default is +Object+.
29
- # [strict] If strict mode should be used. +true+ or +false+. Default is +false+
30
26
  #
31
- # Returns the parsed object.
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 +Object+, +Array+, +Hash+ and +String+.
29
+ # @param strict [Boolean] If strict mode should be used.
32
30
  #
33
- # Raises NestedText::Error if anything went wrong.
31
+ # @return [Object, nil] The parsed object.
34
32
  #
35
- # Raises +IOError+ on issue opening +filename+ for reading in text mode.
33
+ # @raise [NestedText::Error] if anything went wrong.
34
+ # @raise [IOError] on issue opening +filename+ for reading in text mode.
36
35
  def self.load_file(filename, top_class: Object, strict: false)
37
36
  raise Errors::WrongInputTypeError.new([String], filename) unless !filename.nil? && filename.is_a?(String)
38
37
 
@@ -6,16 +6,14 @@ require "nestedtext/errors_internal"
6
6
  module NestedText
7
7
  # Encode a Ruby object to a NestedText string.
8
8
  #
9
- # [obj] The object to encode to NestedText.
10
- # [io] Additionally write the output to this IO object. The caller is responsible for that the IO is closed after the call to this method.
11
- # [indentation] The indentation of nested levels to use.
12
- # [strict] If strict mode should be used. +true+ or +false+. Default is +false+
9
+ # @param obj [Object] The object to encode to NestedText.
10
+ # @param io [IO] Additionally write the output to this IO object. The caller is responsible for that the IO is closed after the call to this method.
11
+ # @param indentation [Integer] The indentation of nested levels to use.
12
+ # @param strict [Boolean] If strict mode should be used.
13
13
  #
14
- # Returns a String containing NestedText data.
15
- #
16
- # Raises NestedText::Error if anything went wrong.
17
- #
18
- # Raises whatever the passed +io+ can raise.
14
+ # @return A String containing NestedText data.
15
+ # @raise [NestedText::Error] if anything went wrong.
16
+ # @raise Whatever the +io+ can raise, if supplied.
19
17
  def self.dump(obj, io: nil, indentation: 4, strict: false)
20
18
  raise Errors::DumpBadIOError, io unless io.nil? || io.respond_to?(:write) && io.respond_to?(:fsync)
21
19
 
@@ -29,12 +27,17 @@ module NestedText
29
27
  end
30
28
 
31
29
  # Encode a Ruby object to a NestedText file.
30
+
31
+ # Apart from +filename+, this method behaves exactly like dump.
32
+ #
33
+ # @param (see dump)
34
+ # @param filename [String] The file path to write the NestedText result to. The conventional file extension is +.nt+.
32
35
  #
33
- # [filename] The file path to write the NestedText result to. The conventional file extension is +.nt+.
34
36
  #
35
- # Raises +IOError+ on issues opening the +filename+ for writing in text mode.
37
+ # @return (see dump)
38
+ # @raise (see dump)
39
+ # @raise [IOError] on issues opening the +filename+ for writing in text mode.
36
40
  #
37
- # Apart from +filename+, this method behaves exactly like dump (taking same arguments, returning and raising the same values).
38
41
  def self.dump_file(obj, filename, **kwargs)
39
42
  raise Errors::DumpFileBadPathError, filename unless filename.is_a? String
40
43
 
@@ -6,7 +6,7 @@ module NestedText
6
6
  module NTEncodeMixin
7
7
  # Encode this object to a NestedText string.
8
8
  #
9
- # This method takes the same arguments as NestedText::dump.
9
+ # This method takes the same named arguments as {NestedText.dump}.
10
10
  def to_nt(**kwargs)
11
11
  NestedText.dump(self, strict: false, **kwargs)
12
12
  end
@@ -1,7 +1,7 @@
1
1
  module NestedText
2
2
  # Top level error to rescue on.
3
3
  #
4
- # +Error+ is a subclass of +StandardError+ and behaves as expected e.g. +#message+.
4
+ # Error is a subclass of StandardError and behaves as expected e.g. #message.
5
5
  class Error < StandardError
6
6
  private_class_method :new
7
7
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module NestedText
4
4
  # The version of this library.
5
- VERSION = "3.0.0"
5
+ VERSION = "3.1.0"
6
6
  end
data/lib/nestedtext.rb CHANGED
@@ -11,6 +11,6 @@ require_relative "nestedtext/version"
11
11
  # = NestedText
12
12
  # The main module in this library to use.
13
13
  #
14
- # See README.md for documentation on Types, Strict Mode and Custom Classes.
14
+ # See {file:README.md} for documentation on Types, Strict Mode and Custom Classes.
15
15
  module NestedText
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nestedtext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Westrup