shale 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +366 -8
  4. data/exe/shaleb +123 -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 +7 -1
  10. data/lib/shale/error.rb +12 -0
  11. data/lib/shale/mapper.rb +17 -15
  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_compiler/boolean.rb +21 -0
  19. data/lib/shale/schema/json_compiler/date.rb +21 -0
  20. data/lib/shale/schema/json_compiler/float.rb +21 -0
  21. data/lib/shale/schema/json_compiler/integer.rb +21 -0
  22. data/lib/shale/schema/json_compiler/object.rb +85 -0
  23. data/lib/shale/schema/json_compiler/property.rb +70 -0
  24. data/lib/shale/schema/json_compiler/string.rb +21 -0
  25. data/lib/shale/schema/json_compiler/time.rb +21 -0
  26. data/lib/shale/schema/json_compiler/utils.rb +52 -0
  27. data/lib/shale/schema/json_compiler/value.rb +13 -0
  28. data/lib/shale/schema/json_compiler.rb +333 -0
  29. data/lib/shale/schema/json_generator/base.rb +41 -0
  30. data/lib/shale/schema/json_generator/boolean.rb +23 -0
  31. data/lib/shale/schema/json_generator/collection.rb +39 -0
  32. data/lib/shale/schema/json_generator/date.rb +23 -0
  33. data/lib/shale/schema/json_generator/float.rb +23 -0
  34. data/lib/shale/schema/json_generator/integer.rb +23 -0
  35. data/lib/shale/schema/json_generator/object.rb +40 -0
  36. data/lib/shale/schema/json_generator/ref.rb +28 -0
  37. data/lib/shale/schema/json_generator/schema.rb +59 -0
  38. data/lib/shale/schema/json_generator/string.rb +23 -0
  39. data/lib/shale/schema/json_generator/time.rb +23 -0
  40. data/lib/shale/schema/json_generator/value.rb +23 -0
  41. data/lib/shale/schema/json_generator.rb +165 -0
  42. data/lib/shale/schema/xml_generator/attribute.rb +41 -0
  43. data/lib/shale/schema/xml_generator/complex_type.rb +70 -0
  44. data/lib/shale/schema/xml_generator/element.rb +55 -0
  45. data/lib/shale/schema/xml_generator/import.rb +46 -0
  46. data/lib/shale/schema/xml_generator/ref_attribute.rb +37 -0
  47. data/lib/shale/schema/xml_generator/ref_element.rb +39 -0
  48. data/lib/shale/schema/xml_generator/schema.rb +121 -0
  49. data/lib/shale/schema/xml_generator/typed_attribute.rb +46 -0
  50. data/lib/shale/schema/xml_generator/typed_element.rb +46 -0
  51. data/lib/shale/schema/xml_generator.rb +315 -0
  52. data/lib/shale/schema.rb +70 -0
  53. data/lib/shale/type/boolean.rb +2 -2
  54. data/lib/shale/type/composite.rb +78 -72
  55. data/lib/shale/type/date.rb +35 -2
  56. data/lib/shale/type/float.rb +2 -2
  57. data/lib/shale/type/integer.rb +2 -2
  58. data/lib/shale/type/string.rb +2 -2
  59. data/lib/shale/type/time.rb +35 -2
  60. data/lib/shale/type/{base.rb → value.rb} +18 -7
  61. data/lib/shale/utils.rb +18 -2
  62. data/lib/shale/version.rb +1 -1
  63. data/lib/shale.rb +10 -10
  64. data/shale.gemspec +6 -2
  65. metadata +53 -13
  66. 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.2
4
+ version: 0.4.0
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-03-06 00:00:00.000000000 Z
11
+ date: 2022-05-30 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,47 @@ 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_compiler.rb
41
+ - lib/shale/schema/json_compiler/boolean.rb
42
+ - lib/shale/schema/json_compiler/date.rb
43
+ - lib/shale/schema/json_compiler/float.rb
44
+ - lib/shale/schema/json_compiler/integer.rb
45
+ - lib/shale/schema/json_compiler/object.rb
46
+ - lib/shale/schema/json_compiler/property.rb
47
+ - lib/shale/schema/json_compiler/string.rb
48
+ - lib/shale/schema/json_compiler/time.rb
49
+ - lib/shale/schema/json_compiler/utils.rb
50
+ - lib/shale/schema/json_compiler/value.rb
51
+ - lib/shale/schema/json_generator.rb
52
+ - lib/shale/schema/json_generator/base.rb
53
+ - lib/shale/schema/json_generator/boolean.rb
54
+ - lib/shale/schema/json_generator/collection.rb
55
+ - lib/shale/schema/json_generator/date.rb
56
+ - lib/shale/schema/json_generator/float.rb
57
+ - lib/shale/schema/json_generator/integer.rb
58
+ - lib/shale/schema/json_generator/object.rb
59
+ - lib/shale/schema/json_generator/ref.rb
60
+ - lib/shale/schema/json_generator/schema.rb
61
+ - lib/shale/schema/json_generator/string.rb
62
+ - lib/shale/schema/json_generator/time.rb
63
+ - lib/shale/schema/json_generator/value.rb
64
+ - lib/shale/schema/xml_generator.rb
65
+ - lib/shale/schema/xml_generator/attribute.rb
66
+ - lib/shale/schema/xml_generator/complex_type.rb
67
+ - lib/shale/schema/xml_generator/element.rb
68
+ - lib/shale/schema/xml_generator/import.rb
69
+ - lib/shale/schema/xml_generator/ref_attribute.rb
70
+ - lib/shale/schema/xml_generator/ref_element.rb
71
+ - lib/shale/schema/xml_generator/schema.rb
72
+ - lib/shale/schema/xml_generator/typed_attribute.rb
73
+ - lib/shale/schema/xml_generator/typed_element.rb
35
74
  - lib/shale/type/boolean.rb
36
75
  - lib/shale/type/composite.rb
37
76
  - lib/shale/type/date.rb
@@ -39,19 +78,20 @@ files:
39
78
  - lib/shale/type/integer.rb
40
79
  - lib/shale/type/string.rb
41
80
  - lib/shale/type/time.rb
81
+ - lib/shale/type/value.rb
42
82
  - lib/shale/utils.rb
43
83
  - lib/shale/version.rb
44
84
  - shale.gemspec
45
- homepage: https://github.com/kgiszczak/shale
85
+ homepage: https://shalerb.org
46
86
  licenses:
47
87
  - MIT
48
88
  metadata:
49
89
  allowed_push_host: https://rubygems.org
50
- homepage_uri: https://github.com/kgiszczak/shale
90
+ homepage_uri: https://shalerb.org
51
91
  source_code_uri: https://github.com/kgiszczak/shale
52
92
  changelog_uri: https://github.com/kgiszczak/shale/blob/master/CHANGELOG.md
53
93
  bug_tracker_uri: https://github.com/kgiszczak/shale/issues
54
- post_install_message:
94
+ post_install_message:
55
95
  rdoc_options: []
56
96
  require_paths:
57
97
  - lib
@@ -66,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
106
  - !ruby/object:Gem::Version
67
107
  version: '0'
68
108
  requirements: []
69
- rubygems_version: 3.1.2
70
- signing_key:
109
+ rubygems_version: 3.1.6
110
+ signing_key:
71
111
  specification_version: 4
72
112
  summary: Ruby object mapper and serializer for XML, JSON and YAML.
73
113
  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