rom-repository 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -2
- data/Gemfile +1 -7
- data/Rakefile +1 -0
- data/lib/rom/repository/struct_builder.rb +1 -1
- data/lib/rom/repository/version.rb +1 -1
- data/spec/integration/typed_structs_spec.rb +47 -14
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/struct_builder_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d225169d8e6601c42a19f9e8504363fb766b49b
|
4
|
+
data.tar.gz: 2277ca38edb2706b648fabbd30da68cbbb9adb3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb36f1ef4cd751ddb8de93a54018b6c057db268c00f66131a5911f7b3f632e1db159952fc6be2043a486ed6c31dedb6aced2933df57a3b9cb74768d2fa09f346
|
7
|
+
data.tar.gz: 73ce2e1fbcedc63495fd7b6bcd959a938427d9b16774396450dd04b26a64585a4f4f56033cf7763c29f9ca0e94cdb72517e01b2aa24920f0c7894bb60a1bfa4b
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
+
# v1.0.2 2017-02-13
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Structs uses read types for attributes so that they don't perform an unexpected serialization (flash-gordon)
|
6
|
+
|
7
|
+
[Compare v1.0.1...v1.0.2](https://github.com/rom-rb/rom-repository/compare/v1.0.1...v1.0.2)
|
8
|
+
|
1
9
|
# v1.0.1 2017-01-31
|
2
10
|
|
3
11
|
### Fixed
|
4
12
|
|
5
13
|
* `Changeset::Update` creates a command with restricted relation (solnic)
|
6
|
-
* `Changeset#result` will always return `:many` for arrays and `:one` for other objects (even a custom object is used) (solnic)
|
14
|
+
* `Changeset#result` will always return `:many` for arrays and `:one` for other objects (even when a custom object is used) (solnic)
|
7
15
|
|
8
|
-
[Compare v1.0.
|
16
|
+
[Compare v1.0.0...v1.0.1](https://github.com/rom-rb/rom-repository/compare/v1.0.0...v1.0.1)
|
9
17
|
|
10
18
|
# v1.0.0 2017-01-30
|
11
19
|
|
data/Gemfile
CHANGED
@@ -4,13 +4,6 @@ gemspec
|
|
4
4
|
|
5
5
|
gem 'inflecto'
|
6
6
|
|
7
|
-
gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master'
|
8
|
-
gem 'rom-mapper', git: 'https://github.com/rom-rb/rom-mapper.git', branch: 'master'
|
9
|
-
|
10
|
-
group :development, :test do
|
11
|
-
gem 'rom-sql', git: 'https://github.com/rom-rb/rom-sql.git', branch: 'master'
|
12
|
-
end
|
13
|
-
|
14
7
|
group :development do
|
15
8
|
gem 'dry-equalizer', '~> 0.2'
|
16
9
|
gem 'sqlite3', platforms: [:mri, :rbx]
|
@@ -18,6 +11,7 @@ group :development do
|
|
18
11
|
end
|
19
12
|
|
20
13
|
group :test do
|
14
|
+
gem 'rom-sql'
|
21
15
|
gem 'rspec'
|
22
16
|
gem 'dry-struct'
|
23
17
|
gem 'byebug', platforms: :mri
|
data/Rakefile
CHANGED
@@ -1,31 +1,64 @@
|
|
1
1
|
RSpec.describe 'ROM repository with typed structs' do
|
2
2
|
subject(:repo) do
|
3
|
-
Class.new(ROM::Repository[:books]).new(rom)
|
3
|
+
Class.new(ROM::Repository[:books]) { commands :create }.new(rom)
|
4
4
|
end
|
5
5
|
|
6
6
|
include_context 'database'
|
7
7
|
include_context 'seeds'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
context 'typed projections' do
|
10
|
+
before do
|
11
|
+
configuration.relation(:books) do
|
12
|
+
schema(infer: true)
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
view(:index) do
|
15
|
+
schema { project(:id, :title, :created_at) }
|
16
|
+
relation { order(:title) }
|
17
|
+
end
|
16
18
|
end
|
19
|
+
|
20
|
+
rom.relations[:books].insert(title: 'Hello World', created_at: Time.now)
|
17
21
|
end
|
18
22
|
|
19
|
-
|
23
|
+
it 'loads typed structs' do
|
24
|
+
book = repo.books.index.first
|
25
|
+
|
26
|
+
expect(book).to be_kind_of(Dry::Struct)
|
27
|
+
|
28
|
+
expect(book.id).to be_kind_of(Integer)
|
29
|
+
expect(book.title).to eql('Hello World')
|
30
|
+
expect(book.created_at).to be_kind_of(Time)
|
31
|
+
end
|
20
32
|
end
|
21
33
|
|
22
|
-
|
23
|
-
|
34
|
+
context 'read-write type coercions' do
|
35
|
+
before do
|
36
|
+
configuration.relation(:books) do
|
37
|
+
schema(infer: true) do
|
38
|
+
attribute :title,
|
39
|
+
ROM::Types::Coercible::String.meta(
|
40
|
+
read: ROM::Types::Symbol.constructor(&:to_sym)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
configuration.commands(:books) do
|
46
|
+
define(:create) { result(:one) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'loads typed structs' do
|
51
|
+
created_book = repo.create(title: :'Hello World', created_at: Time.now)
|
24
52
|
|
25
|
-
|
53
|
+
expect(created_book).to be_kind_of(Dry::Struct)
|
26
54
|
|
27
|
-
|
28
|
-
|
29
|
-
|
55
|
+
expect(created_book.id).to be_kind_of(Integer)
|
56
|
+
expect(created_book.title).to eql(:'Hello World')
|
57
|
+
expect(created_book.created_at).to be_kind_of(Time)
|
58
|
+
|
59
|
+
book = repo.books.to_a.first
|
60
|
+
|
61
|
+
expect(book).to eql(created_book)
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.6.10
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: Repository abstraction for rom-rb
|