jmongo 1.1.3 → 1.1.4

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.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jmongo'
3
- s.version = '1.1.3'
4
- s.date = '2011-10-18'
3
+ s.version = '1.1.4'
4
+ s.date = '2011-10-19'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Chuck Remes","Guy Boertje", "Lee Henson"]
7
7
  s.email = ["cremes@mac.com", "guyboertje@gmail.com", "lee.m.henson@gmail.com"]
@@ -38,30 +38,31 @@ module Mongo
38
38
  _limit options[:limit]
39
39
  _sort options[:order]
40
40
  _batch_size options[:batch_size]
41
- @hint = options[:hint]
41
+ _hint options[:hint]
42
42
  @snapshot = options[:snapshot]
43
43
  @explain = options[:explain]
44
44
  @socket = options[:socket]
45
45
  @timeout = options.fetch(:timeout, true)
46
46
  @transformer = options[:transformer]
47
47
  @tailable = options.fetch(:tailable, false)
48
- @await_data = @tailable ? options[:await_data] : nil
49
- @next_timeout = NEXT_DOCUMENT_TIMEOUT
50
- @is_poison_function = nil
51
- case @await_data
52
- when Hash
53
- @poison_doc = @await_data.fetch(:poison_doc, default_poison_doc)
54
- @is_poison_function = @await_data[:is_poison_function]
55
- @next_timeout = @await_data.fetch(:next_timeout, NEXT_DOCUMENT_TIMEOUT).to_f
56
- when Numeric
57
- @poison_doc = default_poison_doc
58
- @next_timeout = @await_data.to_f
59
- when TrueClass
48
+ @do_tailable_timeout = false
49
+
50
+ if @tailable
51
+ @await_data = options.fetch(:await_data, true)
52
+ @next_timeout = NEXT_DOCUMENT_TIMEOUT
53
+ @is_poison_function = nil
60
54
  @poison_doc = default_poison_doc
61
- else
62
- @poison_doc = nil
55
+ @do_tailable_timeout = true
56
+ case @await_data
57
+ when Hash
58
+ @poison_doc = @await_data.fetch(:poison_doc, default_poison_doc)
59
+ @is_poison_function = @await_data[:is_poison_function]
60
+ @next_timeout = @await_data.fetch(:next_timeout, NEXT_DOCUMENT_TIMEOUT).to_f
61
+ when Numeric
62
+ @next_timeout = @await_data.to_f
63
+ end
64
+ @timeout_thread = TimeoutThread.new(@collection, @poison_doc, @next_timeout)
63
65
  end
64
- @timeout_thread = TimeoutThread.new(@collection, @poison_doc, @next_timeout) if @tailable && @poison_doc
65
66
 
66
67
  @full_collection_name = "#{@collection.db.name}.#{@collection.name}"
67
68
 
@@ -155,6 +156,11 @@ module Mongo
155
156
  end
156
157
  end
157
158
 
159
+ def _hint(hint = nil)
160
+ return if hint.nil?
161
+ @hint = to_dbobject(hint)
162
+ end
163
+
158
164
  def _batch_size(size=nil)
159
165
  return if size.nil?
160
166
  raise ArgumentError, "batch_size requires an integer" unless size.is_a? Integer
@@ -271,9 +277,9 @@ module Mongo
271
277
  end
272
278
 
273
279
  def __next
274
- @timeout_thread.trigger if @tailable
275
- doc = from_dbobject(@j_cursor.next)
276
- if @tailable
280
+ if @do_tailable_timeout
281
+ @timeout_thread.trigger
282
+ doc = from_dbobject(@j_cursor.next)
277
283
  if poisoned?(doc)
278
284
  nil
279
285
  else
@@ -281,7 +287,7 @@ module Mongo
281
287
  doc
282
288
  end
283
289
  else
284
- doc
290
+ from_dbobject(@j_cursor.next)
285
291
  end
286
292
  end
287
293
 
@@ -324,11 +330,8 @@ module Mongo
324
330
  @j_cursor = @j_cursor.hint(@hint) if @hint
325
331
  @j_cursor = @j_cursor.snapshot if @snapshot
326
332
  @j_cursor = @j_cursor.batchSize(@batch_size) if @batch_size && @batch_size > 0
327
- opts_bf = @j_cursor.options
328
- opts_bf = mask_option(opts_bf, JMongo::Bytes::QUERYOPTION_NOTIMEOUT, !@timeout)
329
- opts_bf = mask_option(opts_bf, JMongo::Bytes::QUERYOPTION_TAILABLE, !!@tailable)
330
- opts_bf = mask_option(opts_bf, JMongo::Bytes::QUERYOPTION_AWAITDATA, !!@await_data)
331
- @j_cursor.options = opts_bf
333
+ @j_cursor = @j_cursor.addOption JMongo::Bytes::QUERYOPTION_NOTIMEOUT unless @timeout
334
+ @j_cursor = @j_cursor.addOption JMongo::Bytes::QUERYOPTION_TAILABLE if @tailable
332
335
  end
333
336
 
334
337
  self
@@ -1,3 +1,3 @@
1
1
  module Mongo
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.4'
3
3
  end
@@ -904,8 +904,17 @@ describe "Collection" do
904
904
  tail.next_document
905
905
  end
906
906
  end
907
-
907
+
908
908
  it "should find using a tailable cursor" do
909
+ tail = Mongo::Cursor.new(@capped, :timeout => false, :tailable => true, :order => [['$natural', 1]])
910
+ 1000.times do
911
+ assert tail.next_document
912
+ end
913
+ assert true, tail.has_next?
914
+ assert_nil tail.next_document
915
+ end
916
+
917
+ it "should find using a tailable cursor with await_data" do
909
918
  tail = Mongo::Cursor.new(@capped, :timeout => false, :tailable => true, :await_data => true, :order => [['$natural', 1]])
910
919
  1000.times do
911
920
  assert tail.next_document
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jmongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-18 00:00:00.000000000 Z
14
+ date: 2011-10-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: require_all
18
- requirement: &10865120 !ruby/object:Gem::Requirement
18
+ requirement: &15446080 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '1.2'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *10865120
26
+ version_requirements: *15446080
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: awesome_print
29
- requirement: &10864640 !ruby/object:Gem::Requirement
29
+ requirement: &15445600 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.4'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *10864640
37
+ version_requirements: *15445600
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: fuubar
40
- requirement: &10864180 !ruby/object:Gem::Requirement
40
+ requirement: &15444720 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0.0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *10864180
48
+ version_requirements: *15444720
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rspec
51
- requirement: &10863300 !ruby/object:Gem::Requirement
51
+ requirement: &15444260 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '2.6'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *10863300
59
+ version_requirements: *15444260
60
60
  description: Thin jruby wrapper around Mongo Java Driver
61
61
  email:
62
62
  - cremes@mac.com