rom-repository 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: e6b048642fe2a94616f34fd16f97f14c66ef9d09
4
- data.tar.gz: f5d68af52ed2f23e95f0b374c6dd8ec6c0fba51a
3
+ metadata.gz: 3d225169d8e6601c42a19f9e8504363fb766b49b
4
+ data.tar.gz: 2277ca38edb2706b648fabbd30da68cbbb9adb3c
5
5
  SHA512:
6
- metadata.gz: 54fdd9a7b04880a7e3d3b9cdcaaf4794921bbfc9fe1fe95a6807b18e9c5d025cc295c86f8f4afb7f43a25939ef04bb665dfeeef84c768eb6b2d4037619b826d5
7
- data.tar.gz: d4d7fe97225798174a5d7feee644f76188f321066501d2c8b4683dcc15d37b8fad1c1aa6fd0dd186962a3094a4ee9d486c29788d0047ffe830b8b7cc1e6dc2e1
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.1...v1.0.1](https://github.com/rom-rb/rom-repository/compare/v1.0.0...v1.0.1)
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,3 +1,4 @@
1
+ require "bundler/gem_tasks"
1
2
  require "rspec/core/rake_task"
2
3
 
3
4
  RSpec::Core::RakeTask.new(:spec)
@@ -50,7 +50,7 @@ module ROM
50
50
  end
51
51
 
52
52
  def visit_attribute(attr)
53
- [attr.aliased? && !attr.wrapped? ? attr.alias : attr.name, attr.type]
53
+ [attr.aliased? && !attr.wrapped? ? attr.alias : attr.name, attr.to_read_type]
54
54
  end
55
55
 
56
56
  def build_class(name, parent, &block)
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  class Repository
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.0.2'.freeze
4
4
  end
5
5
  end
@@ -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
- before do
10
- configuration.relation(:books) do
11
- schema(infer: true)
9
+ context 'typed projections' do
10
+ before do
11
+ configuration.relation(:books) do
12
+ schema(infer: true)
12
13
 
13
- view(:index) do
14
- schema { project(:id, :title, :created_at) }
15
- relation { order(:title) }
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
- rom.relations[:books].insert(title: 'Hello World', created_at: Time.now)
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
- it 'loads typed structs' do
23
- book = repo.books.index.first
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
- expect(book).to be_kind_of(Dry::Struct)
53
+ expect(created_book).to be_kind_of(Dry::Struct)
26
54
 
27
- expect(book.id).to be_kind_of(Integer)
28
- expect(book.title).to eql('Hello World')
29
- expect(book.created_at).to be_kind_of(Time)
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
@@ -53,4 +53,6 @@ RSpec.configure do |config|
53
53
  end
54
54
 
55
55
  config.include(MapperRegistry)
56
+
57
+ config.disable_monkey_patching!
56
58
  end
@@ -7,7 +7,7 @@ RSpec.describe 'struct builder', '#call' do
7
7
  aliased?: false,
8
8
  wrapped?: false,
9
9
  foreign_key?: false,
10
- type: ROM::Types.const_get(type),
10
+ to_read_type: ROM::Types.const_get(type),
11
11
  **opts
12
12
  )
13
13
  end
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.1
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-01-31 00:00:00.000000000 Z
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.5.1
191
+ rubygems_version: 2.6.10
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Repository abstraction for rom-rb