shale 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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 YAML, adapter must implement .load and .dump methods, so
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 YAML adapter for handling YAML documents
33
- # Shale.yaml_adapter = MultiJson
34
- # Shale.yaml_adapter # => MultiJson
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.8.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: 2022-08-30 00:00:00.000000000 Z
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.3.7
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: []