representable 3.0.4 → 3.2.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 +5 -5
- data/.github/workflows/ci.yml +23 -0
- data/CHANGES.md +14 -0
- data/Gemfile +4 -7
- data/LICENSE +1 -1
- data/README.md +12 -12
- data/Rakefile +1 -6
- data/lib/representable/binding.rb +32 -12
- data/lib/representable/cached.rb +1 -1
- data/lib/representable/coercion.rb +8 -6
- data/lib/representable/config.rb +8 -3
- data/lib/representable/debug.rb +23 -15
- data/lib/representable/declarative.rb +8 -3
- data/lib/representable/decorator.rb +1 -1
- data/lib/representable/definition.rb +7 -2
- data/lib/representable/deserializer.rb +4 -3
- data/lib/representable/for_collection.rb +1 -1
- data/lib/representable/hash/allow_symbols.rb +9 -11
- data/lib/representable/hash/binding.rb +1 -0
- data/lib/representable/hash/collection.rb +4 -2
- data/lib/representable/hash.rb +6 -2
- data/lib/representable/hash_methods.rb +3 -2
- data/lib/representable/insert.rb +1 -1
- data/lib/representable/json/collection.rb +3 -0
- data/lib/representable/json/hash.rb +1 -0
- data/lib/representable/json.rb +5 -7
- data/lib/representable/object/binding.rb +5 -1
- data/lib/representable/object.rb +1 -1
- data/lib/representable/option.rb +19 -0
- data/lib/representable/pipeline.rb +3 -2
- data/lib/representable/pipeline_factories.rb +4 -2
- data/lib/representable/populator.rb +1 -1
- data/lib/representable/represent.rb +1 -0
- data/lib/representable/serializer.rb +2 -1
- data/lib/representable/version.rb +1 -1
- data/lib/representable/xml/binding.rb +5 -6
- data/lib/representable/xml.rb +7 -10
- data/lib/representable/yaml/binding.rb +1 -0
- data/lib/representable/yaml.rb +3 -3
- data/lib/representable.rb +18 -25
- data/representable.gemspec +3 -3
- data/test/as_test.rb +4 -4
- data/test/binding_test.rb +10 -10
- data/test/cached_test.rb +19 -19
- data/test/class_test.rb +7 -7
- data/test/coercion_test.rb +33 -22
- data/test/config/inherit_test.rb +14 -14
- data/test/config_test.rb +18 -18
- data/test/decorator_scope_test.rb +3 -3
- data/test/decorator_test.rb +17 -17
- data/test/default_test.rb +7 -7
- data/test/definition_test.rb +32 -32
- data/test/{example.rb → examples/example.rb} +0 -0
- data/test/exec_context_test.rb +6 -6
- data/test/features_test.rb +3 -3
- data/test/filter_test.rb +6 -6
- data/test/for_collection_test.rb +2 -2
- data/test/generic_test.rb +3 -3
- data/test/getter_setter_test.rb +5 -5
- data/test/hash_test.rb +19 -19
- data/test/heritage_test.rb +4 -4
- data/test/if_test.rb +6 -6
- data/test/include_exclude_test.rb +12 -12
- data/test/inherit_test.rb +15 -15
- data/test/inline_test.rb +11 -11
- data/test/instance_test.rb +29 -29
- data/test/is_representable_test.rb +10 -10
- data/test/json_test.rb +7 -7
- data/test/lonely_test.rb +16 -16
- data/test/nested_test.rb +7 -7
- data/test/object_test.rb +7 -7
- data/test/option_test.rb +36 -0
- data/test/parse_pipeline_test.rb +3 -3
- data/test/pipeline_test.rb +43 -43
- data/test/populator_test.rb +15 -15
- data/test/prepare_test.rb +2 -2
- data/test/private_options_test.rb +2 -2
- data/test/reader_writer_test.rb +2 -2
- data/test/render_nil_test.rb +2 -2
- data/test/represent_test.rb +4 -4
- data/test/representable_test.rb +27 -27
- data/test/schema_test.rb +5 -5
- data/test/serialize_deserialize_test.rb +2 -2
- data/test/skip_test.rb +10 -10
- data/test/stringify_hash_test.rb +3 -3
- data/test/test_helper.rb +4 -2
- data/test/uncategorized_test.rb +10 -10
- data/test/user_options_test.rb +4 -4
- data/test/wrap_test.rb +11 -11
- data/test/xml_namespace_test.rb +1 -1
- data/test/xml_test.rb +6 -6
- data/test/yaml_test.rb +20 -20
- metadata +16 -11
- data/.travis.yml +0 -16
- data/lib/representable/autoload.rb +0 -14
- data/test/mongoid_test.rb +0 -31
data/test/yaml_test.rb
CHANGED
|
@@ -14,15 +14,15 @@ id: 1
|
|
|
14
14
|
name: Rancid
|
|
15
15
|
} }
|
|
16
16
|
|
|
17
|
-
it { BandRepresenter.new(Band.new).from_yaml(data)[:id, :name].must_equal [1, "Rancid"] }
|
|
18
|
-
it { BandRepresenter.new(Band.new).parse(data)[:id, :name].must_equal [1, "Rancid"] }
|
|
17
|
+
it { _(BandRepresenter.new(Band.new).from_yaml(data)[:id, :name]).must_equal [1, "Rancid"] }
|
|
18
|
+
it { _(BandRepresenter.new(Band.new).parse(data)[:id, :name]).must_equal [1, "Rancid"] }
|
|
19
19
|
|
|
20
20
|
#---
|
|
21
21
|
# to_yaml
|
|
22
22
|
let(:band) { Band.new("1", "Rancid") }
|
|
23
23
|
|
|
24
|
-
it { BandRepresenter.new(band).to_yaml.must_equal data }
|
|
25
|
-
it { BandRepresenter.new(band).render.must_equal data }
|
|
24
|
+
it { _(BandRepresenter.new(band).to_yaml).must_equal data }
|
|
25
|
+
it { _(BandRepresenter.new(band).render).must_equal data }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
class YamlTest < MiniTest::Spec
|
|
@@ -47,14 +47,14 @@ class YamlTest < MiniTest::Spec
|
|
|
47
47
|
|
|
48
48
|
describe "#to_yaml" do
|
|
49
49
|
it "renders plain property" do
|
|
50
|
-
album.extend(yaml).to_yaml.must_equal(
|
|
50
|
+
_(album.extend(yaml).to_yaml).must_equal(
|
|
51
51
|
"---
|
|
52
52
|
best_song: Liar
|
|
53
53
|
")
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "always renders values into strings" do
|
|
57
|
-
Album.new.tap { |a| a.best_song = 8675309 }.extend(yaml).to_yaml.must_equal(
|
|
57
|
+
_(Album.new.tap { |a| a.best_song = 8675309 }.extend(yaml).to_yaml).must_equal(
|
|
58
58
|
"---
|
|
59
59
|
best_song: 8675309
|
|
60
60
|
"
|
|
@@ -65,10 +65,10 @@ best_song: 8675309
|
|
|
65
65
|
|
|
66
66
|
describe "#from_yaml" do
|
|
67
67
|
it "parses plain property" do
|
|
68
|
-
album.extend(yaml).from_yaml(
|
|
68
|
+
_(album.extend(yaml).from_yaml(
|
|
69
69
|
"---
|
|
70
70
|
best_song: This Song Is Recycled
|
|
71
|
-
").best_song.must_equal "This Song Is Recycled"
|
|
71
|
+
").best_song).must_equal "This Song Is Recycled"
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
@@ -87,7 +87,7 @@ best_song: This Song Is Recycled
|
|
|
87
87
|
|
|
88
88
|
describe "#to_yaml" do
|
|
89
89
|
it "renders embedded typed property" do
|
|
90
|
-
album.extend(yaml_album).to_yaml.must_equal "---
|
|
90
|
+
_(album.extend(yaml_album).to_yaml).must_equal "---
|
|
91
91
|
best_song:
|
|
92
92
|
name: Liar
|
|
93
93
|
"
|
|
@@ -96,10 +96,10 @@ best_song:
|
|
|
96
96
|
|
|
97
97
|
describe "#from_yaml" do
|
|
98
98
|
it "parses embedded typed property" do
|
|
99
|
-
album.extend(yaml_album).from_yaml("---
|
|
99
|
+
_(album.extend(yaml_album).from_yaml("---
|
|
100
100
|
best_song:
|
|
101
101
|
name: Go With Me
|
|
102
|
-
").must_equal Album.new(nil,Song.new("Go With Me"))
|
|
102
|
+
")).must_equal Album.new(nil,Song.new("Go With Me"))
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
end
|
|
@@ -116,7 +116,7 @@ best_song:
|
|
|
116
116
|
|
|
117
117
|
describe "#to_yaml" do
|
|
118
118
|
it "renders a block style list per default" do
|
|
119
|
-
album.extend(yaml).to_yaml.must_equal "---
|
|
119
|
+
_(album.extend(yaml).to_yaml).must_equal "---
|
|
120
120
|
songs:
|
|
121
121
|
- Jackhammer
|
|
122
122
|
- Terrible Man
|
|
@@ -125,7 +125,7 @@ songs:
|
|
|
125
125
|
|
|
126
126
|
it "renders a flow style list when :style => :flow set" do
|
|
127
127
|
yaml = yaml_representer { collection :songs, :style => :flow }
|
|
128
|
-
album.extend(yaml).to_yaml.must_equal "---
|
|
128
|
+
_(album.extend(yaml).to_yaml).must_equal "---
|
|
129
129
|
songs: [Jackhammer, Terrible Man]
|
|
130
130
|
"
|
|
131
131
|
end
|
|
@@ -134,16 +134,16 @@ songs: [Jackhammer, Terrible Man]
|
|
|
134
134
|
|
|
135
135
|
describe "#from_yaml" do
|
|
136
136
|
it "parses a block style list" do
|
|
137
|
-
album.extend(yaml).from_yaml("---
|
|
137
|
+
_(album.extend(yaml).from_yaml("---
|
|
138
138
|
songs:
|
|
139
139
|
- Off Key Melody
|
|
140
|
-
- Sinking").must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
140
|
+
- Sinking")).must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
141
141
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it "parses a flow style list" do
|
|
145
|
-
album.extend(yaml).from_yaml("---
|
|
146
|
-
songs: [Off Key Melody, Sinking]").must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
145
|
+
_(album.extend(yaml).from_yaml("---
|
|
146
|
+
songs: [Off Key Melody, Sinking]")).must_equal Album.new(["Off Key Melody", "Sinking"])
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -162,7 +162,7 @@ songs: [Off Key Melody, Sinking]").must_equal Album.new(["Off Key Melody", "Sink
|
|
|
162
162
|
|
|
163
163
|
describe "#to_yaml" do
|
|
164
164
|
it "renders collection of typed property" do
|
|
165
|
-
album.extend(yaml_album).to_yaml.must_equal "---
|
|
165
|
+
_(album.extend(yaml_album).to_yaml).must_equal "---
|
|
166
166
|
songs:
|
|
167
167
|
- name: Liar
|
|
168
168
|
track: 1
|
|
@@ -174,12 +174,12 @@ songs:
|
|
|
174
174
|
|
|
175
175
|
describe "#from_yaml" do
|
|
176
176
|
it "parses collection of typed property" do
|
|
177
|
-
album.extend(yaml_album).from_yaml("---
|
|
177
|
+
_(album.extend(yaml_album).from_yaml("---
|
|
178
178
|
songs:
|
|
179
179
|
- name: One Shot Deal
|
|
180
180
|
track: 4
|
|
181
181
|
- name: Three Way Dance
|
|
182
|
-
track: 5").must_equal Album.new([Song.new("One Shot Deal", 4), Song.new("Three Way Dance", 5)])
|
|
182
|
+
track: 5")).must_equal Album.new([Song.new("One Shot Deal", 4), Song.new("Three Way Dance", 5)])
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
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.0
|
|
4
|
+
version: 3.2.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: 2022-05-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: uber
|
|
@@ -39,9 +39,12 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.1.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: trailblazer-option
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.1.1
|
|
45
48
|
- - "<"
|
|
46
49
|
- !ruby/object:Gem::Version
|
|
47
50
|
version: 0.2.0
|
|
@@ -49,6 +52,9 @@ dependencies:
|
|
|
49
52
|
prerelease: false
|
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
54
|
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: 0.1.1
|
|
52
58
|
- - "<"
|
|
53
59
|
- !ruby/object:Gem::Version
|
|
54
60
|
version: 0.2.0
|
|
@@ -109,7 +115,7 @@ dependencies:
|
|
|
109
115
|
- !ruby/object:Gem::Version
|
|
110
116
|
version: '0'
|
|
111
117
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
118
|
+
name: dry-types
|
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
|
114
120
|
requirements:
|
|
115
121
|
- - ">="
|
|
@@ -144,8 +150,8 @@ executables: []
|
|
|
144
150
|
extensions: []
|
|
145
151
|
extra_rdoc_files: []
|
|
146
152
|
files:
|
|
153
|
+
- ".github/workflows/ci.yml"
|
|
147
154
|
- ".gitignore"
|
|
148
|
-
- ".travis.yml"
|
|
149
155
|
- CHANGES.md
|
|
150
156
|
- Gemfile
|
|
151
157
|
- LICENSE
|
|
@@ -154,7 +160,6 @@ files:
|
|
|
154
160
|
- TODO
|
|
155
161
|
- TODO-4.0.md
|
|
156
162
|
- lib/representable.rb
|
|
157
|
-
- lib/representable/autoload.rb
|
|
158
163
|
- lib/representable/binding.rb
|
|
159
164
|
- lib/representable/cached.rb
|
|
160
165
|
- lib/representable/coercion.rb
|
|
@@ -176,6 +181,7 @@ files:
|
|
|
176
181
|
- lib/representable/json/hash.rb
|
|
177
182
|
- lib/representable/object.rb
|
|
178
183
|
- lib/representable/object/binding.rb
|
|
184
|
+
- lib/representable/option.rb
|
|
179
185
|
- lib/representable/pipeline.rb
|
|
180
186
|
- lib/representable/pipeline_factories.rb
|
|
181
187
|
- lib/representable/populator.rb
|
|
@@ -203,7 +209,7 @@ files:
|
|
|
203
209
|
- test/default_test.rb
|
|
204
210
|
- test/defaults_options_test.rb
|
|
205
211
|
- test/definition_test.rb
|
|
206
|
-
- test/example.rb
|
|
212
|
+
- test/examples/example.rb
|
|
207
213
|
- test/examples/object.rb
|
|
208
214
|
- test/exec_context_test.rb
|
|
209
215
|
- test/features_test.rb
|
|
@@ -222,9 +228,9 @@ files:
|
|
|
222
228
|
- test/is_representable_test.rb
|
|
223
229
|
- test/json_test.rb
|
|
224
230
|
- test/lonely_test.rb
|
|
225
|
-
- test/mongoid_test.rb
|
|
226
231
|
- test/nested_test.rb
|
|
227
232
|
- test/object_test.rb
|
|
233
|
+
- test/option_test.rb
|
|
228
234
|
- test/parse_pipeline_test.rb
|
|
229
235
|
- test/pipeline_test.rb
|
|
230
236
|
- test/populator_test.rb
|
|
@@ -260,15 +266,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
260
266
|
requirements:
|
|
261
267
|
- - ">="
|
|
262
268
|
- !ruby/object:Gem::Version
|
|
263
|
-
version:
|
|
269
|
+
version: 2.4.0
|
|
264
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
271
|
requirements:
|
|
266
272
|
- - ">="
|
|
267
273
|
- !ruby/object:Gem::Version
|
|
268
274
|
version: '0'
|
|
269
275
|
requirements: []
|
|
270
|
-
|
|
271
|
-
rubygems_version: 2.5.2
|
|
276
|
+
rubygems_version: 3.0.3.1
|
|
272
277
|
signing_key:
|
|
273
278
|
specification_version: 4
|
|
274
279
|
summary: Renders and parses JSON/XML/YAML documents from and to Ruby objects. Includes
|
data/.travis.yml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Representable
|
|
2
|
-
autoload :Hash, 'representable/hash'
|
|
3
|
-
autoload :JSON, 'representable/json'
|
|
4
|
-
autoload :Object, 'representable/object'
|
|
5
|
-
autoload :YAML, 'representable/yaml'
|
|
6
|
-
autoload :XML, 'representable/xml'
|
|
7
|
-
|
|
8
|
-
module Hash
|
|
9
|
-
autoload :AllowSymbols, 'representable/hash/allow_symbols'
|
|
10
|
-
autoload :Collection, 'representable/hash/collection'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
autoload :Decorator, 'representable/decorator'
|
|
14
|
-
end
|
data/test/mongoid_test.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# require 'test_helper'
|
|
2
|
-
# require 'mongoid'
|
|
3
|
-
# require 'mongoid/document'
|
|
4
|
-
|
|
5
|
-
# class MongoidTest < MiniTest::Spec
|
|
6
|
-
# describe "Mongoid compatibility" do
|
|
7
|
-
# it "allows #to_json" do
|
|
8
|
-
# class Profile
|
|
9
|
-
# include Mongoid::Document
|
|
10
|
-
# field :name
|
|
11
|
-
# end
|
|
12
|
-
|
|
13
|
-
# class Dude
|
|
14
|
-
# include Mongoid::Document
|
|
15
|
-
# embeds_one :profile, :class_name => "MongoidTest::Profile"
|
|
16
|
-
# end
|
|
17
|
-
|
|
18
|
-
# module ProfileRepresenter
|
|
19
|
-
# include Representable::JSON
|
|
20
|
-
|
|
21
|
-
# property :name
|
|
22
|
-
# end
|
|
23
|
-
|
|
24
|
-
# dude = Dude.new
|
|
25
|
-
# dude.profile = Profile.new
|
|
26
|
-
# dude.profile.name = "Kofi"
|
|
27
|
-
|
|
28
|
-
# assert_equal "{\"name\":\"Kofi\"}", dude.profile.extend(ProfileRepresenter).to_json
|
|
29
|
-
# end
|
|
30
|
-
# end
|
|
31
|
-
# end
|