shale 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +313 -62
- data/exe/shaleb +19 -4
- data/lib/shale/adapter/csv.rb +48 -0
- data/lib/shale/adapter/nokogiri/document.rb +7 -2
- data/lib/shale/adapter/nokogiri.rb +11 -4
- data/lib/shale/adapter/ox.rb +10 -4
- data/lib/shale/adapter/rexml.rb +18 -4
- data/lib/shale/error.rb +20 -8
- data/lib/shale/mapper.rb +41 -6
- data/lib/shale/mapping/delegates.rb +95 -0
- data/lib/shale/mapping/descriptor/dict.rb +10 -1
- data/lib/shale/mapping/descriptor/xml.rb +13 -2
- data/lib/shale/mapping/dict.rb +15 -5
- data/lib/shale/mapping/dict_base.rb +12 -6
- data/lib/shale/mapping/dict_group.rb +1 -1
- data/lib/shale/mapping/validator.rb +10 -3
- data/lib/shale/mapping/xml.rb +22 -6
- data/lib/shale/mapping/xml_base.rb +21 -12
- data/lib/shale/schema/compiler/complex.rb +52 -8
- data/lib/shale/schema/compiler/xml_complex.rb +5 -4
- data/lib/shale/schema/json_compiler.rb +27 -13
- data/lib/shale/schema/json_generator.rb +2 -2
- data/lib/shale/schema/xml_compiler.rb +46 -18
- data/lib/shale/schema/xml_generator.rb +3 -3
- data/lib/shale/schema.rb +10 -4
- data/lib/shale/type/complex.rb +291 -34
- data/lib/shale/type/date.rb +11 -0
- data/lib/shale/type/time.rb +11 -0
- data/lib/shale/type/value.rb +22 -0
- data/lib/shale/utils.rb +22 -4
- data/lib/shale/version.rb +1 -1
- data/lib/shale.rb +30 -4
- data/shale.gemspec +2 -2
- metadata +7 -5
data/lib/shale.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
require_relative 'shale/mapper'
|
6
|
+
require_relative 'shale/adapter/csv'
|
6
7
|
require_relative 'shale/adapter/json'
|
7
8
|
require_relative 'shale/type/boolean'
|
8
9
|
require_relative 'shale/type/date'
|
@@ -15,7 +16,7 @@ require_relative 'shale/version'
|
|
15
16
|
# Main library namespace
|
16
17
|
#
|
17
18
|
# Shale uses adapters for parsing and serializing documents.
|
18
|
-
# For handling JSON and
|
19
|
+
# For handling JSON, YAML, TOML and CSV, adapter must implement .load and .dump methods, so
|
19
20
|
# e.g for handling JSON, MultiJson works out of the box.
|
20
21
|
#
|
21
22
|
# Adapters for XML handling are more complicated and must conform to [@see shale/adapter/rexml]
|
@@ -29,9 +30,11 @@ require_relative 'shale/version'
|
|
29
30
|
# Shale.json_adapter = MultiJson
|
30
31
|
# Shale.json_adapter # => MultiJson
|
31
32
|
#
|
32
|
-
# @example setting
|
33
|
-
#
|
34
|
-
#
|
33
|
+
# @example setting TOML adapter for handling TOML documents
|
34
|
+
# require 'shale/adapter/toml_rb'
|
35
|
+
#
|
36
|
+
# Shale.toml_adapter = Shale::Adapter::TomlRB
|
37
|
+
# Shale.toml_adapter # => Shale::Adapter::TomlRB
|
35
38
|
#
|
36
39
|
# @example setting REXML adapter for handling XML documents
|
37
40
|
# Shale.xml_adapter = Shale::Adapter::REXML
|
@@ -86,6 +89,16 @@ module Shale
|
|
86
89
|
# @api public
|
87
90
|
attr_accessor :toml_adapter
|
88
91
|
|
92
|
+
# Set CSV adapter
|
93
|
+
#
|
94
|
+
# @param [.load, .dump] adapter
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# Shale.csv_adapter = Shale::Adapter::CSV
|
98
|
+
#
|
99
|
+
# @api public
|
100
|
+
attr_writer :csv_adapter
|
101
|
+
|
89
102
|
# XML adapter accessor. Available adapters are Shale::Adapter::REXML,
|
90
103
|
# Shale::Adapter::Nokogiri and Shale::Adapter::Ox
|
91
104
|
#
|
@@ -126,5 +139,18 @@ module Shale
|
|
126
139
|
def yaml_adapter
|
127
140
|
@yaml_adapter || YAML
|
128
141
|
end
|
142
|
+
|
143
|
+
# Return CSV adapter. By default CSV is used
|
144
|
+
#
|
145
|
+
# @return [.load, .dump]
|
146
|
+
#
|
147
|
+
# @example
|
148
|
+
# Shale.csv_adapter
|
149
|
+
# # => Shale::Adapter::CSV
|
150
|
+
#
|
151
|
+
# @api public
|
152
|
+
def csv_adapter
|
153
|
+
@csv_adapter || Adapter::CSV
|
154
|
+
end
|
129
155
|
end
|
130
156
|
end
|
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, TOML and YAML.'
|
12
|
-
spec.description = 'Ruby object mapper and serializer for XML, JSON, TOML and YAML.'
|
11
|
+
spec.summary = 'Ruby object mapper and serializer for XML, JSON, TOML, CSV and YAML.'
|
12
|
+
spec.description = 'Ruby object mapper and serializer for XML, JSON, TOML, CSV 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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Giszczak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby object mapper and serializer for XML, JSON, TOML and YAML.
|
13
|
+
description: Ruby object mapper and serializer for XML, JSON, TOML, CSV and YAML.
|
14
14
|
email:
|
15
15
|
- beerkg@gmail.com
|
16
16
|
executables:
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- README.md
|
24
24
|
- exe/shaleb
|
25
25
|
- lib/shale.rb
|
26
|
+
- lib/shale/adapter/csv.rb
|
26
27
|
- lib/shale/adapter/json.rb
|
27
28
|
- lib/shale/adapter/nokogiri.rb
|
28
29
|
- lib/shale/adapter/nokogiri/document.rb
|
@@ -37,6 +38,7 @@ files:
|
|
37
38
|
- lib/shale/attribute.rb
|
38
39
|
- lib/shale/error.rb
|
39
40
|
- lib/shale/mapper.rb
|
41
|
+
- lib/shale/mapping/delegates.rb
|
40
42
|
- lib/shale/mapping/descriptor/dict.rb
|
41
43
|
- lib/shale/mapping/descriptor/xml.rb
|
42
44
|
- lib/shale/mapping/descriptor/xml_namespace.rb
|
@@ -123,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
125
|
- !ruby/object:Gem::Version
|
124
126
|
version: '0'
|
125
127
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.4.10
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
|
-
summary: Ruby object mapper and serializer for XML, JSON, TOML and YAML.
|
131
|
+
summary: Ruby object mapper and serializer for XML, JSON, TOML, CSV and YAML.
|
130
132
|
test_files: []
|