mongo 1.8.4 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +6 -14
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +2 -0
  5. data/VERSION +1 -1
  6. data/lib/mongo.rb +11 -9
  7. data/lib/mongo/collection.rb +26 -19
  8. data/lib/mongo/cursor.rb +7 -2
  9. data/lib/mongo/db.rb +1 -1
  10. data/lib/mongo/mongo_client.rb +1 -1
  11. data/lib/mongo/mongo_replica_set_client.rb +2 -3
  12. data/lib/mongo/mongo_sharded_client.rb +1 -2
  13. data/lib/mongo/util/node.rb +12 -14
  14. data/lib/mongo/util/pool.rb +1 -1
  15. data/lib/mongo/util/pool_manager.rb +13 -15
  16. data/lib/mongo/util/sharding_pool_manager.rb +5 -2
  17. data/lib/mongo/util/support.rb +14 -0
  18. data/mongo.gemspec +7 -3
  19. data/test/functional/authentication_test.rb +21 -0
  20. data/test/functional/collection_test.rb +0 -1
  21. data/test/functional/connection_test.rb +1 -1
  22. data/test/functional/db_test.rb +1 -56
  23. data/test/functional/support_test.rb +30 -0
  24. data/test/replica_set/authentication_test.rb +23 -0
  25. data/test/replica_set/max_values_test.rb +61 -0
  26. data/test/sharded_cluster/basic_test.rb +18 -0
  27. data/test/shared/authentication.rb +49 -0
  28. data/test/tools/mongo_config.rb +21 -26
  29. data/test/unit/node_test.rb +3 -0
  30. data/test/unit/pool_manager_test.rb +3 -1
  31. data/test/unit/read_test.rb +4 -0
  32. data/test/unit/sharding_pool_manager_test.rb +88 -0
  33. metadata +38 -69
  34. metadata.gz.sig +0 -0
  35. data/test/auxillary/1.4_feature_test.rb +0 -165
  36. data/test/auxillary/authentication_test.rb +0 -74
  37. data/test/auxillary/autoreconnect_test.rb +0 -39
  38. data/test/auxillary/fork_test.rb +0 -28
  39. data/test/auxillary/pool_reuse_test.rb +0 -65
  40. data/test/auxillary/repl_set_auth_test.rb +0 -69
  41. data/test/auxillary/slave_connection_test.rb +0 -37
  42. data/test/auxillary/threaded_authentication_test.rb +0 -99
  43. data/test/bson/binary_test.rb +0 -13
  44. data/test/bson/bson_test.rb +0 -762
  45. data/test/bson/byte_buffer_test.rb +0 -215
  46. data/test/bson/hash_with_indifferent_access_test.rb +0 -48
  47. data/test/bson/json_test.rb +0 -16
  48. data/test/bson/object_id_test.rb +0 -153
  49. data/test/bson/ordered_hash_test.rb +0 -247
  50. data/test/bson/timestamp_test.rb +0 -51
  51. data/test/tools/auth_repl_set_manager.rb +0 -14
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -12,35 +12,28 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain:
15
- - !binary |-
16
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURPRENDQWlDZ0F3SUJB
17
- Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJDTVJRd0VnWURWUVFEREF0a2Nt
18
- bDIKWlhJdGNuVmllVEVWTUJNR0NnbVNKb21UOGl4a0FSa1dCVEV3WjJWdU1S
19
- TXdFUVlLQ1pJbWlaUHlMR1FCR1JZRApZMjl0TUI0WERURXpNREl3TVRFME1U
20
- RXpOMW9YRFRFME1ESXdNVEUwTVRFek4xb3dRakVVTUJJR0ExVUVBd3dMClpI
21
- SnBkbVZ5TFhKMVlua3hGVEFUQmdvSmtpYUprL0lzWkFFWkZnVXhNR2RsYmpF
22
- VE1CRUdDZ21TSm9tVDhpeGsKQVJrV0EyTnZiVENDQVNJd0RRWUpLb1pJaHZj
23
- TkFRRUJCUUFEZ2dFUEFEQ0NBUW9DZ2dFQkFORmRTQWE4ZlJtMQpiQU05emE2
24
- WjBmQUg0ZzAyYnFNMU5Hbnc4ekpRckUvUEZyRmZZNklGQ1QyQ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v648IF3MR1tCQumVL0XcYMvZcxBj
31
+ a/p+8DomWTQqUdNbNoGywwjtVBWfDdwFV8Po1XcN/AtpILOJQd9J77INIGGCHxZo
32
+ 6SOHHaNknlE9H0w6q0SVxZKZI8/+2c447V0NrHIw1Qhe0tAGJ9V1u3ky8gyxe0SM
33
+ 8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
34
+ RNTuXsVG5NDACo7Q
35
+ -----END CERTIFICATE-----
36
+ date: 2013-04-11 00:00:00.000000000 Z
44
37
  dependencies:
45
38
  - !ruby/object:Gem::Dependency
46
39
  name: bson
@@ -48,14 +41,14 @@ dependencies:
48
41
  requirements:
49
42
  - - ~>
50
43
  - !ruby/object:Gem::Version
51
- version: 1.8.4
44
+ version: 1.8.5
52
45
  type: :runtime
53
46
  prerelease: false
54
47
  version_requirements: !ruby/object:Gem::Requirement
55
48
  requirements:
56
49
  - - ~>
57
50
  - !ruby/object:Gem::Version
58
- version: 1.8.4
51
+ version: 1.8.5
59
52
  description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
60
53
  email: mongodb-dev@googlegroups.com
61
54
  executables:
@@ -100,22 +93,7 @@ files:
100
93
  - lib/mongo/util/unix_socket.rb
101
94
  - lib/mongo/util/uri_parser.rb
102
95
  - lib/mongo/util/write_concern.rb
103
- - test/auxillary/1.4_feature_test.rb
104
- - test/auxillary/authentication_test.rb
105
- - test/auxillary/autoreconnect_test.rb
106
- - test/auxillary/fork_test.rb
107
- - test/auxillary/pool_reuse_test.rb
108
- - test/auxillary/repl_set_auth_test.rb
109
- - test/auxillary/slave_connection_test.rb
110
- - test/auxillary/threaded_authentication_test.rb
111
- - test/bson/binary_test.rb
112
- - test/bson/bson_test.rb
113
- - test/bson/byte_buffer_test.rb
114
- - test/bson/hash_with_indifferent_access_test.rb
115
- - test/bson/json_test.rb
116
- - test/bson/object_id_test.rb
117
- - test/bson/ordered_hash_test.rb
118
- - test/bson/timestamp_test.rb
96
+ - test/functional/authentication_test.rb
119
97
  - test/functional/collection_test.rb
120
98
  - test/functional/connection_test.rb
121
99
  - test/functional/conversions_test.rb
@@ -135,6 +113,7 @@ files:
135
113
  - test/functional/timeout_test.rb
136
114
  - test/functional/uri_test.rb
137
115
  - test/functional/write_concern_test.rb
116
+ - test/replica_set/authentication_test.rb
138
117
  - test/replica_set/basic_test.rb
139
118
  - test/replica_set/client_test.rb
140
119
  - test/replica_set/complex_connect_test.rb
@@ -142,15 +121,16 @@ files:
142
121
  - test/replica_set/count_test.rb
143
122
  - test/replica_set/cursor_test.rb
144
123
  - test/replica_set/insert_test.rb
124
+ - test/replica_set/max_values_test.rb
145
125
  - test/replica_set/pinning_test.rb
146
126
  - test/replica_set/query_test.rb
147
127
  - test/replica_set/read_preference_test.rb
148
128
  - test/replica_set/refresh_test.rb
149
129
  - test/replica_set/replication_ack_test.rb
150
130
  - test/sharded_cluster/basic_test.rb
131
+ - test/shared/authentication.rb
151
132
  - test/test_helper.rb
152
133
  - test/threading/basic_test.rb
153
- - test/tools/auth_repl_set_manager.rb
154
134
  - test/tools/mongo_config.rb
155
135
  - test/tools/mongo_config_test.rb
156
136
  - test/unit/client_test.rb
@@ -165,6 +145,7 @@ files:
165
145
  - test/unit/pool_test.rb
166
146
  - test/unit/read_test.rb
167
147
  - test/unit/safe_test.rb
148
+ - test/unit/sharding_pool_manager_test.rb
168
149
  - test/unit/util_test.rb
169
150
  - test/unit/write_concern_test.rb
170
151
  homepage: http://www.mongodb.org
@@ -177,37 +158,22 @@ require_paths:
177
158
  - lib
178
159
  required_ruby_version: !ruby/object:Gem::Requirement
179
160
  requirements:
180
- - - ! '>='
161
+ - - '>='
181
162
  - !ruby/object:Gem::Version
182
163
  version: '0'
183
164
  required_rubygems_version: !ruby/object:Gem::Requirement
184
165
  requirements:
185
- - - ! '>='
166
+ - - '>='
186
167
  - !ruby/object:Gem::Version
187
168
  version: '0'
188
169
  requirements: []
189
170
  rubyforge_project: mongo
190
- rubygems_version: 2.0.3
171
+ rubygems_version: 2.0.2
191
172
  signing_key:
192
173
  specification_version: 4
193
174
  summary: Ruby driver for MongoDB
194
175
  test_files:
195
- - test/auxillary/1.4_feature_test.rb
196
- - test/auxillary/authentication_test.rb
197
- - test/auxillary/autoreconnect_test.rb
198
- - test/auxillary/fork_test.rb
199
- - test/auxillary/pool_reuse_test.rb
200
- - test/auxillary/repl_set_auth_test.rb
201
- - test/auxillary/slave_connection_test.rb
202
- - test/auxillary/threaded_authentication_test.rb
203
- - test/bson/binary_test.rb
204
- - test/bson/bson_test.rb
205
- - test/bson/byte_buffer_test.rb
206
- - test/bson/hash_with_indifferent_access_test.rb
207
- - test/bson/json_test.rb
208
- - test/bson/object_id_test.rb
209
- - test/bson/ordered_hash_test.rb
210
- - test/bson/timestamp_test.rb
176
+ - test/functional/authentication_test.rb
211
177
  - test/functional/collection_test.rb
212
178
  - test/functional/connection_test.rb
213
179
  - test/functional/conversions_test.rb
@@ -227,6 +193,7 @@ test_files:
227
193
  - test/functional/timeout_test.rb
228
194
  - test/functional/uri_test.rb
229
195
  - test/functional/write_concern_test.rb
196
+ - test/replica_set/authentication_test.rb
230
197
  - test/replica_set/basic_test.rb
231
198
  - test/replica_set/client_test.rb
232
199
  - test/replica_set/complex_connect_test.rb
@@ -234,15 +201,16 @@ test_files:
234
201
  - test/replica_set/count_test.rb
235
202
  - test/replica_set/cursor_test.rb
236
203
  - test/replica_set/insert_test.rb
204
+ - test/replica_set/max_values_test.rb
237
205
  - test/replica_set/pinning_test.rb
238
206
  - test/replica_set/query_test.rb
239
207
  - test/replica_set/read_preference_test.rb
240
208
  - test/replica_set/refresh_test.rb
241
209
  - test/replica_set/replication_ack_test.rb
242
210
  - test/sharded_cluster/basic_test.rb
211
+ - test/shared/authentication.rb
243
212
  - test/test_helper.rb
244
213
  - test/threading/basic_test.rb
245
- - test/tools/auth_repl_set_manager.rb
246
214
  - test/tools/mongo_config.rb
247
215
  - test/tools/mongo_config_test.rb
248
216
  - test/unit/client_test.rb
@@ -257,6 +225,7 @@ test_files:
257
225
  - test/unit/pool_test.rb
258
226
  - test/unit/read_test.rb
259
227
  - test/unit/safe_test.rb
228
+ - test/unit/sharding_pool_manager_test.rb
260
229
  - test/unit/util_test.rb
261
230
  - test/unit/write_concern_test.rb
262
231
  has_rdoc: yard
metadata.gz.sig CHANGED
Binary file
@@ -1,165 +0,0 @@
1
- require 'test_helper'
2
- require 'mongo'
3
-
4
-
5
- # Demonstrate features in MongoDB 1.4
6
- class Features14Test < Test::Unit::TestCase
7
-
8
- context "MongoDB 1.4" do
9
- setup do
10
- @client = MongoClient.new
11
- @db = @client['mongo-ruby-test']
12
- @col = @db['new-features']
13
- end
14
-
15
- teardown do
16
- @col.drop
17
- end
18
-
19
- context "new query operators: " do
20
-
21
- context "$elemMatch: " do
22
- setup do
23
- @col.save({:user => 'bob', :updates => [{:date => Time.now.utc, :body => 'skiing', :n => 1},
24
- {:date => Time.now.utc, :body => 'biking', :n => 2}]})
25
-
26
- @col.save({:user => 'joe', :updates => [{:date => Time.now.utc, :body => 'skiing', :n => 2},
27
- {:date => Time.now.utc, :body => 'biking', :n => 10}]})
28
- end
29
-
30
- should "match a document with a matching object element in an array" do
31
- doc = @col.find_one({"updates" => {"$elemMatch" => {"body" => "skiing", "n" => 2}}})
32
- assert_equal 'joe', doc['user']
33
- end
34
-
35
- should "$elemMatch with a conditional operator" do
36
- doc1 = @col.find_one({"updates" => {"$elemMatch" => {"body" => "biking", "n" => {"$gt" => 5}}}})
37
- assert_equal 'joe', doc1['user']
38
- end
39
-
40
- should "note the difference between $elemMatch and a traditional match" do
41
- doc = @col.find({"updates.body" => "skiing", "updates.n" => 2}).to_a
42
- assert_equal 2, doc.size
43
- end
44
- end
45
-
46
- context "$all with regexes" do
47
- setup do
48
- @col.save({:n => 1, :a => 'whale'})
49
- @col.save({:n => 2, :a => 'snake'})
50
- end
51
-
52
- should "match multiple regexes" do
53
- doc = @col.find({:a => {'$all' => [/ha/, /le/]}}).to_a
54
- assert_equal 1, doc.size
55
- assert_equal 1, doc.first['n']
56
- end
57
-
58
- should "not match if not every regex matches" do
59
- doc = @col.find({:a => {'$all' => [/ha/, /sn/]}}).to_a
60
- assert_equal 0, doc.size
61
- end
62
- end
63
-
64
- context "the $not operator" do
65
- setup do
66
- @col.save({:a => ['x']})
67
- @col.save({:a => ['x', 'y']})
68
- @col.save({:a => ['x', 'y', 'z']})
69
- end
70
-
71
- should "negate a standard operator" do
72
- results = @col.find({:a => {'$not' => {'$size' => 2}}}).to_a
73
- assert_equal 2, results.size
74
- results = results.map {|r| r['a']}
75
- assert_equal ['x'], results.sort.first
76
- assert_equal ['x', 'y', 'z'], results.sort.last
77
- end
78
- end
79
- end
80
-
81
- context "new update operators: " do
82
-
83
- context "$addToSet (pushing a unique value)" do
84
- setup do
85
- @col.save({:username => 'bob', :interests => ['skiing', 'guitar']})
86
- end
87
-
88
- should "add an item to a set uniquely ($addToSet)" do
89
- @col.update({:username => 'bob'}, {'$addToSet' => {'interests' => 'skiing'}})
90
- @col.update({:username => 'bob'}, {'$addToSet' => {'interests' => 'kayaking'}})
91
- document = @col.find_one({:username => 'bob'})
92
- assert_equal ['guitar', 'kayaking', 'skiing'], document['interests'].sort
93
- end
94
-
95
- should "add an array of items uniquely ($addToSet with $each)" do
96
- @col.update({:username => 'bob'}, {'$addToSet' => {'interests' => {'$each' => ['skiing', 'kayaking', 'biking']}}})
97
- document = @col.find_one({:username => 'bob'})
98
- assert_equal ['biking', 'guitar', 'kayaking', 'skiing'], document['interests'].sort
99
- end
100
- end
101
-
102
- context "the positional operator ($)" do
103
- setup do
104
- @id1 = @col.insert({:text => 'hello',
105
- :comments => [{'by' => 'bob',
106
- 'text' => 'lol!'},
107
- {'by' => 'susie',
108
- 'text' => 'bye bye!'}]})
109
- @id2 = @col.insert({:text => 'goodbye',
110
- :comments => [{'by' => 'bob',
111
- 'text' => 'au revoir'},
112
- {'by' => 'susie',
113
- 'text' => 'bye bye!'}]})
114
- end
115
-
116
- should "update a matching array item" do
117
- @col.update({"_id" => @id1, "comments.by" => 'bob'}, {'$set' => {'comments.$.text' => 'lmao!'}}, :multi => true)
118
- result = @col.find_one({"_id" => @id1})
119
- assert_equal 'lmao!', result['comments'][0]['text']
120
- end
121
- end
122
- end
123
-
124
- context "Geoindexing" do
125
- setup do
126
- @places = @db['places']
127
- @places.create_index([['loc', Mongo::GEO2D]])
128
-
129
- @empire_state = ([40.748371, -73.985031])
130
- @jfk = ([40.643711, -73.790009])
131
-
132
- @places.insert({'name' => 'Empire State Building', 'loc' => ([40.748371, -73.985031])})
133
- @places.insert({'name' => 'Flatiron Building', 'loc' => ([40.741581, -73.987549])})
134
- @places.insert({'name' => 'Grand Central', 'loc' => ([40.751678, -73.976562])})
135
- @places.insert({'name' => 'Columbia University', 'loc' => ([40.808922, -73.961617])})
136
- @places.insert({'name' => 'NYSE', 'loc' => ([40.71455, -74.007124])})
137
- @places.insert({'name' => 'JFK', 'loc' => ([40.643711, -73.790009])})
138
- end
139
-
140
- teardown do
141
- @places.drop
142
- end
143
-
144
- should "find the nearest addresses" do
145
- results = @places.find({'loc' => {'$near' => @empire_state}}).limit(2).to_a
146
- assert_equal 2, results.size
147
- assert_equal 'Empire State Building', results[0]['name']
148
- assert_equal 'Flatiron Building', results[1]['name']
149
- end
150
-
151
- should "use geoNear command to return distances from a point" do
152
- cmd = BSON::OrderedHash.new
153
- cmd['geoNear'] = 'places'
154
- cmd['near'] = @empire_state
155
- cmd['num'] = 6
156
- r = @db.command(cmd)
157
-
158
- assert_equal 6, r['results'].length
159
- r['results'].each do |result|
160
- puts result.inspect
161
- end
162
- end
163
- end
164
- end
165
- end
@@ -1,74 +0,0 @@
1
- require 'test_helper'
2
- require 'mongo'
3
-
4
- # NOTE: This test requires bouncing the server.
5
- # It also requires that a user exists on the admin database.
6
- class AuthenticationTest < Test::Unit::TestCase
7
- include Mongo
8
-
9
- def setup
10
- @client = MongoClient.new
11
- @db1 = @client.db('mongo-ruby-test-auth1')
12
- @db2 = @client.db('mongo-ruby-test-auth2')
13
- @admin = @client.db('admin')
14
- end
15
-
16
- def teardown
17
- @db1.authenticate('user1', 'secret')
18
- @db2.authenticate('user2', 'secret')
19
- @client.drop_database('mongo-ruby-test-auth1')
20
- @client.drop_database('mongo-ruby-test-auth2')
21
- end
22
-
23
- def test_authenticate
24
- @admin.authenticate('bob', 'secret')
25
- @db1.add_user('user1', 'secret')
26
- @db2.add_user('user2', 'secret')
27
- @db2.add_user('userRO', 'secret', true) # read-only
28
- @admin.logout
29
-
30
- assert_raise Mongo::OperationFailure do
31
- @db1['stuff'].insert({:a => 2})
32
- end
33
-
34
- assert_raise Mongo::OperationFailure do
35
- @db2['stuff'].insert({:a => 2})
36
- end
37
-
38
- @db1.authenticate('user1', 'secret')
39
- @db2.authenticate('user2', 'secret')
40
-
41
- assert @db1['stuff'].insert({:a => 2})
42
- assert @db2['stuff'].insert({:a => 2})
43
-
44
- puts "Please bounce the server."
45
- gets
46
-
47
- # Here we reconnect.
48
- begin
49
- @db1['stuff'].find.to_a
50
- rescue Mongo::ConnectionFailure
51
- end
52
-
53
- assert @db1['stuff'].insert({:a => 2})
54
- assert @db2['stuff'].insert({:a => 2})
55
- assert @db2['stuff'].find({})
56
-
57
- @db1.logout
58
- assert_raise Mongo::OperationFailure do
59
- @db1['stuff'].insert({:a => 2})
60
- end
61
-
62
- @db2.logout
63
- assert_raise Mongo::OperationFailure do
64
- assert @db2['stuff'].insert({:a => 2})
65
- end
66
-
67
- @db2.authenticate('userRO', 'secret')
68
- assert @db2['stuff'].find({})
69
- assert_raise Mongo::OperationFailure do
70
- assert @db2['stuff'].insert({:a => 2})
71
- end
72
- end
73
-
74
- end