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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a0b6cd70b82bc532b0a07ca0035dc1f1c6b112cb90fca7d244e1ac3468c327f
4
- data.tar.gz: 661653dde2ad0f4aca0107e84605e92764952023aae4c7b0d624cded6d7130ad
3
+ metadata.gz: 0d17fbfc73eb6b25b90136d515733b694ac2631ad3861f47d62dde5517ec394b
4
+ data.tar.gz: be69f4aaed8fda60749dcb3dc3188bb57def014cd91715198baab0eebd801386
5
5
  SHA512:
6
- metadata.gz: f382b96782f326b2b52a85cfdf340c99a29824af3aa7cccbf9129a146700b73b6b48137361e56a7b1b017b48236c6aef15029d98b78a35e192eafeb765caacb2
7
- data.tar.gz: b2712eab0e52144fbe418e2035dc39ccba6ce241304debaab9e04b4ee39f71dcc3eb95a77c0f1d2885538c38361f6efb896620c052e4bcb58f1529390b61eae8
6
+ metadata.gz: eb4b2eca60ed3001be80d50eff19fe008abf68030a99101eb0282b5fe65d091c21d62537a3dcbfafb32484e985d4e670377d701413de25832b8195f0ff08cdeb
7
+ data.tar.gz: b95131034f38c0907672943108c0633164817981ba0107c508e618467b69f0c7f2e914c91d1152219b3488e6432cd1a9839e394704a1465e1792ef540140613e
@@ -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
@@ -1,3 +1,9 @@
1
+ # 0.4.6
2
+
3
+ * Remove deprecation warnings for newer versions of dry-types
4
+ * Fix sqlite3 version to 1.3.x to avoid issue with AR 5.0
5
+ * Raise an error if class is used as property name
6
+
1
7
  # 0.4.5
2
8
 
3
9
  * Use Gem::Version to detect version for dry-types
@@ -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", "~> 1.3"
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
@@ -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
- include Dry::Types.module
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)
@@ -1,3 +1,3 @@
1
1
  module Disposable
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
@@ -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
@@ -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
- constructor = Disposable::Twin::Coercion::DRY_TYPES_VERSION < Gem::Version.new("0.13.0") ? 'form.nil' : 'params.nil'
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
@@ -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.5
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-04-30 00:00:00.000000000 Z
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: '1.3'
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: '1.3'
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: '0'
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: '0'
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
- rubygems_version: 3.0.2
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