origin 2.1.1 → 2.2.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: 67afcab5f2627b154dbe6dedf6dbec074115e13f
4
- data.tar.gz: d53486d4fc1c1f543ce11523f0cccad6fb7944c6
3
+ metadata.gz: 0b18444ac7a70fe5f8b4ffb6cfc3561007018adb
4
+ data.tar.gz: df43b397e418dbe94ae4435252f73490d4ba8d2a
5
5
  SHA512:
6
- metadata.gz: 19f0fc16f76f16408f3d73880db1c15af02877559772b456e0b4cecd5dd05589940e499fc6a83322e06ce73a8d3c347f33517e967b6f3ece6957e39eb4011190
7
- data.tar.gz: 6b0e86e432fbd806d3ea038314948f8401fe5612d7e18b6e8edc0bafdd64d0283930ed50cd702af4fe7b9d2cab79d0730592eb25330298cdf837fbad1a22a877
6
+ metadata.gz: 29d9b33aba3b290a0112d0d8b02d446d881da38de59c612f0da08aede046ed695bffd6b03ff1bf1a6db01c6dd7b146078c538e05f3caedd6118314333816f6e5
7
+ data.tar.gz: 6e917ba1a28baf310037fac320b9db36ba54aa6ba69868183db13eb30e02db042775ed33ef36a317e209ab7089c3cd31e5dea9abce09f2885755b3fafa85b8b3
@@ -1,12 +1,5 @@
1
1
  # Overview
2
2
 
3
- ## 2.1.1
4
-
5
- ### Resolved Issues
6
-
7
- * Fixed integer evolution when a trailing "." existed but no fraction provided,
8
- ie "7.1"
9
-
10
3
  ## 2.1.0
11
4
 
12
5
  ### New Features
@@ -267,6 +267,42 @@ module Origin
267
267
  end
268
268
  end
269
269
 
270
+ # Associate a comment with the query.
271
+ #
272
+ # @example Add a comment.
273
+ # optional.comment('slow query')
274
+ #
275
+ # @note Set profilingLevel to 2 and the comment will be logged in the profile
276
+ # collection along with the query.
277
+ #
278
+ # @param [ String ] comment The comment to be associated with the query.
279
+ #
280
+ # @return [ Optional ] The cloned optional.
281
+ #
282
+ # @since 2.2.0
283
+ def comment(comment = nil)
284
+ clone.tap do |query|
285
+ query.options.store(:comment, comment)
286
+ end
287
+ end
288
+
289
+ # Set the cursor type.
290
+ #
291
+ # @example Set the cursor type.
292
+ # optional.cursor_type(:tailable)
293
+ # optional.cursor_type(:tailable_await)
294
+ #
295
+ # @note The cursor can be type :tailable or :tailable_await.
296
+ #
297
+ # @param [ Symbol ] type The type of cursor to create.
298
+ #
299
+ # @return [ Optional ] The cloned optional.
300
+ #
301
+ # @since 2.2.0
302
+ def cursor_type(type)
303
+ clone.tap { |query| query.options.store(:cursor_type, type) }
304
+ end
305
+
270
306
  private
271
307
 
272
308
  # Add a single sort option.
@@ -284,7 +320,7 @@ module Origin
284
320
  #
285
321
  # @since 1.0.0
286
322
  def add_sort_option(options, field, direction)
287
- if driver == :mongo
323
+ if driver == :mongo1x
288
324
  sorting = (options[:sort] || []).dup
289
325
  sorting.push([ field, direction ])
290
326
  options.store(:sort, sorting)
@@ -58,7 +58,7 @@ module Origin
58
58
  # @param [ Symbol ] driver The driver being used.
59
59
  #
60
60
  # @since 1.0.0
61
- def initialize(aliases = {}, serializers = {}, driver = :moped)
61
+ def initialize(aliases = {}, serializers = {}, driver = :mongo)
62
62
  @aliases, @driver, @serializers = aliases, driver.to_sym, serializers
63
63
  @options = Options.new(aliases, serializers)
64
64
  @selector = Selector.new(aliases, serializers)
@@ -491,6 +491,32 @@ module Origin
491
491
  ::Integer.evolve(value)
492
492
  end
493
493
 
494
+ # Construct a text search selector.
495
+ #
496
+ # @example Construct a text search selector.
497
+ # selectable.text_search("testing")
498
+ #
499
+ # @example Construct a text search selector with options.
500
+ # selectable.text_search("testing", :$language => "fr")
501
+ #
502
+ # @param [ String, Symbol ] terms A string of terms that MongoDB parses
503
+ # and uses to query the text index.
504
+ # @param [ Hash ] opts Text search options. See MongoDB documentation
505
+ # for options.
506
+ #
507
+ # @return [ Selectable ] The cloned selectable.
508
+ #
509
+ # @since 2.2.0
510
+ def text_search(terms, opts = nil)
511
+ clone.tap do |query|
512
+ if terms
513
+ criterion = { :$text => { :$search => terms } }
514
+ criterion[:$text].merge!(opts) if opts
515
+ query.selector = criterion
516
+ end
517
+ end
518
+ end
519
+
494
520
  # This is the general entry point for most MongoDB queries. This either
495
521
  # creates a standard field: value selection, and expanded selection with
496
522
  # the use of hash methods, or a $where selection if a string is provided.
@@ -18,7 +18,9 @@ module Origin
18
18
  def merge!(other)
19
19
  other.each_pair do |key, value|
20
20
  if value.is_a?(Hash) && self[key.to_s].is_a?(Hash)
21
- value = self[key.to_s].merge(value)
21
+ value = self[key.to_s].merge(value) do |_key, old_val, new_val|
22
+ multi_value?(_key) ? (old_val + new_val).uniq : new_val
23
+ end
22
24
  end
23
25
  if multi_selection?(key)
24
26
  value = (self[key.to_s] || []).concat(value)
@@ -154,7 +156,7 @@ module Origin
154
156
  end
155
157
  end
156
158
 
157
- # Determines if the selection is a multi-select, like an $and or $or
159
+ # Determines if the selection is a multi-select, like an $and or $or or $nor
158
160
  # selection.
159
161
  #
160
162
  # @api private
@@ -168,7 +170,23 @@ module Origin
168
170
  #
169
171
  # @since 1.0.0
170
172
  def multi_selection?(key)
171
- key =~ /\$and|\$or/
173
+ key =~ /\$and|\$or|\$nor/
174
+ end
175
+
176
+ # Determines if the selection operator takes a list. Returns true for $in and $nin.
177
+ #
178
+ # @api private
179
+ #
180
+ # @example Does the selection operator take multiple values?
181
+ # selector.multi_value?("$nin")
182
+ #
183
+ # @param [ String ] key The key to check.
184
+ #
185
+ # @return [ true, false ] If the key is $in or $nin.
186
+ #
187
+ # @since 2.1.1
188
+ def multi_value?(key)
189
+ key =~ /\$nin|\$in/
172
190
  end
173
191
  end
174
192
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Origin
3
- VERSION = "2.1.1"
3
+ VERSION = "2.2.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Origin is a simple DSL for generating MongoDB selectors and options
14
14
  email:
@@ -71,8 +71,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: 1.3.6
72
72
  requirements: []
73
73
  rubyforge_project: origin
74
- rubygems_version: 2.2.1
74
+ rubygems_version: 2.4.6
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Simple DSL for MongoDB query generation
78
78
  test_files: []
79
+ has_rdoc: