dry-data 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +6 -1
- data/benchmarks/basic.rb +1 -1
- data/benchmarks/constrained.rb +43 -0
- data/dry-data.gemspec +1 -0
- data/lib/dry/data.rb +4 -1
- data/lib/dry/data/constraints.rb +0 -2
- data/lib/dry/data/struct.rb +1 -1
- data/lib/dry/data/value.rb +20 -0
- data/lib/dry/data/version.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11440d87987301e5ab00e881aca9769d10ca46b6
|
4
|
+
data.tar.gz: 10aac35f319d13a0f42875976005c32f8feb08f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b992fddcabd0940aec06466dff1fc804161183fb579619ea53fb4b38f4ca7229812677001b718f6af8d91e2c99603ae808e5c253e2e9bde93f2dec797b77b99
|
7
|
+
data.tar.gz: fa2e28003cf3ca3bffbb6f2953a5d8860c312e9fbf5135249432f5f7ecd358f94e8a64938f2e7add69618b66c4c947c84c215338e111d9cc61e73fa94a8dd806
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# v0.3.2 2015-12-10
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
* `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
* Added missing require for `dry-equalizer` (solnic)
|
10
|
+
|
11
|
+
[Compare v0.3.1...v0.3.2](https://github.com/dryrb/dry-data/compare/v0.3.1...v0.3.2)
|
12
|
+
|
1
13
|
# v0.3.1 2015-12-09
|
2
14
|
|
3
15
|
## Changed
|
data/Gemfile
CHANGED
@@ -5,9 +5,14 @@ gemspec
|
|
5
5
|
gem 'dry-validation'
|
6
6
|
|
7
7
|
group :tools do
|
8
|
+
gem 'byebug', platform: :mri
|
9
|
+
end
|
10
|
+
|
11
|
+
group :benchmarks do
|
12
|
+
gem 'sqlite3'
|
13
|
+
gem 'activerecord'
|
8
14
|
gem 'benchmark-ips'
|
9
15
|
gem 'virtus'
|
10
16
|
gem 'fast_attributes'
|
11
17
|
gem 'attrio'
|
12
|
-
gem 'byebug', platform: :mri
|
13
18
|
end
|
data/benchmarks/basic.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'dry-data'
|
2
|
+
require 'dry/data/type/constrained'
|
3
|
+
|
4
|
+
require 'active_record'
|
5
|
+
require 'benchmark/ips'
|
6
|
+
|
7
|
+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
8
|
+
|
9
|
+
ActiveRecord::Schema.define do
|
10
|
+
create_table :users do |table|
|
11
|
+
table.column :name, :string
|
12
|
+
table.column :age, :integer
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ARUser < ActiveRecord::Base
|
17
|
+
self.table_name = :users
|
18
|
+
end
|
19
|
+
|
20
|
+
module Types
|
21
|
+
end
|
22
|
+
|
23
|
+
Dry::Data.configure do |config|
|
24
|
+
config.namespace = Types
|
25
|
+
end
|
26
|
+
|
27
|
+
Dry::Data.finalize
|
28
|
+
|
29
|
+
class DryDataUser < Dry::Data::Struct
|
30
|
+
attribute :id, Types::Form::Int
|
31
|
+
attribute :name, Types::Strict::String.constrained(size: 3..64)
|
32
|
+
attribute :age, Types::Form::Int.constrained(gt: 18)
|
33
|
+
end
|
34
|
+
|
35
|
+
puts ARUser.new(id: 1, name: 'Jane', age: '21').inspect
|
36
|
+
puts DryDataUser.new(id: 1, name: 'Jane', age: '21').inspect
|
37
|
+
|
38
|
+
Benchmark.ips do |x|
|
39
|
+
x.report('active record') { ARUser.new(id: 1, name: 'Jane', age: '21') }
|
40
|
+
x.report('dry-data') { DryDataUser.new(id: 1, name: 'Jane', age: '21') }
|
41
|
+
|
42
|
+
x.compare!
|
43
|
+
end
|
data/dry-data.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_runtime_dependency 'thread_safe', '~> 0.3'
|
31
31
|
spec.add_runtime_dependency 'dry-container', '~> 0.2'
|
32
|
+
spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
|
32
33
|
spec.add_runtime_dependency 'dry-configurable', '~> 0.1'
|
33
34
|
spec.add_runtime_dependency 'inflecto', '~> 0.0.0', '>= 0.0.2'
|
34
35
|
spec.add_runtime_dependency 'kleisli', '~> 0.2'
|
data/lib/dry/data.rb
CHANGED
@@ -2,14 +2,17 @@ require 'bigdecimal'
|
|
2
2
|
require 'date'
|
3
3
|
require 'set'
|
4
4
|
|
5
|
-
require 'dry-container'
|
6
5
|
require 'inflecto'
|
7
6
|
require 'thread_safe/cache'
|
8
7
|
|
8
|
+
require 'dry-container'
|
9
|
+
require 'dry-equalizer'
|
10
|
+
|
9
11
|
require 'dry/data/version'
|
10
12
|
require 'dry/data/container'
|
11
13
|
require 'dry/data/type'
|
12
14
|
require 'dry/data/struct'
|
15
|
+
require 'dry/data/value'
|
13
16
|
require 'dry/data/dsl'
|
14
17
|
|
15
18
|
module Dry
|
data/lib/dry/data/constraints.rb
CHANGED
data/lib/dry/data/struct.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Dry
|
2
|
+
module Data
|
3
|
+
class Value < Struct
|
4
|
+
def self.inherited(klass)
|
5
|
+
super
|
6
|
+
klass.instance_variable_set('@equalizer', Equalizer.new)
|
7
|
+
klass.send(:include, klass.equalizer)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.attributes(*args)
|
11
|
+
super
|
12
|
+
equalizer.instance_variable_get('@keys').concat(schema.keys).uniq!
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.equalizer
|
16
|
+
@equalizer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/dry/data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-equalizer
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: dry-configurable
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +158,7 @@ files:
|
|
144
158
|
- README.md
|
145
159
|
- Rakefile
|
146
160
|
- benchmarks/basic.rb
|
161
|
+
- benchmarks/constrained.rb
|
147
162
|
- bin/console
|
148
163
|
- bin/setup
|
149
164
|
- dry-data.gemspec
|
@@ -164,6 +179,7 @@ files:
|
|
164
179
|
- lib/dry/data/type/optional.rb
|
165
180
|
- lib/dry/data/types.rb
|
166
181
|
- lib/dry/data/types/form.rb
|
182
|
+
- lib/dry/data/value.rb
|
167
183
|
- lib/dry/data/version.rb
|
168
184
|
homepage: https://github.com/dryrb/dry-data
|
169
185
|
licenses:
|
@@ -186,8 +202,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
202
|
version: '0'
|
187
203
|
requirements: []
|
188
204
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.4.5
|
205
|
+
rubygems_version: 2.4.5
|
190
206
|
signing_key:
|
191
207
|
specification_version: 4
|
192
208
|
summary: Simple type-system for Ruby
|
193
209
|
test_files: []
|
210
|
+
has_rdoc:
|