representable 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fac946d38143671ea43e0a6981d35dc7e8e8a0026af631fe53bb67d30f413c0
4
- data.tar.gz: 3f98fb8a4ff2ea929ecd3afd9c97bc32fa7b7959d696a5c4ea4d5c9aecfac4d4
3
+ metadata.gz: f3a1388b7570e31d62c555a87d6165793e9d095cf1bed18c04cb8cbe86bc2ba2
4
+ data.tar.gz: 43e418db52478d3d4fc33f505ce86d840fcb666a8abc83e20269bbfab4c53a3a
5
5
  SHA512:
6
- metadata.gz: 781a63fe0c5a650bc54d007dd6c16b20dec422b8312fa831b938ad0b78a1ffe5c6cbf640de1406574943035cbbc03925446e9ddd0cc640c1a0c9e9212b75d71e
7
- data.tar.gz: fbedd21d3373cca798829c164357cc8c6d1470c9fe16b4d404b67a1df0f9eeebdb13a1ae262f585d54c4a2c4209573b23f211b4ca1430e801c21dca4c9451b4f
6
+ metadata.gz: 39e957975d24f76894ef9a7186fff69155525e5f777c120a77e2ecee8a7dcdccee62b2140ed8ab34ebc9de916a9098d9da846e0befda2c90fa32e4a9ff470ecc
7
+ data.tar.gz: cf309756f2470854283c09bbca25b3200b26ba1702b75e533573382dabd2f33a6f3eeaee963c2cc2bb0ddb9d3bdf026bf7dacba6da3f22f44dc805bc8d1ca505
@@ -1,17 +1,23 @@
1
1
  name: CI
2
- on: [push, pull_request]
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ branches:
8
+ - master
9
+
3
10
  jobs:
4
11
  test:
5
12
  strategy:
6
13
  fail-fast: false
7
14
  matrix:
8
- # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
9
- ruby: [2.5, 2.6, 2.7, '3.0', head]
15
+ ruby: [2.5, 2.6, 2.7, '3.0', "3.1"]
10
16
  runs-on: ubuntu-latest
11
17
  steps:
12
18
  - uses: actions/checkout@v2
13
19
  - uses: ruby/setup-ruby@v1
14
20
  with:
15
21
  ruby-version: ${{ matrix.ruby }}
16
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
22
+ bundler-cache: true
17
23
  - run: bundle exec rake
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 3.2.0
2
+ * Drop support for Virtus Coercion
3
+ * Fix deprecation warning with Nokogiri 1.13.0
4
+
1
5
  # 3.1.1
2
6
 
3
7
  * Upgrade `trailblazer-option` to `0.1.1` which supports passing an empty `keyword_arguments`.
data/README.md CHANGED
@@ -2,20 +2,19 @@
2
2
 
3
3
  Representable maps Ruby objects to documents and back.
4
4
 
5
- [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
- [![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
7
- [![Build
8
- Status](https://travis-ci.org/trailblazer/representable.svg)](https://travis-ci.org/trailblazer/representable)
5
+ ![Build
6
+ Status](https://github.com/trailblazer/representable/actions/workflows/ci.yml/badge.svg?branch=master)
9
7
  [![Gem Version](https://badge.fury.io/rb/representable.svg)](http://badge.fury.io/rb/representable)
10
8
 
9
+
11
10
  In other words: Take an object and decorate it with a representer module. This will allow you to render a JSON, XML or YAML document from that object. But that's only half of it! You can also use representers to parse a document and create or populate an object.
12
11
 
13
- Representable is helpful for all kind of mappings, rendering and parsing workflows. However, it is mostly useful in API code. Are you planning to write a real REST API with representable? Then check out the [Roar](http://github.com/apotonick/roar) gem first, save work and time and make the world a better place instead.
12
+ Representable is helpful for all kind of mappings, rendering and parsing workflows. However, it is mostly useful in API code. Are you planning to write a real REST API with representable? Then check out the [Roar](https://github.com/trailblazer/roar) gem first, save work and time and make the world a better place instead.
14
13
 
15
14
 
16
15
  ## Full Documentation
17
16
 
18
- Representable comes with a rich set of options and semantics for parsing and rendering documents. Its [full documentation](http://trailblazer.to/gems/representable/3.0/api.html) can be found on the Trailblazer site.
17
+ Representable comes with a rich set of options and semantics for parsing and rendering documents. Its [full documentation](https://trailblazer.to/2.1/docs/representable.html) can be found on the Trailblazer site.
19
18
 
20
19
  ## Example
21
20
 
@@ -64,7 +63,7 @@ song = SongRepresenter.new(song).from_json(%{ {"title":"Roxanne"} })
64
63
  #=> #<Song title="Roxanne", track=nil>
65
64
  ```
66
65
 
67
- Note that parsing hashes per default does [require string keys](http://trailblazer.to/gems/representable/3.0/api.html#symbol-keys) and does _not_ pick up symbol keys.
66
+ Note that parsing hashes per default does [require string keys](https://trailblazer.to/2.1/docs/representable.html#representable-api-symbol-keys) and does _not_ pick up symbol keys.
68
67
 
69
68
 
70
69
  ## Collections
@@ -137,7 +136,7 @@ end
137
136
 
138
137
  Representable has many more features and can literally parse and render any kind of document to an arbitrary Ruby object graph.
139
138
 
140
- Please check the [official documentation for more](http://trailblazer.to/gems/representable/).
139
+ Please check the [official documentation for more](https://trailblazer.to/2.1/docs/representable.html#representable-api).
141
140
 
142
141
 
143
142
  ## Installation
@@ -172,4 +171,4 @@ Representable started as a heavily simplified fork of the ROXML gem. Big thanks
172
171
  * Copyright (c) 2011-2020 Nick Sutterer <apotonick@gmail.com>
173
172
  * ROXML is Copyright (c) 2004-2009 Ben Woosley, Zak Mandhro and Anders Engstrom.
174
173
 
175
- Representable is released under the [MIT License](http://www.opensource.org/licenses/MIT).
174
+ Representable is released under the [MIT License](https://www.opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module Representable
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -24,7 +24,7 @@ module Representable
24
24
  wrap_node = parent
25
25
 
26
26
  if wrap = self[:wrap]
27
- parent << wrap_node = XML::Node(parent, wrap)
27
+ parent << wrap_node = XML::Node(parent.document, wrap)
28
28
  end
29
29
 
30
30
  wrap_node << serialize_for(fragments, parent, as)
@@ -39,7 +39,7 @@ module Representable
39
39
 
40
40
  # Creates wrapped node for the property.
41
41
  def serialize_for(value, parent, as)
42
- node = XML::Node(parent, as) # node doesn't have attr="" attributes!!!
42
+ node = XML::Node(parent.document, as) # node doesn't have attr="" attributes!!!
43
43
  serialize_node(node, value, as)
44
44
  end
45
45
 
@@ -106,7 +106,7 @@ module Representable
106
106
  class Hash < Collection
107
107
  def serialize_for(value, parent, as)
108
108
  set_for(parent, value.collect do |k, v|
109
- node = XML::Node(parent, k)
109
+ node = XML::Node(parent.document, k)
110
110
  serialize_node(node, v, as)
111
111
  end)
112
112
  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.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-13 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uber
@@ -188,7 +188,6 @@ files:
188
188
  - lib/representable/represent.rb
189
189
  - lib/representable/serializer.rb
190
190
  - lib/representable/version.rb
191
- - lib/representable/virtus_coercion.rb
192
191
  - lib/representable/xml.rb
193
192
  - lib/representable/xml/binding.rb
194
193
  - lib/representable/xml/collection.rb
@@ -250,7 +249,6 @@ files:
250
249
  - test/test_helper_test.rb
251
250
  - test/uncategorized_test.rb
252
251
  - test/user_options_test.rb
253
- - test/virtus_coercion_test.rb
254
252
  - test/wrap_test.rb
255
253
  - test/xml_bindings_test.rb
256
254
  - test/xml_namespace_test.rb
@@ -260,7 +258,7 @@ homepage: https://github.com/trailblazer/representable/
260
258
  licenses:
261
259
  - MIT
262
260
  metadata: {}
263
- post_install_message:
261
+ post_install_message:
264
262
  rdoc_options: []
265
263
  require_paths:
266
264
  - lib
@@ -275,68 +273,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
273
  - !ruby/object:Gem::Version
276
274
  version: '0'
277
275
  requirements: []
278
- rubygems_version: 3.0.8
279
- signing_key:
276
+ rubygems_version: 3.0.3.1
277
+ signing_key:
280
278
  specification_version: 4
281
279
  summary: Renders and parses JSON/XML/YAML documents from and to Ruby objects. Includes
282
280
  plain properties, collections, nesting, coercion and more.
283
- test_files:
284
- - test/as_test.rb
285
- - test/benchmarking.rb
286
- - test/binding_test.rb
287
- - test/cached_test.rb
288
- - test/class_test.rb
289
- - test/coercion_test.rb
290
- - test/config/inherit_test.rb
291
- - test/config_test.rb
292
- - test/decorator_scope_test.rb
293
- - test/decorator_test.rb
294
- - test/default_test.rb
295
- - test/defaults_options_test.rb
296
- - test/definition_test.rb
297
- - test/examples/example.rb
298
- - test/examples/object.rb
299
- - test/exec_context_test.rb
300
- - test/features_test.rb
301
- - test/filter_test.rb
302
- - test/for_collection_test.rb
303
- - test/generic_test.rb
304
- - test/getter_setter_test.rb
305
- - test/hash_bindings_test.rb
306
- - test/hash_test.rb
307
- - test/heritage_test.rb
308
- - test/if_test.rb
309
- - test/include_exclude_test.rb
310
- - test/inherit_test.rb
311
- - test/inline_test.rb
312
- - test/instance_test.rb
313
- - test/is_representable_test.rb
314
- - test/json_test.rb
315
- - test/lonely_test.rb
316
- - test/nested_test.rb
317
- - test/object_test.rb
318
- - test/option_test.rb
319
- - test/parse_pipeline_test.rb
320
- - test/pipeline_test.rb
321
- - test/populator_test.rb
322
- - test/prepare_test.rb
323
- - test/private_options_test.rb
324
- - test/reader_writer_test.rb
325
- - test/realistic_benchmark.rb
326
- - test/render_nil_test.rb
327
- - test/represent_test.rb
328
- - test/representable_test.rb
329
- - test/schema_test.rb
330
- - test/serialize_deserialize_test.rb
331
- - test/skip_test.rb
332
- - test/stringify_hash_test.rb
333
- - test/test_helper.rb
334
- - test/test_helper_test.rb
335
- - test/uncategorized_test.rb
336
- - test/user_options_test.rb
337
- - test/virtus_coercion_test.rb
338
- - test/wrap_test.rb
339
- - test/xml_bindings_test.rb
340
- - test/xml_namespace_test.rb
341
- - test/xml_test.rb
342
- - test/yaml_test.rb
281
+ test_files: []
@@ -1,38 +0,0 @@
1
- gem 'virtus'
2
- require "virtus"
3
-
4
- module Representable
5
- module VirtusCoercion
6
- class Coercer
7
- def initialize(type)
8
- @type = type
9
- end
10
-
11
- # This gets called when the :render_filter or :parse_filter option is evaluated.
12
- # Usually the Coercer instance is an element in a Pipeline to allow >1 filters per property.
13
- def call(input, options)
14
- Virtus::Attribute.build(@type).coerce(input)
15
- end
16
- end
17
-
18
-
19
- def self.included(base)
20
- base.class_eval do
21
- extend ClassMethods
22
- register_feature VirtusCoercion
23
- end
24
- end
25
-
26
-
27
- module ClassMethods
28
- def property(name, options={}, &block)
29
- super.tap do |definition|
30
- return definition unless type = options[:type]
31
-
32
- definition.merge!(render_filter: coercer = Coercer.new(type))
33
- definition.merge!(parse_filter: coercer)
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,52 +0,0 @@
1
- require 'test_helper'
2
- require 'representable/virtus_coercion'
3
-
4
- class VirtusCoercionTest < MiniTest::Spec
5
- representer! do
6
- include Representable::VirtusCoercion
7
-
8
- property :title # no coercion.
9
- property :length, :type => Float
10
-
11
- property :band, :class => OpenStruct do
12
- property :founded, :type => Integer
13
- end
14
-
15
- collection :songs, :class => OpenStruct do
16
- property :ok, :type => Virtus::Attribute::Boolean
17
- end
18
- end
19
-
20
- let(:album) { OpenStruct.new(:title => "Dire Straits", :length => 41.34,
21
- :band => OpenStruct.new(:founded => "1977"),
22
- :songs => [OpenStruct.new(:ok => 1), OpenStruct.new(:ok => 0)]) }
23
-
24
- it { _(album.extend(representer).to_hash).must_equal({"title"=>"Dire Straits", "length"=>41.34, "band"=>{"founded"=>1977}, "songs"=>[{"ok"=>true}, {"ok"=>false}]}) }
25
-
26
- it {
27
- album = OpenStruct.new
28
- album.extend(representer)
29
- album.from_hash({"title"=>"Dire Straits", "length"=>"41.34", "band"=>{"founded"=>"1977"}, "songs"=>[{"ok"=>1}, {"ok"=>0}]})
30
-
31
- # it
32
- _(album.length).must_equal 41.34
33
- _(album.band.founded).must_equal 1977
34
- _(album.songs[0].ok).must_equal true
35
- }
36
-
37
-
38
- describe "with user :parse_filter and :render_filter" do
39
- representer! do
40
- include Representable::VirtusCoercion
41
-
42
- property :length, :type => Float,
43
- :parse_filter => lambda { |input, options| "#{input}.1" }, # happens BEFORE coercer.
44
- :render_filter => lambda { |fragment,*| "#{fragment}.1" }
45
- end
46
-
47
- # user's :parse_filter(s) are run before coercion.
48
- it { _(OpenStruct.new.extend(representer).from_hash("length"=>"1").length).must_equal 1.1 }
49
- # user's :render_filter(s) are run before coercion.
50
- it { _(OpenStruct.new(:length=>1).extend(representer).to_hash).must_equal({"length" => 1.1}) }
51
- end
52
- end