shale 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +274 -7
  4. data/exe/shaleb +75 -0
  5. data/lib/shale/adapter/json.rb +7 -2
  6. data/lib/shale/adapter/nokogiri.rb +48 -12
  7. data/lib/shale/adapter/ox.rb +28 -4
  8. data/lib/shale/adapter/rexml.rb +56 -13
  9. data/lib/shale/attribute.rb +1 -1
  10. data/lib/shale/error.rb +6 -0
  11. data/lib/shale/mapper.rb +11 -11
  12. data/lib/shale/mapping/descriptor/dict.rb +57 -0
  13. data/lib/shale/mapping/descriptor/xml.rb +43 -0
  14. data/lib/shale/mapping/descriptor/xml_namespace.rb +37 -0
  15. data/lib/shale/mapping/{key_value.rb → dict.rb} +8 -6
  16. data/lib/shale/mapping/validator.rb +51 -0
  17. data/lib/shale/mapping/xml.rb +86 -15
  18. data/lib/shale/schema/json/base.rb +41 -0
  19. data/lib/shale/schema/json/boolean.rb +23 -0
  20. data/lib/shale/schema/json/collection.rb +39 -0
  21. data/lib/shale/schema/json/date.rb +23 -0
  22. data/lib/shale/schema/json/float.rb +23 -0
  23. data/lib/shale/schema/json/integer.rb +23 -0
  24. data/lib/shale/schema/json/object.rb +37 -0
  25. data/lib/shale/schema/json/ref.rb +28 -0
  26. data/lib/shale/schema/json/schema.rb +57 -0
  27. data/lib/shale/schema/json/string.rb +23 -0
  28. data/lib/shale/schema/json/time.rb +23 -0
  29. data/lib/shale/schema/json.rb +165 -0
  30. data/lib/shale/schema/xml/attribute.rb +41 -0
  31. data/lib/shale/schema/xml/complex_type.rb +67 -0
  32. data/lib/shale/schema/xml/element.rb +55 -0
  33. data/lib/shale/schema/xml/import.rb +46 -0
  34. data/lib/shale/schema/xml/ref_attribute.rb +37 -0
  35. data/lib/shale/schema/xml/ref_element.rb +39 -0
  36. data/lib/shale/schema/xml/schema.rb +121 -0
  37. data/lib/shale/schema/xml/typed_attribute.rb +46 -0
  38. data/lib/shale/schema/xml/typed_element.rb +46 -0
  39. data/lib/shale/schema/xml.rb +316 -0
  40. data/lib/shale/schema.rb +47 -0
  41. data/lib/shale/type/boolean.rb +2 -2
  42. data/lib/shale/type/composite.rb +67 -56
  43. data/lib/shale/type/date.rb +35 -2
  44. data/lib/shale/type/float.rb +2 -2
  45. data/lib/shale/type/integer.rb +2 -2
  46. data/lib/shale/type/string.rb +2 -2
  47. data/lib/shale/type/time.rb +35 -2
  48. data/lib/shale/type/{base.rb → value.rb} +18 -7
  49. data/lib/shale/utils.rb +18 -2
  50. data/lib/shale/version.rb +1 -1
  51. data/lib/shale.rb +10 -10
  52. data/shale.gemspec +6 -2
  53. metadata +41 -13
  54. data/lib/shale/mapping/base.rb +0 -32
metadata CHANGED
@@ -1,25 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Giszczak
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-06 00:00:00.000000000 Z
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby object mapper and serializer for XML, JSON and YAML.
14
14
  email:
15
15
  - beerkg@gmail.com
16
- executables: []
16
+ executables:
17
+ - shaleb
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - CHANGELOG.md
21
22
  - LICENSE.txt
22
23
  - README.md
24
+ - exe/shaleb
23
25
  - lib/shale.rb
24
26
  - lib/shale/adapter/json.rb
25
27
  - lib/shale/adapter/nokogiri.rb
@@ -28,10 +30,35 @@ files:
28
30
  - lib/shale/attribute.rb
29
31
  - lib/shale/error.rb
30
32
  - lib/shale/mapper.rb
31
- - lib/shale/mapping/base.rb
32
- - lib/shale/mapping/key_value.rb
33
+ - lib/shale/mapping/descriptor/dict.rb
34
+ - lib/shale/mapping/descriptor/xml.rb
35
+ - lib/shale/mapping/descriptor/xml_namespace.rb
36
+ - lib/shale/mapping/dict.rb
37
+ - lib/shale/mapping/validator.rb
33
38
  - lib/shale/mapping/xml.rb
34
- - lib/shale/type/base.rb
39
+ - lib/shale/schema.rb
40
+ - lib/shale/schema/json.rb
41
+ - lib/shale/schema/json/base.rb
42
+ - lib/shale/schema/json/boolean.rb
43
+ - lib/shale/schema/json/collection.rb
44
+ - lib/shale/schema/json/date.rb
45
+ - lib/shale/schema/json/float.rb
46
+ - lib/shale/schema/json/integer.rb
47
+ - lib/shale/schema/json/object.rb
48
+ - lib/shale/schema/json/ref.rb
49
+ - lib/shale/schema/json/schema.rb
50
+ - lib/shale/schema/json/string.rb
51
+ - lib/shale/schema/json/time.rb
52
+ - lib/shale/schema/xml.rb
53
+ - lib/shale/schema/xml/attribute.rb
54
+ - lib/shale/schema/xml/complex_type.rb
55
+ - lib/shale/schema/xml/element.rb
56
+ - lib/shale/schema/xml/import.rb
57
+ - lib/shale/schema/xml/ref_attribute.rb
58
+ - lib/shale/schema/xml/ref_element.rb
59
+ - lib/shale/schema/xml/schema.rb
60
+ - lib/shale/schema/xml/typed_attribute.rb
61
+ - lib/shale/schema/xml/typed_element.rb
35
62
  - lib/shale/type/boolean.rb
36
63
  - lib/shale/type/composite.rb
37
64
  - lib/shale/type/date.rb
@@ -39,19 +66,20 @@ files:
39
66
  - lib/shale/type/integer.rb
40
67
  - lib/shale/type/string.rb
41
68
  - lib/shale/type/time.rb
69
+ - lib/shale/type/value.rb
42
70
  - lib/shale/utils.rb
43
71
  - lib/shale/version.rb
44
72
  - shale.gemspec
45
- homepage: https://github.com/kgiszczak/shale
73
+ homepage: https://shalerb.org
46
74
  licenses:
47
75
  - MIT
48
76
  metadata:
49
77
  allowed_push_host: https://rubygems.org
50
- homepage_uri: https://github.com/kgiszczak/shale
78
+ homepage_uri: https://shalerb.org
51
79
  source_code_uri: https://github.com/kgiszczak/shale
52
80
  changelog_uri: https://github.com/kgiszczak/shale/blob/master/CHANGELOG.md
53
81
  bug_tracker_uri: https://github.com/kgiszczak/shale/issues
54
- post_install_message:
82
+ post_install_message:
55
83
  rdoc_options: []
56
84
  require_paths:
57
85
  - lib
@@ -66,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
94
  - !ruby/object:Gem::Version
67
95
  version: '0'
68
96
  requirements: []
69
- rubygems_version: 3.1.2
70
- signing_key:
97
+ rubygems_version: 3.1.6
98
+ signing_key:
71
99
  specification_version: 4
72
100
  summary: Ruby object mapper and serializer for XML, JSON and YAML.
73
101
  test_files: []
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../error'
4
-
5
- module Shale
6
- module Mapping
7
- class Base
8
- private
9
-
10
- # Validate correctness of argument passed to map functions
11
- #
12
- # @param [String] key
13
- # @param [Symbol] to
14
- # @param [Hash] using
15
- #
16
- # @raise [IncorrectMappingArgumentsError] when arguments are incorrect
17
- #
18
- # @api private
19
- def validate_arguments(key, to, using)
20
- if to.nil? && using.nil?
21
- msg = ":to or :using argument is required for mapping '#{key}'"
22
- raise IncorrectMappingArgumentsError, msg
23
- end
24
-
25
- if !using.nil? && (using[:from].nil? || using[:to].nil?)
26
- msg = ":using argument for mapping '#{key}' requires :to and :from keys"
27
- raise IncorrectMappingArgumentsError, msg
28
- end
29
- end
30
- end
31
- end
32
- end