shale 0.5.0 → 0.7.1

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.
@@ -32,7 +32,7 @@ module Shale
32
32
  # @return [String]
33
33
  #
34
34
  # @api private
35
- def self.as_json(value)
35
+ def self.as_json(value, **)
36
36
  value&.iso8601
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ module Shale
43
43
  # @return [String]
44
44
  #
45
45
  # @api private
46
- def self.as_yaml(value)
46
+ def self.as_yaml(value, **)
47
47
  value&.iso8601
48
48
  end
49
49
 
@@ -32,7 +32,7 @@ module Shale
32
32
  # @return [String]
33
33
  #
34
34
  # @api private
35
- def self.as_json(value)
35
+ def self.as_json(value, **)
36
36
  value&.iso8601
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ module Shale
43
43
  # @return [String]
44
44
  #
45
45
  # @api private
46
- def self.as_yaml(value)
46
+ def self.as_yaml(value, **)
47
47
  value&.iso8601
48
48
  end
49
49
 
@@ -30,7 +30,7 @@ module Shale
30
30
  # @return [any]
31
31
  #
32
32
  # @api private
33
- def of_hash(value)
33
+ def of_hash(value, **)
34
34
  value
35
35
  end
36
36
 
@@ -41,7 +41,7 @@ module Shale
41
41
  # @return [any]
42
42
  #
43
43
  # @api private
44
- def as_hash(value)
44
+ def as_hash(value, **)
45
45
  value
46
46
  end
47
47
 
@@ -52,7 +52,7 @@ module Shale
52
52
  # @return [any]
53
53
  #
54
54
  # @api private
55
- def of_json(value)
55
+ def of_json(value, **)
56
56
  value
57
57
  end
58
58
 
@@ -63,7 +63,7 @@ module Shale
63
63
  # @return [any]
64
64
  #
65
65
  # @api private
66
- def as_json(value)
66
+ def as_json(value, **)
67
67
  value
68
68
  end
69
69
 
@@ -74,7 +74,7 @@ module Shale
74
74
  # @return [any]
75
75
  #
76
76
  # @api private
77
- def of_yaml(value)
77
+ def of_yaml(value, **)
78
78
  value
79
79
  end
80
80
 
@@ -85,7 +85,29 @@ module Shale
85
85
  # @return [any]
86
86
  #
87
87
  # @api private
88
- def as_yaml(value)
88
+ def as_yaml(value, **)
89
+ value
90
+ end
91
+
92
+ # Extract value from TOML document
93
+ #
94
+ # @param [any] value
95
+ #
96
+ # @return [any]
97
+ #
98
+ # @api private
99
+ def of_toml(value, **)
100
+ value
101
+ end
102
+
103
+ # Convert value to form accepted by TOML document
104
+ #
105
+ # @param [any] value
106
+ #
107
+ # @return [any]
108
+ #
109
+ # @api private
110
+ def as_toml(value, **)
89
111
  value
90
112
  end
91
113
 
@@ -96,7 +118,7 @@ module Shale
96
118
  # @return [String]
97
119
  #
98
120
  # @api private
99
- def of_xml(node)
121
+ def of_xml(node, **)
100
122
  node.text
101
123
  end
102
124
 
@@ -116,11 +138,18 @@ module Shale
116
138
  # @param [#to_s] value Value to convert to XML
117
139
  # @param [String] name Name of the element
118
140
  # @param [Shale::Adapter::<XML adapter>::Document] doc Document
141
+ # @param [true, false] cdata
119
142
  #
120
143
  # @api private
121
- def as_xml(value, name, doc)
144
+ def as_xml(value, name, doc, cdata = false, **)
122
145
  element = doc.create_element(name)
123
- doc.add_text(element, as_xml_value(value))
146
+
147
+ if cdata
148
+ doc.create_cdata(as_xml_value(value), element)
149
+ else
150
+ doc.add_text(element, as_xml_value(value))
151
+ end
152
+
124
153
  element
125
154
  end
126
155
  end
data/lib/shale/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Shale
4
4
  # @api private
5
- VERSION = '0.5.0'
5
+ VERSION = '0.7.1'
6
6
  end
data/lib/shale.rb CHANGED
@@ -72,6 +72,20 @@ module Shale
72
72
  # @api public
73
73
  attr_writer :yaml_adapter
74
74
 
75
+ # TOML adapter accessor.
76
+ #
77
+ # @param [@see Shale::Adapter::TomlRB] adapter
78
+ #
79
+ # @example setting adapter
80
+ # Shale.toml_adapter = Shale::Adapter::TomlRB
81
+ #
82
+ # @example getting adapter
83
+ # Shale.toml_adapter
84
+ # # => Shale::Adapter::TomlRB
85
+ #
86
+ # @api public
87
+ attr_accessor :toml_adapter
88
+
75
89
  # XML adapter accessor. Available adapters are Shale::Adapter::REXML,
76
90
  # Shale::Adapter::Nokogiri and Shale::Adapter::Ox
77
91
  #
data/shale.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Kamil Giszczak']
9
9
  spec.email = ['beerkg@gmail.com']
10
10
 
11
- spec.summary = 'Ruby object mapper and serializer for XML, JSON and YAML.'
12
- spec.description = 'Ruby object mapper and serializer for XML, JSON and YAML.'
11
+ spec.summary = 'Ruby object mapper and serializer for XML, JSON, TOML and YAML.'
12
+ spec.description = 'Ruby object mapper and serializer for XML, JSON, TOML and YAML.'
13
13
  spec.homepage = 'https://shalerb.org'
14
14
  spec.license = 'MIT'
15
15
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Giszczak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Ruby object mapper and serializer for XML, JSON and YAML.
13
+ description: Ruby object mapper and serializer for XML, JSON, TOML and YAML.
14
14
  email:
15
15
  - beerkg@gmail.com
16
16
  executables:
@@ -33,6 +33,7 @@ files:
33
33
  - lib/shale/adapter/rexml.rb
34
34
  - lib/shale/adapter/rexml/document.rb
35
35
  - lib/shale/adapter/rexml/node.rb
36
+ - lib/shale/adapter/toml_rb.rb
36
37
  - lib/shale/attribute.rb
37
38
  - lib/shale/error.rb
38
39
  - lib/shale/mapper.rb
@@ -117,5 +118,5 @@ requirements: []
117
118
  rubygems_version: 3.3.7
118
119
  signing_key:
119
120
  specification_version: 4
120
- summary: Ruby object mapper and serializer for XML, JSON and YAML.
121
+ summary: Ruby object mapper and serializer for XML, JSON, TOML and YAML.
121
122
  test_files: []