mongo-find_replace 0.18.3

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.
Files changed (68) hide show
  1. data/LICENSE.txt +202 -0
  2. data/README.rdoc +358 -0
  3. data/Rakefile +133 -0
  4. data/bin/bson_benchmark.rb +59 -0
  5. data/bin/fail_if_no_c.rb +11 -0
  6. data/examples/admin.rb +42 -0
  7. data/examples/capped.rb +22 -0
  8. data/examples/cursor.rb +48 -0
  9. data/examples/gridfs.rb +88 -0
  10. data/examples/index_test.rb +126 -0
  11. data/examples/info.rb +31 -0
  12. data/examples/queries.rb +70 -0
  13. data/examples/simple.rb +24 -0
  14. data/examples/strict.rb +35 -0
  15. data/examples/types.rb +36 -0
  16. data/lib/mongo.rb +61 -0
  17. data/lib/mongo/admin.rb +95 -0
  18. data/lib/mongo/collection.rb +664 -0
  19. data/lib/mongo/connection.rb +555 -0
  20. data/lib/mongo/cursor.rb +393 -0
  21. data/lib/mongo/db.rb +527 -0
  22. data/lib/mongo/exceptions.rb +60 -0
  23. data/lib/mongo/gridfs.rb +22 -0
  24. data/lib/mongo/gridfs/chunk.rb +90 -0
  25. data/lib/mongo/gridfs/grid_store.rb +555 -0
  26. data/lib/mongo/types/binary.rb +48 -0
  27. data/lib/mongo/types/code.rb +36 -0
  28. data/lib/mongo/types/dbref.rb +38 -0
  29. data/lib/mongo/types/min_max_keys.rb +58 -0
  30. data/lib/mongo/types/objectid.rb +219 -0
  31. data/lib/mongo/types/regexp_of_holding.rb +45 -0
  32. data/lib/mongo/util/bson_c.rb +18 -0
  33. data/lib/mongo/util/bson_ruby.rb +595 -0
  34. data/lib/mongo/util/byte_buffer.rb +222 -0
  35. data/lib/mongo/util/conversions.rb +97 -0
  36. data/lib/mongo/util/ordered_hash.rb +135 -0
  37. data/lib/mongo/util/server_version.rb +69 -0
  38. data/lib/mongo/util/support.rb +26 -0
  39. data/lib/mongo/util/xml_to_ruby.rb +112 -0
  40. data/mongo-ruby-driver.gemspec +28 -0
  41. data/test/replica/count_test.rb +34 -0
  42. data/test/replica/insert_test.rb +50 -0
  43. data/test/replica/pooled_insert_test.rb +54 -0
  44. data/test/replica/query_test.rb +39 -0
  45. data/test/test_admin.rb +67 -0
  46. data/test/test_bson.rb +397 -0
  47. data/test/test_byte_buffer.rb +81 -0
  48. data/test/test_chunk.rb +82 -0
  49. data/test/test_collection.rb +534 -0
  50. data/test/test_connection.rb +160 -0
  51. data/test/test_conversions.rb +120 -0
  52. data/test/test_cursor.rb +386 -0
  53. data/test/test_db.rb +254 -0
  54. data/test/test_db_api.rb +783 -0
  55. data/test/test_db_connection.rb +16 -0
  56. data/test/test_grid_store.rb +306 -0
  57. data/test/test_helper.rb +42 -0
  58. data/test/test_objectid.rb +156 -0
  59. data/test/test_ordered_hash.rb +168 -0
  60. data/test/test_round_trip.rb +114 -0
  61. data/test/test_slave_connection.rb +36 -0
  62. data/test/test_threading.rb +87 -0
  63. data/test/threading/test_threading_large_pool.rb +90 -0
  64. data/test/unit/collection_test.rb +52 -0
  65. data/test/unit/connection_test.rb +59 -0
  66. data/test/unit/cursor_test.rb +94 -0
  67. data/test/unit/db_test.rb +97 -0
  68. metadata +123 -0
data/Rakefile ADDED
@@ -0,0 +1,133 @@
1
+ # -*- mode: ruby; -*-
2
+ require 'rubygems'
3
+ require 'rubygems/specification'
4
+ require 'fileutils'
5
+ require 'rake'
6
+ require 'rake/testtask'
7
+ require 'rake/gempackagetask'
8
+ begin
9
+ require 'rake/contrib/rubyforgepublisher'
10
+ rescue LoadError
11
+ end
12
+ require 'rbconfig'
13
+ include Config
14
+ ENV['TEST_MODE'] = 'TRUE'
15
+
16
+ desc "Test the MongoDB Ruby driver."
17
+ task :test do
18
+ puts "\nThis option has changed."
19
+ puts "\nTo test the driver with the c-extensions:\nrake test:c\n"
20
+ puts "To test the pure ruby driver: \nrake test:ruby"
21
+ end
22
+
23
+ namespace :test do
24
+
25
+ desc "Test the driver with the c extension enabled."
26
+ task :c do
27
+ ENV['C_EXT'] = 'TRUE'
28
+ Rake::Task['test:unit'].invoke
29
+ Rake::Task['test:functional'].invoke
30
+ Rake::Task['test:pooled_threading'].invoke
31
+ Rake::Task['test:drop_databases'].invoke
32
+ ENV['C_EXT'] = nil
33
+ end
34
+
35
+ desc "Test the driver using pure ruby (no c extension)"
36
+ task :ruby do
37
+ ENV['C_EXT'] = nil
38
+ Rake::Task['test:unit'].invoke
39
+ Rake::Task['test:functional'].invoke
40
+ Rake::Task['test:pooled_threading'].invoke
41
+ Rake::Task['test:drop_databases'].invoke
42
+ end
43
+
44
+ Rake::TestTask.new(:unit) do |t|
45
+ t.test_files = FileList['test/unit/*_test.rb']
46
+ t.verbose = true
47
+ end
48
+
49
+ Rake::TestTask.new(:functional) do |t|
50
+ t.test_files = FileList['test/test*.rb']
51
+ t.verbose = true
52
+ end
53
+
54
+ Rake::TestTask.new(:pooled_threading) do |t|
55
+ t.test_files = FileList['test/threading/*.rb']
56
+ t.verbose = true
57
+ end
58
+
59
+ Rake::TestTask.new(:pair_count) do |t|
60
+ t.test_files = FileList['test/replica/count_test.rb']
61
+ t.verbose = true
62
+ end
63
+
64
+ Rake::TestTask.new(:pair_insert) do |t|
65
+ t.test_files = FileList['test/replica/insert_test.rb']
66
+ t.verbose = true
67
+ end
68
+
69
+ Rake::TestTask.new(:pooled_pair_insert) do |t|
70
+ t.test_files = FileList['test/replica/pooled_insert_test.rb']
71
+ t.verbose = true
72
+ end
73
+
74
+ Rake::TestTask.new(:pair_query) do |t|
75
+ t.test_files = FileList['test/replica/query_test.rb']
76
+ t.verbose = true
77
+ end
78
+
79
+ task :drop_databases do |t|
80
+ puts "Dropping test database..."
81
+ require File.join(File.dirname(__FILE__), 'lib', 'mongo')
82
+ include Mongo
83
+ con = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
84
+ ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
85
+ con.drop_database('ruby-mongo-test')
86
+ end
87
+ end
88
+
89
+ desc "Generate documentation"
90
+ task :rdoc do
91
+ version = eval(File.read("mongo-ruby-driver.gemspec")).version
92
+ out = File.join('html', version.to_s)
93
+ FileUtils.rm_rf('html')
94
+ system "rdoc --main README.rdoc --op #{out} --inline-source --quiet README.rdoc `find lib -name '*.rb'`"
95
+ end
96
+
97
+ desc "Generate YARD documentation"
98
+ task :ydoc do
99
+ version = eval(File.read("mongo-ruby-driver.gemspec")).version
100
+ out = File.join('ydoc', version.to_s)
101
+ FileUtils.rm_rf('ydoc')
102
+ system "yardoc lib/**/*.rb lib/mongo/**/*.rb -o #{out} --title MongoRuby-#{version}"
103
+ end
104
+
105
+ desc "Publish documentation to mongo.rubyforge.org"
106
+ task :publish => [:rdoc] do
107
+ # Assumes docs are in ./html
108
+ Rake::RubyForgePublisher.new(GEM, RUBYFORGE_USER).upload
109
+ end
110
+
111
+ namespace :gem do
112
+
113
+ desc "Install the gem locally"
114
+ task :install do
115
+ sh "gem build mongo-ruby-driver.gemspec"
116
+ sh "gem install mongo-*.gem"
117
+ sh "rm mongo-*.gem"
118
+ end
119
+
120
+ desc "Install the optional c extensions"
121
+ task :install_extensions do
122
+ sh "gem build mongo-extensions.gemspec"
123
+ sh "gem install mongo_ext-*.gem"
124
+ sh "rm mongo_ext-*.gem"
125
+ end
126
+
127
+ end
128
+
129
+ task :default => :list
130
+
131
+ task :list do
132
+ system 'rake -T'
133
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'mongo'
5
+
6
+ include Mongo
7
+
8
+ TRIALS = 100000
9
+
10
+ def encode(doc)
11
+ t0 = Time.new
12
+ b = BSON.new
13
+ TRIALS.times { |i|
14
+ b = BSON.new
15
+ b.serialize doc
16
+ }
17
+ print "took: #{Time.now.to_f - t0.to_f}\n"
18
+ return b
19
+ end
20
+
21
+ def decode(bson)
22
+ t0 = Time.new
23
+ doc = nil
24
+ TRIALS.times { |i|
25
+ doc = bson.deserialize
26
+ }
27
+ print "took: #{Time.now.to_f - t0.to_f}\n"
28
+ return doc
29
+ end
30
+
31
+ TEST_CASES = [{},
32
+ {
33
+ "hello" => "world"
34
+ },
35
+ {
36
+ "hello" => "world",
37
+ "mike" => "something",
38
+ "here's" => "another"
39
+ },
40
+ {
41
+ "int" => 200,
42
+ "bool" => true,
43
+ "an int" => 20,
44
+ "a bool" => false
45
+ },
46
+ {
47
+ "this" => 5,
48
+ "is" => {"a" => true},
49
+ "big" => [true, 5.5],
50
+ "object" => nil
51
+ }]
52
+
53
+ TEST_CASES.each { |doc|
54
+ print "case #{doc.inspect}\n"
55
+ print "enc bson\n"
56
+ enc_bson = encode(doc)
57
+ print "dec bson\n"
58
+ raise "FAIL" unless doc == decode(enc_bson)
59
+ }
@@ -0,0 +1,11 @@
1
+ # Fail if the C extension module isn't installed.
2
+ #
3
+ # Only really intended to be used by internal build scripts.
4
+
5
+ require 'rubygems'
6
+ require 'mongo'
7
+ begin
8
+ require 'mongo_ext/cbson'
9
+ rescue LoadError
10
+ Process.exit 1
11
+ end
data/examples/admin.rb ADDED
@@ -0,0 +1,42 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'mongo'
4
+ require 'pp'
5
+
6
+ include Mongo
7
+
8
+ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
9
+ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
10
+
11
+ puts "Connecting to #{host}:#{port}"
12
+ db = Mongo::Connection.new(host, port).db('ruby-mongo-examples')
13
+ coll = db.create_collection('test')
14
+
15
+ # Erase all records from collection, if any
16
+ coll.remove
17
+
18
+ admin = db.admin
19
+
20
+ # Profiling level set/get
21
+ puts "Profiling level: #{admin.profiling_level}"
22
+
23
+ # Start profiling everything
24
+ admin.profiling_level = :all
25
+
26
+ # Read records, creating a profiling event
27
+ coll.find().to_a
28
+
29
+ # Stop profiling
30
+ admin.profiling_level = :off
31
+
32
+ # Print all profiling info
33
+ pp admin.profiling_info
34
+
35
+ # Validate returns a hash if all is well and
36
+ # raises an exception if there is a problem.
37
+ info = admin.validate_collection(coll.name)
38
+ puts "valid = #{info['ok']}"
39
+ puts info['result']
40
+
41
+ # Destroy the collection
42
+ coll.drop
@@ -0,0 +1,22 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'mongo'
3
+
4
+ include Mongo
5
+
6
+ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
7
+ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
8
+
9
+ puts "Connecting to #{host}:#{port}"
10
+ db = Connection.new(host, port).db('ruby-mongo-examples')
11
+ db.drop_collection('test')
12
+
13
+ # A capped collection has a max size and, optionally, a max number of records.
14
+ # Old records get pushed out by new ones once the size or max num records is reached.
15
+ coll = db.create_collection('test', :capped => true, :size => 1024, :max => 12)
16
+
17
+ 100.times { |i| coll.insert('a' => i+1) }
18
+
19
+ # We will only see the last 12 records
20
+ coll.find().each { |row| p row }
21
+
22
+ coll.drop
@@ -0,0 +1,48 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'mongo'
4
+ require 'pp'
5
+
6
+ include Mongo
7
+
8
+ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
9
+ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
10
+
11
+ puts "Connecting to #{host}:#{port}"
12
+ db = Connection.new(host, port).db('ruby-mongo-examples')
13
+ coll = db.collection('test')
14
+
15
+ # Erase all records from collection, if any
16
+ coll.remove
17
+
18
+ # Insert 3 records
19
+ 3.times { |i| coll.insert({'a' => i+1}) }
20
+
21
+ # Cursors don't run their queries until you actually attempt to retrieve data
22
+ # from them.
23
+
24
+ # Find returns a Cursor, which is Enumerable. You can iterate:
25
+ coll.find().each { |row| pp row }
26
+
27
+ # You can turn it into an array:
28
+ array = coll.find().to_a
29
+
30
+ # You can iterate after turning it into an array (the cursor will iterate over
31
+ # the copy of the array that it saves internally.)
32
+ cursor = coll.find()
33
+ array = cursor.to_a
34
+ cursor.each { |row| pp row }
35
+
36
+ # You can get the next object
37
+ first_object = coll.find().next_document
38
+
39
+ # next_document returns nil if there are no more objects that match
40
+ cursor = coll.find()
41
+ obj = cursor.next_document
42
+ while obj
43
+ pp obj
44
+ obj = cursor.next_document
45
+ end
46
+
47
+ # Destroy the collection
48
+ coll.drop
@@ -0,0 +1,88 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'mongo'
4
+ require 'mongo/gridfs'
5
+
6
+ include Mongo
7
+ include GridFS
8
+
9
+ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
10
+ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
11
+
12
+ puts "Connecting to #{host}:#{port}"
13
+ db = Connection.new(host, port).db('ruby-mongo-examples')
14
+
15
+ def dump(db, fname)
16
+ GridStore.open(db, fname, 'r') { |f| puts f.read }
17
+ end
18
+
19
+ # Write a new file
20
+ GridStore.open(db, 'foobar', 'w') { |f| f.write("hello, world!") }
21
+
22
+ # Read it and print out the contents
23
+ dump(db, 'foobar')
24
+
25
+ # Append more data
26
+ GridStore.open(db, 'foobar', 'w+') { |f| f.write("\n"); f.puts "line two" }
27
+ dump(db, 'foobar')
28
+
29
+ # Overwrite
30
+ GridStore.open(db, 'foobar', 'w') { |f| f.puts "hello, sailor!" }
31
+ dump(db, 'foobar')
32
+
33
+ # File existence tests
34
+ puts "File 'foobar' exists: #{GridStore.exist?(db, 'foobar')}"
35
+ puts "File 'does-not-exist' exists: #{GridStore.exist?(db, 'does-not-exist')}"
36
+
37
+ # Read with offset (uses seek)
38
+ puts GridStore.read(db, 'foobar', 6, 7)
39
+
40
+ # Rewind/seek/tell
41
+ GridStore.open(db, 'foobar', 'w') { |f|
42
+ f.write "hello, world!"
43
+ f.rewind
44
+ f.write "xyzzz"
45
+ puts f.tell # => 5
46
+ f.seek(4)
47
+ f.write('y')
48
+ }
49
+ dump(db, 'foobar') # => 'xyzzy'
50
+
51
+ # Unlink (delete)
52
+ GridStore.unlink(db, 'foobar')
53
+ puts "File 'foobar' exists after delete: #{GridStore.exist?(db, 'foobar')}"
54
+
55
+ # Metadata
56
+ GridStore.open(db, 'foobar', 'w') { |f| f.write("hello, world!") }
57
+ GridStore.open(db, 'foobar', 'r') { |f|
58
+ puts f.content_type
59
+ puts f.upload_date
60
+ puts f.chunk_size
61
+ puts f.metadata.inspect
62
+ }
63
+
64
+ # Add some metadata; change content type
65
+ GridStore.open(db, 'foobar', 'w+') { |f|
66
+ f.content_type = 'text/xml'
67
+ f.metadata = {'a' => 1}
68
+ }
69
+ # Print it
70
+ GridStore.open(db, 'foobar', 'r') { |f|
71
+ puts f.content_type
72
+ puts f.upload_date
73
+ puts f.chunk_size
74
+ puts f.metadata.inspect
75
+ }
76
+
77
+ # You can also set metadata when initially writing the file. Setting :root
78
+ # means that the file and its chunks are stored in a different root
79
+ # collection: instead of gridfs.files and gridfs.chunks, here we use
80
+ # my_files.files and my_files.chunks.
81
+ GridStore.open(db, 'foobar', 'w',
82
+ :content_type => 'text/plain',
83
+ :metadata => {'a' => 1},
84
+ :chunk_size => 1024 * 4,
85
+ :root => 'my_files') { |f|
86
+ f.puts 'hello, world'
87
+ }
88
+
@@ -0,0 +1,126 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'mongo'
4
+
5
+ include Mongo
6
+
7
+ host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
8
+ port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
9
+
10
+ puts ">> Connecting to #{host}:#{port}"
11
+ db = Connection.new(host, port).db('ruby-mongo-index_test')
12
+
13
+ class Exception
14
+ def errmsg
15
+ "%s: %s\n%s" % [self.class, message, (backtrace || []).join("\n") << "\n"]
16
+ end
17
+ end
18
+
19
+ puts ">> Dropping collection test"
20
+ begin
21
+ res = db.drop_collection('test')
22
+ puts "dropped : #{res.inspect}"
23
+ rescue => e
24
+ puts "Error: #{e.errmsg}"
25
+ end
26
+
27
+ puts ">> Creating collection test"
28
+ begin
29
+ coll = db.collection('test')
30
+ puts "created : #{coll.inspect}"
31
+ rescue => e
32
+ puts "Error: #{e.errmsg}"
33
+ end
34
+
35
+ OBJS_COUNT = 100
36
+
37
+ puts ">> Generating test data"
38
+ msgs = %w{hola hello aloha ciao}
39
+ arr = (0...OBJS_COUNT).collect {|x| { :number => x, :rndm => (rand(5)+1), :msg => msgs[rand(4)] }}
40
+ puts "generated"
41
+
42
+ puts ">> Inserting data (#{arr.size})"
43
+ coll.insert(arr)
44
+ puts "inserted"
45
+
46
+ puts ">> Creating index"
47
+ #res = coll.create_index "all", :_id => 1, :number => 1, :rndm => 1, :msg => 1
48
+ res = coll.create_index [[:number, 1], [:rndm, 1], [:msg, 1]]
49
+ puts "created index: #{res.inspect}"
50
+ # ============================ Mongo Log ============================
51
+ # Fri Dec 5 14:45:02 Adding all existing records for ruby-mongo-console.test to new index
52
+ # ***
53
+ # Bad data or size in BSONElement::size()
54
+ # bad type:30
55
+ # totalsize:11 fieldnamesize:4
56
+ # lastrec:
57
+ # Fri Dec 5 14:45:02 ruby-mongo-console.system.indexes Assertion failure false jsobj.cpp a0
58
+ # Fri Dec 5 14:45:02 database: ruby-mongo-console op:7d2 0
59
+ # Fri Dec 5 14:45:02 ns: ruby-mongo-console.system.indexes
60
+
61
+ puts ">> Gathering index information"
62
+ begin
63
+ res = coll.index_information
64
+ puts "index_information : #{res.inspect}"
65
+ rescue => e
66
+ puts "Error: #{e.errmsg}"
67
+ end
68
+ # ============================ Console Output ============================
69
+ # RuntimeError: Keys for index on return from db was nil. Coll = ruby-mongo-console.test
70
+ # from ./bin/../lib/mongo/db.rb:135:in `index_information'
71
+ # from (irb):11:in `collect'
72
+ # from ./bin/../lib/mongo/cursor.rb:47:in `each'
73
+ # from ./bin/../lib/mongo/db.rb:130:in `collect'
74
+ # from ./bin/../lib/mongo/db.rb:130:in `index_information'
75
+ # from ./bin/../lib/mongo/collection.rb:74:in `index_information'
76
+ # from (irb):11
77
+
78
+ puts ">> Dropping index"
79
+ begin
80
+ res = coll.drop_index "number_1_rndm_1_msg_1"
81
+ puts "dropped : #{res.inspect}"
82
+ rescue => e
83
+ puts "Error: #{e.errmsg}"
84
+ end
85
+
86
+ # ============================ Console Output ============================
87
+ # => {"nIndexesWas"=>2.0, "ok"=>1.0}
88
+ # ============================ Mongo Log ============================
89
+ # 0x41802a 0x411549 0x42bac6 0x42c1f6 0x42c55b 0x42e6f7 0x41631e 0x41a89d 0x41ade2 0x41b448 0x4650d2 0x4695ad
90
+ # db/db(_Z12sayDbContextPKc+0x17a) [0x41802a]
91
+ # db/db(_Z8assertedPKcS0_j+0x9) [0x411549]
92
+ # db/db(_ZNK11BSONElement4sizeEv+0x1f6) [0x42bac6]
93
+ # db/db(_ZN7BSONObj8getFieldEPKc+0xa6) [0x42c1f6]
94
+ # db/db(_ZN7BSONObj14getFieldDottedEPKc+0x11b) [0x42c55b]
95
+ # db/db(_ZN7BSONObj19extractFieldsDottedES_R14BSONObjBuilder+0x87) [0x42e6f7]
96
+ # db/db(_ZN12IndexDetails17getKeysFromObjectER7BSONObjRSt3setIS0_St4lessIS0_ESaIS0_EE+0x24e) [0x41631e]
97
+ # db/db(_Z12_indexRecordR12IndexDetailsR7BSONObj7DiskLoc+0x5d) [0x41a89d]
98
+ # db/db(_Z18addExistingToIndexPKcR12IndexDetails+0xb2) [0x41ade2]
99
+ # db/db(_ZN11DataFileMgr6insertEPKcPKvib+0x508) [0x41b448]
100
+ # db/db(_Z14receivedInsertR7MessageRSt18basic_stringstreamIcSt11char_traitsIcESaIcEE+0x112) [0x4650d2]
101
+ # db/db(_Z10connThreadv+0xb4d) [0x4695ad]
102
+ # Fri Dec 5 14:45:02 ruby-mongo-console.system.indexes Caught Assertion insert, continuing
103
+ # Fri Dec 5 14:47:59 CMD: deleteIndexes ruby-mongo-console.test
104
+ # d->nIndexes was 2
105
+ # alpha implementation, space not reclaimed
106
+
107
+ puts ">> Gathering index information"
108
+ begin
109
+ res = coll.index_information
110
+ puts "index_information : #{res.inspect}"
111
+ rescue => e
112
+ puts "Error: #{e.errmsg}"
113
+ end
114
+ # ============================ Console Output ============================
115
+ # RuntimeError: Keys for index on return from db was nil. Coll = ruby-mongo-console.test
116
+ # from ./bin/../lib/mongo/db.rb:135:in `index_information'
117
+ # from (irb):15:in `collect'
118
+ # from ./bin/../lib/mongo/cursor.rb:47:in `each'
119
+ # from ./bin/../lib/mongo/db.rb:130:in `collect'
120
+ # from ./bin/../lib/mongo/db.rb:130:in `index_information'
121
+ # from ./bin/../lib/mongo/collection.rb:74:in `index_information'
122
+ # from (irb):15
123
+
124
+ puts ">> Closing connection"
125
+ db.close
126
+ puts "closed"