disposable 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/CHANGES.md +6 -0
- data/disposable.gemspec +2 -2
- data/lib/disposable/twin.rb +7 -0
- data/lib/disposable/twin/coercion.rb +3 -1
- data/lib/disposable/version.rb +1 -1
- data/test/twin/changed_test.rb +2 -2
- data/test/twin/coercion_test.rb +2 -3
- data/test/twin/struct/coercion_test.rb +1 -1
- data/test/twin/twin_test.rb +10 -0
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d17fbfc73eb6b25b90136d515733b694ac2631ad3861f47d62dde5517ec394b
|
4
|
+
data.tar.gz: be69f4aaed8fda60749dcb3dc3188bb57def014cd91715198baab0eebd801386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb4b2eca60ed3001be80d50eff19fe008abf68030a99101eb0282b5fe65d091c21d62537a3dcbfafb32484e985d4e670377d701413de25832b8195f0ff08cdeb
|
7
|
+
data.tar.gz: b95131034f38c0907672943108c0633164817981ba0107c508e618467b69f0c7f2e914c91d1152219b3488e6432cd1a9839e394704a1465e1792ef540140613e
|
data/.travis.yml
CHANGED
@@ -7,6 +7,9 @@ rvm:
|
|
7
7
|
- 2.3
|
8
8
|
- 2.2
|
9
9
|
env:
|
10
|
+
- "DRY_TYPES=1.1"
|
11
|
+
- "DRY_TYPES=1.0"
|
12
|
+
- "DRY_TYPES=0.15"
|
10
13
|
- "DRY_TYPES=0.13"
|
11
14
|
- "DRY_TYPES=0.12"
|
12
15
|
- "ACTIVERECORD=5.0"
|
@@ -29,3 +32,11 @@ matrix:
|
|
29
32
|
- rvm: ruby-head
|
30
33
|
- env: ACTIVERECORD=4.1
|
31
34
|
- rvm: 2.1
|
35
|
+
- rvm: 2.2
|
36
|
+
exclude:
|
37
|
+
- { rvm: 2.3, env: DRY_TYPES=1.1 }
|
38
|
+
- { rvm: 2.2, env: DRY_TYPES=1.1 }
|
39
|
+
- { rvm: 2.3, env: DRY_TYPES=1.0 }
|
40
|
+
- { rvm: 2.2, env: DRY_TYPES=1.0 }
|
41
|
+
- { rvm: 2.3, env: DRY_TYPES=0.15 }
|
42
|
+
- { rvm: 2.2, env: DRY_TYPES=0.15 }
|
data/CHANGES.md
CHANGED
data/disposable.gemspec
CHANGED
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "declarative-option", "< 0.2.0"
|
23
23
|
spec.add_dependency "representable", ">= 2.4.0", "<= 3.1.0"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"#, "~> 1.3"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "minitest"
|
28
28
|
spec.add_development_dependency "activerecord"#, "4.2.5"
|
29
|
-
spec.add_development_dependency "sqlite3"
|
29
|
+
spec.add_development_dependency "sqlite3", '~> 1.3.0'
|
30
30
|
spec.add_development_dependency "dry-types"# "~> 0.6"
|
31
31
|
# spec.add_development_dependency "database_cleaner"
|
32
32
|
end
|
data/lib/disposable/twin.rb
CHANGED
@@ -9,6 +9,9 @@ require "representable/decorator"
|
|
9
9
|
|
10
10
|
module Disposable
|
11
11
|
class Twin
|
12
|
+
class InvalidPropertyNameError < StandardError; end
|
13
|
+
INVALID_PROPERTY_NAMES = %i[class].freeze
|
14
|
+
|
12
15
|
extend Declarative::Schema
|
13
16
|
def self.definition_class
|
14
17
|
Definition
|
@@ -32,6 +35,10 @@ module Disposable
|
|
32
35
|
|
33
36
|
# TODO: move to Declarative, as in Representable and Reform.
|
34
37
|
def property(name, options={}, &block)
|
38
|
+
if INVALID_PROPERTY_NAMES.include?(name)
|
39
|
+
raise InvalidPropertyNameError.new("#{name} is used internally and cannot be used as property name")
|
40
|
+
end
|
41
|
+
|
35
42
|
options[:private_name] ||= options.delete(:from) || name
|
36
43
|
is_inherited = options.delete(:_inherited)
|
37
44
|
|
@@ -2,7 +2,9 @@ require "dry-types"
|
|
2
2
|
|
3
3
|
module Disposable::Twin::Coercion
|
4
4
|
module Types
|
5
|
-
|
5
|
+
# NOTE: Use Dry.Types() instead. Beware, it exports strict types by default, for old behavior use Dry.Types(default: :nominal)
|
6
|
+
DRY_MODULE = Gem::Version.new(Dry::Types::VERSION) < Gem::Version.new("0.15.0") ? Dry::Types.module : Dry.Types()
|
7
|
+
include DRY_MODULE
|
6
8
|
end
|
7
9
|
|
8
10
|
DRY_TYPES_VERSION = Gem::Version.new(Dry::Types::VERSION)
|
data/lib/disposable/version.rb
CHANGED
data/test/twin/changed_test.rb
CHANGED
@@ -114,7 +114,7 @@ class ChangedWithCoercionTest < MiniTest::Spec
|
|
114
114
|
include Changed
|
115
115
|
include Coercion
|
116
116
|
|
117
|
-
property :released, type: DRY_TYPES_CONSTANT::Bool
|
117
|
+
property :released, type: DRY_TYPES_CONSTANT::Bool | DRY_TYPES_CONSTANT::Nil
|
118
118
|
end
|
119
119
|
|
120
120
|
it do
|
@@ -133,4 +133,4 @@ class ChangedWithCoercionTest < MiniTest::Spec
|
|
133
133
|
twin.released = 'false'
|
134
134
|
twin.changed?(:released).must_equal true
|
135
135
|
end
|
136
|
-
end
|
136
|
+
end
|
data/test/twin/coercion_test.rb
CHANGED
@@ -82,7 +82,7 @@ class CoercionTest < MiniTest::Spec
|
|
82
82
|
type: DRY_TYPES_CONSTANT::Date, nilify: true
|
83
83
|
property :date_of_death_by_unicorns,
|
84
84
|
type: DRY_TYPES_CONSTANT::Nil | DRY_TYPES_CONSTANT::Date
|
85
|
-
property :id, nilify: true
|
85
|
+
property :id, type: const_get("Types::Coercible::#{DRY_TYPES_INT_CONSTANT}"), nilify: true
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "with Nilify" do
|
@@ -155,8 +155,7 @@ class CoercionTypingTest < MiniTest::Spec
|
|
155
155
|
|
156
156
|
# property :title, type: Dry::Types::Strict::String.constructor(Dry::Types::Params.method(:to_nil))
|
157
157
|
|
158
|
-
|
159
|
-
property :title, type: Types::Strict::String.optional.constructor(Dry::Types[constructor]) # this is the behavior of the "DB" data twin. this is NOT the form.
|
158
|
+
property :title, type: DRY_TYPES_CONSTANT::Nil | Types::Strict::String # this is the behavior of the "DB" data twin. this is NOT the form.
|
160
159
|
|
161
160
|
# property :name, type: Types::Params::String
|
162
161
|
|
@@ -10,7 +10,7 @@ class StructCoercionTest < Minitest::Spec
|
|
10
10
|
feature Coercion
|
11
11
|
|
12
12
|
property :content do
|
13
|
-
property :amount, type: DRY_TYPES_CONSTANT::Float
|
13
|
+
property :amount, type: DRY_TYPES_CONSTANT::Float | DRY_TYPES_CONSTANT::Nil
|
14
14
|
end
|
15
15
|
|
16
16
|
unnest :amount, from: :content
|
data/test/twin/twin_test.rb
CHANGED
@@ -152,3 +152,13 @@ class AccessorsTest < Minitest::Spec
|
|
152
152
|
twin.format = "blubb"
|
153
153
|
end
|
154
154
|
end
|
155
|
+
|
156
|
+
class InvalidPropertyNameTest < Minitest::Spec
|
157
|
+
it 'raises InvalidPropertyNameError' do
|
158
|
+
assert_raises(Disposable::Twin::InvalidPropertyNameError) {
|
159
|
+
class Twin < Disposable::Twin
|
160
|
+
property :class
|
161
|
+
end
|
162
|
+
}
|
163
|
+
end
|
164
|
+
end
|
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.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|
@@ -96,16 +96,16 @@ dependencies:
|
|
96
96
|
name: bundler
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
101
|
+
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
108
|
+
version: '0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: rake
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,16 +152,16 @@ dependencies:
|
|
152
152
|
name: sqlite3
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
|
-
- - "
|
155
|
+
- - "~>"
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
157
|
+
version: 1.3.0
|
158
158
|
type: :development
|
159
159
|
prerelease: false
|
160
160
|
version_requirements: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
|
-
- - "
|
162
|
+
- - "~>"
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
164
|
+
version: 1.3.0
|
165
165
|
- !ruby/object:Gem::Dependency
|
166
166
|
name: dry-types
|
167
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,7 +273,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
- !ruby/object:Gem::Version
|
274
274
|
version: '0'
|
275
275
|
requirements: []
|
276
|
-
|
276
|
+
rubyforge_project:
|
277
|
+
rubygems_version: 2.7.6.2
|
277
278
|
signing_key:
|
278
279
|
specification_version: 4
|
279
280
|
summary: Decorators on top of your ORM layer with change tracking, collection semantics
|