rom 3.2.3 → 3.3.0

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: 0f727af1309d22c607fa43b3c26345749233dbef
4
- data.tar.gz: 7a1d5142394e77da212457c8d656ca2d9d632759
3
+ metadata.gz: 1a76e7a694c3096111424b115fe238285183a2e8
4
+ data.tar.gz: 27559d733a9470cbdc93878625b5c0157ec56964
5
5
  SHA512:
6
- metadata.gz: 2b915a97368fd38abcaab1160d28bbc4aa5b218415fc58605fc8517d6149ca21f7ae749b383a5733e00d937b362dde5a0e61e3acfe65d98e0c847a6632982682
7
- data.tar.gz: ca3d98f9a4446d108bc029aa6ee8da32a0185b52a6a2dd4ed007abf702fb7cf1a8d742b300db5d796ba2e141b3f90bc0608182198f7d64c3e4cfb90265d5c4a4
6
+ metadata.gz: 27fcabc336dde4cee458d52311b3f2eed5934bc5a12055f339a0e7051e14526d14a17fc4aa2d581aa4ccf58ae4fc83357ae87689a328e4b4c2b9c530a5ffa2f6
7
+ data.tar.gz: bf6a440ce37fe9953752c8781737361b1cae014afd78d808db2468a71de68c9e0af7bb7d6920227ce4317a25e5bba86ae64b0f1150d20eccf05416f94089108f
@@ -1,3 +1,9 @@
1
+ # v3.3.0 2017-07-05
2
+
3
+ This release only adds deprecation warnings in preparation for rom 4.0 release.
4
+
5
+ [Compare v3.2.3...v3.3.0](https://github.com/rom-rb/rom/compare/v3.2.3...v3.3.0)
6
+
1
7
  # v3.2.3 2017-05-31
2
8
 
3
9
  ## Added
@@ -1,4 +1,6 @@
1
+ require 'dry/core/deprecations'
1
2
  require 'dry/core/inflector'
3
+
2
4
  require 'rom/registry'
3
5
 
4
6
  module ROM
@@ -10,6 +12,14 @@ module ROM
10
12
  if key?(key) || key?(singularize(key))
11
13
  yield(self[key])
12
14
  else
15
+ msg = <<-STR
16
+ Key inference will be removed in rom 4.0. You need to define :#{key} association.
17
+ => Called at:
18
+ #{caller.join("\n")}
19
+ STR
20
+
21
+ Dry::Core::Deprecations.warn(msg)
22
+
13
23
  false
14
24
  end
15
25
  end
@@ -29,6 +29,7 @@ module ROM
29
29
  include Pipeline::Operator
30
30
 
31
31
  extend Dry::Core::ClassAttributes
32
+ extend Dry::Core::Deprecations[:rom]
32
33
  extend ClassInterface
33
34
 
34
35
  # @!method self.adapter
@@ -316,7 +317,12 @@ module ROM
316
317
  self.class.build(relation, **options, curry_args: args)
317
318
  end
318
319
  end
319
- alias_method :with, :curry
320
+
321
+ # @api public
322
+ def with(*args)
323
+ self.class.warn "Command#with will change its behavior in rom 4.0. Use Command#curry instead.\n\n#{caller[0..5].join("\n")}"
324
+ curry(*args)
325
+ end
320
326
 
321
327
  # Compose this command with other commands
322
328
  #
@@ -1,3 +1,5 @@
1
+ require 'dry/core/deprecations'
2
+
1
3
  require 'rom/types'
2
4
  require 'rom/commands/result'
3
5
 
@@ -7,6 +9,8 @@ module ROM
7
9
  # @api public
8
10
  class CommandRegistry
9
11
  extend Initializer
12
+ extend Dry::Core::Deprecations[:rom]
13
+
10
14
  include Commands
11
15
 
12
16
  CommandNotFoundError = Class.new(KeyError)
@@ -43,6 +47,8 @@ module ROM
43
47
  #
44
48
  # @api public
45
49
  def try(&block)
50
+ self.class.warn "CommandRegistry#try will be removed in rom 4.0"
51
+
46
52
  response = block.call
47
53
 
48
54
  if response.is_a?(Command) || response.is_a?(Composite)
@@ -44,7 +44,7 @@ module ROM
44
44
  tuple_path = Array[*path] << key
45
45
  input_proc = InputEvaluator.build(tuple_path, nodes)
46
46
 
47
- command = command.with(input_proc, opts)
47
+ command = command.curry(input_proc, opts)
48
48
 
49
49
  if nodes
50
50
  if nodes.all? { |node| node.is_a?(Array) }
@@ -21,7 +21,7 @@ module ROM
21
21
  def relation(name, options = EMPTY_HASH, &block)
22
22
  klass_opts = { adapter: default_adapter }.merge(options)
23
23
  klass = Relation.build_class(name, klass_opts)
24
- klass.register_as(name)
24
+ klass.register_as(name, deprecation: false)
25
25
  klass.class_eval(&block) if block
26
26
  register_relation(klass)
27
27
  klass
@@ -18,7 +18,7 @@ module ROM
18
18
 
19
19
  Dry::Core::ClassBuilder.new(name: class_name, parent: ROM::Relation[adapter]).call do |klass|
20
20
  klass.gateway(options.fetch(:gateway, :default))
21
- klass.dataset(name)
21
+ klass.dataset(name, deprecation: false)
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,5 @@
1
+ require 'dry/core/deprecations'
2
+
1
3
  require 'rom/relation/loaded'
2
4
  require 'rom/commands/graph'
3
5
  require 'rom/commands/graph/builder'
@@ -97,6 +99,8 @@ module ROM
97
99
  #
98
100
  # @api public
99
101
  class Container
102
+ extend Dry::Core::Deprecations[:rom]
103
+
100
104
  include Dry::Equalizer(:gateways, :relations, :mappers, :commands)
101
105
 
102
106
  # @!attribute [r] gateways
@@ -150,6 +154,8 @@ module ROM
150
154
  #
151
155
  # @api public
152
156
  def relation(name, &block)
157
+ Dry::Core::Deprecations.warn("#{self.class}#relation is deprecated and will be removed in 4.0\n\n#{caller[0..5].join("\n")}")
158
+
153
159
  relation =
154
160
  if block
155
161
  yield(relations[name])
@@ -184,6 +190,8 @@ module ROM
184
190
  #
185
191
  # @api public
186
192
  def command(options = nil)
193
+ Dry::Core::Deprecations.warn("#{self.class}#command is deprecated and will be removed in 4.0\n\n#{caller[0..5].join("\n")}")
194
+
187
195
  case options
188
196
  when Symbol
189
197
  name = options
@@ -40,7 +40,21 @@ module ROM
40
40
  [self, *names.map { |name| mappers[name] }]
41
41
  .reduce { |a, e| composite_class.new(a, e) }
42
42
  end
43
- alias_method :as, :map_with
43
+
44
+ # @api public
45
+ def as(*names)
46
+ new_meth = names[0].is_a?(Class) ? 'map_to' : 'map_with'
47
+
48
+ msg = <<-STR
49
+ Relation#as will change behavior in 4.0. Use `#{new_meth}` instead
50
+ => Called at:
51
+ #{caller.join("\n")}
52
+ STR
53
+
54
+ Dry::Core::Deprecations.warn(msg)
55
+
56
+ map_with(*names)
57
+ end
44
58
 
45
59
  # Forwards messages to the left side of a pipeline
46
60
  #
@@ -1,6 +1,7 @@
1
1
  require 'set'
2
2
 
3
3
  require 'dry/core/inflector'
4
+ require 'dry/core/deprecations'
4
5
  require 'dry/core/constants'
5
6
 
6
7
  require 'rom/auto_curry'
@@ -13,6 +14,8 @@ module ROM
13
14
  class Relation
14
15
  # @api public
15
16
  module ClassInterface
17
+ extend Dry::Core::Deprecations[:rom]
18
+
16
19
  include Dry::Core::Constants
17
20
 
18
21
  # Register adapter relation subclasses during setup phase
@@ -76,9 +79,15 @@ module ROM
76
79
  # @param [Symbol] value The name of the dataset
77
80
  #
78
81
  # @api public
79
- def self.dataset(value = Undefined, &block)
80
- dataset_proc(block) if block
81
- super
82
+ def self.dataset(*args, deprecation: true, &block)
83
+ if block
84
+ dataset_proc(block)
85
+ elsif args.size > 0
86
+ if deprecation
87
+ warn("Relation.dataset is deprecated in favor of schema settings\n\n#{caller[0..5].join("\n")}")
88
+ end
89
+ end
90
+ super(*args)
82
91
  end
83
92
 
84
93
  # Set or get name under which a relation will be registered
@@ -88,8 +97,12 @@ module ROM
88
97
  # @return [Symbol]
89
98
  #
90
99
  # @api public
91
- def self.register_as(value = Undefined)
92
- if value == Undefined
100
+ def self.register_as(*args, deprecation: true)
101
+ if deprecation && args.size > 0
102
+ warn("Relation.register_as is deprecated in favor of schema settings\n\n#{caller[0..5].join("\n")}")
103
+ end
104
+
105
+ if args.empty?
93
106
  return @register_as if defined?(@register_as)
94
107
 
95
108
  super_val = super()
@@ -100,7 +113,7 @@ module ROM
100
113
  super_val == dataset ? default_name : super_val
101
114
  end
102
115
  else
103
- super
116
+ super(*args)
104
117
  end
105
118
  end
106
119
 
@@ -158,12 +171,12 @@ module ROM
158
171
  if defined?(@schema)
159
172
  @schema
160
173
  elsif block || infer
161
- self.dataset(dataset) if dataset
174
+ self.dataset(dataset, deprecation: false) if dataset
162
175
 
163
176
  if as
164
- self.register_as(as)
177
+ self.register_as(as, deprecation: false)
165
178
  else
166
- self.register_as(self.dataset) unless register_as
179
+ self.register_as(self.dataset, deprecation: false) unless register_as
167
180
  end
168
181
 
169
182
  name = Name[register_as, self.dataset]
@@ -120,7 +120,7 @@ module ROM
120
120
  if infer_relation?(gateway, name)
121
121
  klass = ROM::ConfigurationDSL::Relation.build_class(name, adapter: adapter_for(gateway))
122
122
  klass.gateway(gateway)
123
- klass.dataset(name)
123
+ klass.dataset(name, deprecation: false)
124
124
  @relation_classes << klass
125
125
  else
126
126
  next
@@ -58,7 +58,7 @@ module ROM
58
58
  plugin.apply_to(klass)
59
59
  end
60
60
 
61
- dataset = gateway.dataset(klass.dataset).instance_exec(klass, &ds_proc)
61
+ dataset = gateway.dataset(klass.schema.name.dataset).instance_exec(klass, &ds_proc)
62
62
 
63
63
  options = { __registry__: registry, schema: schema.with(relations: registry), **plugin_options }
64
64
 
@@ -1,3 +1,3 @@
1
1
  module ROM
2
- VERSION = '3.2.3'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
@@ -79,27 +79,28 @@ RSpec.describe ROM::Relation::Graph do
79
79
 
80
80
  describe '#call' do
81
81
  it 'materializes relations' do
82
- expect(graph.call).to match_array([
83
- users_relation,
84
- [tasks_relation]
85
- ])
82
+ root, nodes = graph.call.to_a
83
+
84
+ expect(root.to_a).to eql(users_relation.to_a)
85
+ expect(nodes.flatten).to eql(tasks_relation.to_a)
86
86
  end
87
87
  end
88
88
 
89
89
  describe '#to_a' do
90
90
  it 'coerces to an array' do
91
- expect(graph).to match_array([
92
- users_relation.to_a,
93
- [tasks_relation.for_users(users_relation).to_a]
94
- ])
91
+ root, nodes = graph.to_a
92
+
93
+ expect(root.to_a).to eql(users_relation.to_a)
94
+ expect(nodes.flatten).to eql(tasks_relation.for_users(users_relation).to_a)
95
95
  end
96
96
 
97
97
  it 'returns empty arrays when left was empty' do
98
98
  graph = ROM::Relation::Graph.new(users_relation.by_name('Not here'), [tasks_relation.for_users])
99
99
 
100
- expect(graph).to match_array([
101
- [], [ROM::Relation::Loaded.new(tasks_relation.for_users, [])]
102
- ])
100
+ root, nodes = graph.to_a
101
+
102
+ expect(root).to be_empty
103
+ expect(nodes.flatten).to be_empty
103
104
  end
104
105
  end
105
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
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-05-31 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  version: '0'
402
402
  requirements: []
403
403
  rubyforge_project:
404
- rubygems_version: 2.6.11
404
+ rubygems_version: 2.6.12
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Ruby Object Mapper