disposable 0.2.0.rc1 → 0.2.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +2 -0
- data/Gemfile +2 -1
- data/disposable.gemspec +1 -2
- data/lib/disposable/rescheme.rb +2 -0
- data/lib/disposable/twin/struct.rb +2 -2
- data/lib/disposable/twin/sync.rb +3 -2
- data/lib/disposable/version.rb +1 -1
- data/test/rescheme_test.rb +25 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc1db64d77739d1da5e821cedc6c1bde7d3f8bbd
|
4
|
+
data.tar.gz: 05f481a9db8f68cffe17779c24188b1033d6b00e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d619d15d0fcd6d09ca57c6438fe160a3f174dd494e933bb1ffec7bbd155d5eca5f89aa2c071efd9b54e645fa1cf36d97728b0bca51948d842918c0be48cbd7f
|
7
|
+
data.tar.gz: 67a7a1e451a6c867446a374bfe504932d70b31e5446ad419832e75db1428f28ff3d7080b753c651962976ce004714f289fdf4e373a578a899d798f67999533cd
|
data/CHANGES.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
* `Twin::representer_class.representable_attrs` is now `Twin::definitions`.
|
5
5
|
* `Disposable::Twin::Schema` is now `Disposable::Rescheme`. Renamed its `:representer_from` option to `:definitions_from`.
|
6
6
|
* `twin: Twin::Song` is the only way to specify an external twin. To reduce complexity, I've removed the lambda version of `:twin`.
|
7
|
+
* Added `:exclude_properties` to `Rescheme`.
|
8
|
+
* Runs with Representable 2.4 and 3.0.
|
7
9
|
|
8
10
|
# 0.1.14
|
9
11
|
|
data/Gemfile
CHANGED
@@ -2,7 +2,8 @@ source "https://rubygems.org"
|
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
# gem "representable", path: "../representable"
|
5
|
-
gem "representable",
|
5
|
+
gem "representable", "2.4.0.rc5"
|
6
|
+
# gem "representable", github: "apotonick/representable"
|
6
7
|
# gem "declarative", path: "../declarative"
|
7
8
|
# gem "declarative", github: "apotonick/declarative"
|
8
9
|
gem "minitest-line"
|
data/disposable.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'disposable/version'
|
@@ -20,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
20
19
|
|
21
20
|
spec.add_dependency "uber"
|
22
21
|
spec.add_dependency "declarative", "~> 0.0.4"
|
23
|
-
spec.add_dependency "representable", ">= 2.4.0.
|
22
|
+
spec.add_dependency "representable", ">= 2.4.0.rc5", "<= 3.1.0"
|
24
23
|
|
25
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
25
|
spec.add_development_dependency "rake"
|
data/lib/disposable/rescheme.rb
CHANGED
@@ -19,6 +19,8 @@ class Disposable::Rescheme
|
|
19
19
|
definitions = options[:definitions_from].call(source_class)
|
20
20
|
|
21
21
|
definitions.each do |dfn|
|
22
|
+
next if (options[:exclude_properties]||{}).include?(dfn[:name].to_sym)
|
23
|
+
|
22
24
|
dfn = build_definition!(options, dfn, representer, &block)
|
23
25
|
evaluate_block!(options, dfn, &block)
|
24
26
|
end
|
@@ -12,8 +12,8 @@
|
|
12
12
|
def sync_hash_representer # TODO: make this without representable, please.
|
13
13
|
Sync.hash_representer(self.class) do |dfn|
|
14
14
|
dfn.merge!(
|
15
|
-
prepare: lambda { |
|
16
|
-
serialize: lambda { |
|
15
|
+
prepare: lambda { |options| options[:input] },
|
16
|
+
serialize: lambda { |options| options[:input].sync! },
|
17
17
|
representable: true
|
18
18
|
) if dfn[:nested]
|
19
19
|
end
|
data/lib/disposable/twin/sync.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# 2. call sync! on nested
|
4
4
|
#
|
5
5
|
# Note: #sync currently implicitly saves AR objects with collections
|
6
|
+
require 'ostruct'
|
6
7
|
class Disposable::Twin
|
7
8
|
module Sync
|
8
9
|
class Options < ::Hash
|
@@ -93,8 +94,8 @@ class Disposable::Twin
|
|
93
94
|
)
|
94
95
|
|
95
96
|
dfn.merge!(
|
96
|
-
prepare: lambda { |
|
97
|
-
serialize: lambda { |
|
97
|
+
prepare: lambda { |options| options[:input] }, # TODO: why do we need that here?
|
98
|
+
serialize: lambda { |options| options[:input].to_nested_hash },
|
98
99
|
) if dfn[:nested]
|
99
100
|
end
|
100
101
|
end # #build_nested_hash_representer
|
data/lib/disposable/version.rb
CHANGED
data/test/rescheme_test.rb
CHANGED
@@ -100,6 +100,31 @@ class ReschemeTest < MiniTest::Spec
|
|
100
100
|
decorator.representable_attrs.get(:title).inspect.must_equal "#<Representable::Definition ==>title @options={:writeable=>false, :name=>\"title\", :parse_filter=>[], :render_filter=>[]}>"
|
101
101
|
decorator.representable_attrs.get(:songs).representer_module.representable_attrs.get(:name).inspect.must_equal "#<Representable::Definition ==>name @options={:as=>\"Name\", :deserializer=>{:skip_parse=>\"a crazy cool instance method\"}, :name=>\"name\", :parse_filter=>[], :render_filter=>[]}>"
|
102
102
|
end
|
103
|
+
|
104
|
+
describe ":exclude_properties" do
|
105
|
+
module SmallRepresenter
|
106
|
+
include Representable
|
107
|
+
|
108
|
+
property :id
|
109
|
+
property :songs do
|
110
|
+
property :id
|
111
|
+
property :name, as: "Name"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it do
|
116
|
+
decorator = Disposable::Rescheme.from(SmallRepresenter,
|
117
|
+
include: [Representable::Hash],
|
118
|
+
superclass: Representable::Decorator,
|
119
|
+
definitions_from: lambda { |nested| nested.definitions },
|
120
|
+
recursive: true,
|
121
|
+
exclude_properties: [:id]
|
122
|
+
)
|
123
|
+
|
124
|
+
decorator.definitions.keys.must_equal ["songs"]
|
125
|
+
decorator.definitions.get(:songs).representer_module.definitions.keys.must_equal ["name"]
|
126
|
+
end
|
127
|
+
end
|
103
128
|
end
|
104
129
|
|
105
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disposable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|
@@ -44,20 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.4.0.
|
48
|
-
- - "
|
47
|
+
version: 2.4.0.rc5
|
48
|
+
- - "<="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 3.1.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 2.4.0.
|
58
|
-
- - "
|
57
|
+
version: 2.4.0.rc5
|
58
|
+
- - "<="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 3.1.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: bundler
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|