representable 3.2.0 → 3.3.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +17 -10
- data/.github/workflows/ci_jruby.yml +21 -0
- data/.github/workflows/ci_truffleruby.yml +19 -0
- data/CHANGES.md +5 -0
- data/Gemfile +1 -1
- data/README.md +0 -1
- data/lib/representable/hash/binding.rb +1 -0
- data/lib/representable/json.rb +14 -2
- data/lib/representable/version.rb +1 -1
- data/lib/representable/xml/binding.rb +0 -7
- data/lib/representable/xml.rb +7 -0
- data/representable.gemspec +1 -3
- data/test/as_test.rb +8 -13
- data/test/benchmarking.rb +20 -25
- data/test/binding_test.rb +13 -5
- data/test/cached_test.rb +55 -35
- data/test/class_test.rb +46 -33
- data/test/coercion_test.rb +29 -19
- data/test/config/inherit_test.rb +12 -17
- data/test/config_test.rb +5 -7
- data/test/decorator_scope_test.rb +13 -11
- data/test/decorator_test.rb +11 -11
- data/test/default_test.rb +2 -2
- data/test/defaults_options_test.rb +37 -9
- data/test/definition_test.rb +10 -12
- data/test/examples/example.rb +43 -38
- data/test/examples/object.rb +7 -6
- data/test/exec_context_test.rb +18 -23
- data/test/features_test.rb +29 -10
- data/test/filter_test.rb +29 -20
- data/test/for_collection_test.rb +12 -15
- data/test/generic_test.rb +15 -22
- data/test/getter_setter_test.rb +11 -6
- data/test/hash_bindings_test.rb +21 -12
- data/test/hash_test.rb +53 -38
- data/test/heritage_test.rb +0 -1
- data/test/if_test.rb +25 -21
- data/test/include_exclude_test.rb +24 -16
- data/test/inherit_test.rb +114 -27
- data/test/inline_test.rb +42 -33
- data/test/instance_test.rb +151 -109
- data/test/is_representable_test.rb +19 -17
- data/test/json_test.rb +48 -46
- data/test/lonely_test.rb +35 -33
- data/test/nested_test.rb +16 -19
- data/test/object_test.rb +6 -6
- data/test/option_test.rb +10 -8
- data/test/parse_pipeline_test.rb +21 -15
- data/test/pipeline_test.rb +144 -108
- data/test/populator_test.rb +18 -15
- data/test/prepare_test.rb +15 -17
- data/test/private_options_test.rb +3 -2
- data/test/reader_writer_test.rb +4 -4
- data/test/realistic_benchmark.rb +21 -27
- data/test/render_nil_test.rb +1 -1
- data/test/represent_test.rb +14 -18
- data/test/representable_test.rb +86 -53
- data/test/schema_test.rb +51 -21
- data/test/serialize_deserialize_test.rb +14 -14
- data/test/skip_test.rb +39 -28
- data/test/stringify_hash_test.rb +29 -31
- data/test/test_helper.rb +31 -25
- data/test/test_helper_test.rb +7 -7
- data/test/uncategorized_test.rb +20 -15
- data/test/user_options_test.rb +12 -3
- data/test/wrap_test.rb +27 -17
- data/test/xml_assertions.rb +29 -0
- data/test/xml_bindings_test.rb +5 -8
- data/test/xml_namespace_test.rb +46 -39
- data/test/xml_test.rb +109 -88
- data/test/yaml_test.rb +73 -51
- metadata +7 -32
data/test/yaml_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class YamlPublicMethodsTest < Minitest::Spec
|
|
4
4
|
#---
|
|
@@ -9,10 +9,12 @@ class YamlPublicMethodsTest < Minitest::Spec
|
|
|
9
9
|
property :name
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
let(:data)
|
|
12
|
+
let(:data) do
|
|
13
|
+
%{---
|
|
13
14
|
id: 1
|
|
14
15
|
name: Rancid
|
|
15
|
-
}
|
|
16
|
+
}
|
|
17
|
+
end
|
|
16
18
|
|
|
17
19
|
it { _(BandRepresenter.new(Band.new).from_yaml(data)[:id, :name]).must_equal [1, "Rancid"] }
|
|
18
20
|
it { _(BandRepresenter.new(Band.new).parse(data)[:id, :name]).must_equal [1, "Rancid"] }
|
|
@@ -25,7 +27,7 @@ name: Rancid
|
|
|
25
27
|
it { _(BandRepresenter.new(band).render).must_equal data }
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
class YamlTest <
|
|
30
|
+
class YamlTest < Minitest::Spec
|
|
29
31
|
def self.yaml_representer(&block)
|
|
30
32
|
Module.new do
|
|
31
33
|
include Representable::YAML
|
|
@@ -37,53 +39,59 @@ class YamlTest < MiniTest::Spec
|
|
|
37
39
|
self.class.yaml_representer(&block)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
|
|
41
42
|
describe "property" do
|
|
42
|
-
let(:yaml) { yaml_representer
|
|
43
|
+
let(:yaml) { yaml_representer { property :best_song } }
|
|
43
44
|
|
|
44
|
-
let(:album)
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
let(:album) do
|
|
46
|
+
Album.new.tap do |album|
|
|
47
|
+
album.best_song = "Liar"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
47
50
|
|
|
48
51
|
describe "#to_yaml" do
|
|
49
52
|
it "renders plain property" do
|
|
50
53
|
_(album.extend(yaml).to_yaml).must_equal(
|
|
51
|
-
"---
|
|
54
|
+
"---
|
|
52
55
|
best_song: Liar
|
|
53
|
-
"
|
|
56
|
+
"
|
|
57
|
+
)
|
|
54
58
|
end
|
|
55
59
|
|
|
56
60
|
it "always renders values into strings" do
|
|
57
61
|
_(Album.new.tap { |a| a.best_song = 8675309 }.extend(yaml).to_yaml).must_equal(
|
|
58
|
-
"---
|
|
62
|
+
"---
|
|
59
63
|
best_song: 8675309
|
|
60
64
|
"
|
|
61
|
-
)
|
|
65
|
+
)
|
|
62
66
|
end
|
|
63
67
|
end
|
|
64
68
|
|
|
65
|
-
|
|
66
69
|
describe "#from_yaml" do
|
|
67
70
|
it "parses plain property" do
|
|
68
|
-
_(
|
|
69
|
-
|
|
71
|
+
_(
|
|
72
|
+
album.extend(yaml).from_yaml(
|
|
73
|
+
"---
|
|
70
74
|
best_song: This Song Is Recycled
|
|
71
|
-
"
|
|
75
|
+
"
|
|
76
|
+
).best_song
|
|
77
|
+
).must_equal "This Song Is Recycled"
|
|
72
78
|
end
|
|
73
79
|
end
|
|
74
80
|
|
|
75
|
-
|
|
76
81
|
describe "with :class and :extend" do
|
|
77
|
-
yaml_song = yaml_representer
|
|
78
|
-
let(:yaml_album)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
album.best_song = Song.new("Liar")
|
|
85
|
-
end }
|
|
82
|
+
yaml_song = yaml_representer { property :name }
|
|
83
|
+
let(:yaml_album) do
|
|
84
|
+
Module.new do
|
|
85
|
+
include Representable::YAML
|
|
86
|
+
property :best_song, :extend => yaml_song, :class => Song
|
|
87
|
+
end
|
|
88
|
+
end
|
|
86
89
|
|
|
90
|
+
let(:album) do
|
|
91
|
+
Album.new.tap do |album|
|
|
92
|
+
album.best_song = Song.new("Liar")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
87
95
|
|
|
88
96
|
describe "#to_yaml" do
|
|
89
97
|
it "renders embedded typed property" do
|
|
@@ -96,23 +104,27 @@ best_song:
|
|
|
96
104
|
|
|
97
105
|
describe "#from_yaml" do
|
|
98
106
|
it "parses embedded typed property" do
|
|
99
|
-
_(
|
|
107
|
+
_(
|
|
108
|
+
album.extend(yaml_album).from_yaml(
|
|
109
|
+
"---
|
|
100
110
|
best_song:
|
|
101
111
|
name: Go With Me
|
|
102
|
-
"
|
|
112
|
+
"
|
|
113
|
+
)
|
|
114
|
+
).must_equal Album.new(nil, Song.new("Go With Me"))
|
|
103
115
|
end
|
|
104
116
|
end
|
|
105
117
|
end
|
|
106
118
|
end
|
|
107
119
|
|
|
108
|
-
|
|
109
120
|
describe "collection" do
|
|
110
|
-
let(:yaml) { yaml_representer
|
|
111
|
-
|
|
112
|
-
let(:album) { Album.new.tap do |album|
|
|
113
|
-
album.songs = ["Jackhammer", "Terrible Man"]
|
|
114
|
-
end }
|
|
121
|
+
let(:yaml) { yaml_representer { collection :songs } }
|
|
115
122
|
|
|
123
|
+
let(:album) do
|
|
124
|
+
Album.new.tap do |album|
|
|
125
|
+
album.songs = ["Jackhammer", "Terrible Man"]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
116
128
|
|
|
117
129
|
describe "#to_yaml" do
|
|
118
130
|
it "renders a block style list per default" do
|
|
@@ -131,35 +143,41 @@ songs: [Jackhammer, Terrible Man]
|
|
|
131
143
|
end
|
|
132
144
|
end
|
|
133
145
|
|
|
134
|
-
|
|
135
146
|
describe "#from_yaml" do
|
|
136
147
|
it "parses a block style list" do
|
|
137
|
-
_(
|
|
148
|
+
_(
|
|
149
|
+
album.extend(yaml).from_yaml(
|
|
150
|
+
"---
|
|
138
151
|
songs:
|
|
139
152
|
- Off Key Melody
|
|
140
|
-
- Sinking"
|
|
141
|
-
|
|
153
|
+
- Sinking"
|
|
154
|
+
)
|
|
155
|
+
).must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
142
156
|
end
|
|
143
157
|
|
|
144
158
|
it "parses a flow style list" do
|
|
145
|
-
_(
|
|
146
|
-
|
|
159
|
+
_(
|
|
160
|
+
album.extend(yaml).from_yaml(
|
|
161
|
+
"---
|
|
162
|
+
songs: [Off Key Melody, Sinking]"
|
|
163
|
+
)
|
|
164
|
+
).must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
147
165
|
end
|
|
148
166
|
end
|
|
149
167
|
|
|
150
|
-
|
|
151
168
|
describe "with :class and :extend" do
|
|
152
|
-
let(:yaml_album)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
let(:yaml_album) do
|
|
170
|
+
Module.new do
|
|
171
|
+
include Representable::YAML
|
|
172
|
+
collection :songs, :class => Song do
|
|
173
|
+
property :name
|
|
174
|
+
property :track
|
|
175
|
+
end
|
|
157
176
|
end
|
|
158
|
-
end
|
|
177
|
+
end
|
|
159
178
|
|
|
160
179
|
let(:album) { Album.new([Song.new("Liar", 1), Song.new("What I Know", 2)]) }
|
|
161
180
|
|
|
162
|
-
|
|
163
181
|
describe "#to_yaml" do
|
|
164
182
|
it "renders collection of typed property" do
|
|
165
183
|
_(album.extend(yaml_album).to_yaml).must_equal "---
|
|
@@ -174,12 +192,16 @@ songs:
|
|
|
174
192
|
|
|
175
193
|
describe "#from_yaml" do
|
|
176
194
|
it "parses collection of typed property" do
|
|
177
|
-
_(
|
|
195
|
+
_(
|
|
196
|
+
album.extend(yaml_album).from_yaml(
|
|
197
|
+
"---
|
|
178
198
|
songs:
|
|
179
199
|
- name: One Shot Deal
|
|
180
200
|
track: 4
|
|
181
201
|
- name: Three Way Dance
|
|
182
|
-
track: 5"
|
|
202
|
+
track: 5"
|
|
203
|
+
)
|
|
204
|
+
).must_equal Album.new([Song.new("One Shot Deal", 4), Song.new("Three Way Dance", 5)])
|
|
183
205
|
end
|
|
184
206
|
end
|
|
185
207
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: representable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-09-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: uber
|
|
@@ -72,20 +72,6 @@ dependencies:
|
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: '0'
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: test_xml
|
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - ">="
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.1.6
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - ">="
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.1.6
|
|
89
75
|
- !ruby/object:Gem::Dependency
|
|
90
76
|
name: minitest
|
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,20 +86,6 @@ dependencies:
|
|
|
100
86
|
- - ">="
|
|
101
87
|
- !ruby/object:Gem::Version
|
|
102
88
|
version: '0'
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: virtus
|
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - ">="
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0'
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - ">="
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0'
|
|
117
89
|
- !ruby/object:Gem::Dependency
|
|
118
90
|
name: dry-types
|
|
119
91
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,6 +123,8 @@ extensions: []
|
|
|
151
123
|
extra_rdoc_files: []
|
|
152
124
|
files:
|
|
153
125
|
- ".github/workflows/ci.yml"
|
|
126
|
+
- ".github/workflows/ci_jruby.yml"
|
|
127
|
+
- ".github/workflows/ci_truffleruby.yml"
|
|
154
128
|
- ".gitignore"
|
|
155
129
|
- CHANGES.md
|
|
156
130
|
- Gemfile
|
|
@@ -250,6 +224,7 @@ files:
|
|
|
250
224
|
- test/uncategorized_test.rb
|
|
251
225
|
- test/user_options_test.rb
|
|
252
226
|
- test/wrap_test.rb
|
|
227
|
+
- test/xml_assertions.rb
|
|
253
228
|
- test/xml_bindings_test.rb
|
|
254
229
|
- test/xml_namespace_test.rb
|
|
255
230
|
- test/xml_test.rb
|
|
@@ -266,14 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
266
241
|
requirements:
|
|
267
242
|
- - ">="
|
|
268
243
|
- !ruby/object:Gem::Version
|
|
269
|
-
version:
|
|
244
|
+
version: 3.0.0
|
|
270
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
246
|
requirements:
|
|
272
247
|
- - ">="
|
|
273
248
|
- !ruby/object:Gem::Version
|
|
274
249
|
version: '0'
|
|
275
250
|
requirements: []
|
|
276
|
-
rubygems_version: 3.
|
|
251
|
+
rubygems_version: 3.2.3
|
|
277
252
|
signing_key:
|
|
278
253
|
specification_version: 4
|
|
279
254
|
summary: Renders and parses JSON/XML/YAML documents from and to Ruby objects. Includes
|