Permalink
Browse files

Initial mongo-ruby-driver v2.0 commit

  • Loading branch information...
1 parent d1c16f3 commit 1fc62d949269231e8e7639589a336276390dcc65 @TylerBrock TylerBrock committed Apr 19, 2013
Showing with 10 additions and 36,719 deletions.
  1. +5 −12 Gemfile
  2. +2 −342 README.md
  3. +0 −1 VERSION
  4. 0 test/data/empty_data → bin/.gitkeep
  5. +0 −49 bin/b2json
  6. +0 −50 bin/j2bson
  7. +0 −21 bin/mongo_console
  8. +0 −34 bson.gemspec
  9. +0 −29 bson_ext.gemspec
  10. +0 −135 ext/cbson/bson_buffer.c
  11. +0 −44 ext/cbson/bson_buffer.h
  12. +0 −1,105 ext/cbson/cbson.c
  13. +0 −102 ext/cbson/encoding_helpers.c
  14. +0 −13 ext/cbson/encoding_helpers.h
  15. +0 −10 ext/cbson/extconf.rb
  16. +0 −1 ext/cbson/version.h
  17. BIN ext/jbson/lib/java-bson.jar
  18. +0 −321 ext/jbson/src/main/jbson/RubyBSONCallback.java
  19. +0 −35 ext/jbson/src/main/jbson/RubyBSONDecoder.java
  20. +0 −764 ext/jbson/src/main/jbson/RubyBSONEncoder.java
  21. BIN ext/jbson/target/jbson.jar
  22. 0 lib/.gitkeep
  23. +0 −98 lib/bson.rb
  24. +0 −23 lib/bson/bson_c.rb
  25. +0 −34 lib/bson/bson_java.rb
  26. +0 −623 lib/bson/bson_ruby.rb
  27. +0 −225 lib/bson/byte_buffer.rb
  28. +0 −23 lib/bson/exceptions.rb
  29. +0 −170 lib/bson/ordered_hash.rb
  30. +0 −150 lib/bson/support/hash_with_indifferent_access.rb
  31. +0 −38 lib/bson/types/binary.rb
  32. +0 −41 lib/bson/types/code.rb
  33. +0 −28 lib/bson/types/dbref.rb
  34. +0 −42 lib/bson/types/min_max_keys.rb
  35. +0 −212 lib/bson/types/object_id.rb
  36. +0 −58 lib/bson/types/timestamp.rb
  37. +0 −80 lib/mongo.rb
  38. +0 −1,131 lib/mongo/collection.rb
  39. +0 −616 lib/mongo/cursor.rb
  40. +0 −639 lib/mongo/db.rb
  41. +0 −65 lib/mongo/exceptions.rb
  42. +0 −101 lib/mongo/gridfs/grid.rb
  43. +0 −39 lib/mongo/gridfs/grid_ext.rb
  44. +0 −150 lib/mongo/gridfs/grid_file_system.rb
  45. +0 −472 lib/mongo/gridfs/grid_io.rb
  46. +0 −71 lib/mongo/legacy.rb
  47. +0 −656 lib/mongo/mongo_client.rb
  48. +0 −491 lib/mongo/mongo_replica_set_client.rb
  49. +0 −147 lib/mongo/mongo_sharded_client.rb
  50. +0 −343 lib/mongo/networking.rb
  51. +0 −95 lib/mongo/util/conversions.rb
  52. +0 −87 lib/mongo/util/core_ext.rb
  53. +0 −69 lib/mongo/util/logging.rb
  54. +0 −190 lib/mongo/util/node.rb
  55. +0 −316 lib/mongo/util/pool.rb
  56. +0 −252 lib/mongo/util/pool_manager.rb
  57. +0 −112 lib/mongo/util/read_preference.rb
  58. +0 −54 lib/mongo/util/server_version.rb
  59. +0 −41 lib/mongo/util/sharding_pool_manager.rb
  60. +0 −20 lib/mongo/util/socket_util.rb
  61. +0 −51 lib/mongo/util/ssl_socket.rb
  62. +0 −113 lib/mongo/util/support.rb
  63. +0 −62 lib/mongo/util/tcp_socket.rb
  64. +0 −11 lib/mongo/util/thread_local_variable_manager.rb
  65. +0 −23 lib/mongo/util/unix_socket.rb
  66. +0 −337 lib/mongo/util/uri_parser.rb
  67. +0 −54 lib/mongo/util/write_concern.rb
  68. +3 −10 mongo.gemspec
  69. 0 spec/.gitkeep
  70. +0 −173 spec/bson/bson_spec.rb
  71. +0 −22 spec/mongo/mongo_client_spec.rb
  72. +0 −9 spec/spec_helper.rb
  73. +0 −84 tasks/benchmark.rake
  74. +0 −69 tasks/benchmark/batch_size_benchmark
  75. +0 −58 tasks/benchmark/bson_benchmark.rb
  76. +0 −1 tasks/benchmark/excanvas.min.js
  77. +0 −675 tasks/benchmark/exp_series.html
  78. +0 −708 tasks/benchmark/exp_series.js
  79. +0 −501 tasks/benchmark/exp_series.rb
  80. +0 −46 tasks/benchmark/gridstore_benchmark
  81. +0 −2,599 tasks/benchmark/jquery.flot.js
  82. +0 −8,316 tasks/benchmark/jquery.js
  83. +0 −97 tasks/benchmark/profile_array.rb
  84. BIN tasks/benchmark/sample_file.pdf
  85. +0 −178 tasks/benchmark/standard_benchmark
  86. +0 −20 tasks/compile.rake
  87. +0 −61 tasks/deploy.rake
  88. +0 −16 tasks/docs.rake
  89. +0 −4 tasks/general.rake
  90. +0 −111 tasks/testing.rake
  91. +0 −13 test/bson/binary_test.rb
  92. +0 −762 test/bson/bson_test.rb
  93. +0 −215 test/bson/byte_buffer_test.rb
  94. +0 −48 test/bson/hash_with_indifferent_access_test.rb
  95. +0 −16 test/bson/json_test.rb
  96. +0 −153 test/bson/object_id_test.rb
  97. +0 −247 test/bson/ordered_hash_test.rb
  98. +0 −51 test/bson/timestamp_test.rb
  99. BIN test/data/sample_data
  100. BIN test/data/sample_file.pdf
  101. +0 −1 test/data/small_data.txt
  102. +0 −21 test/functional/authentication_test.rb
  103. +0 −1,410 test/functional/collection_test.rb
  104. +0 −449 test/functional/connection_test.rb
  105. +0 −119 test/functional/conversions_test.rb
  106. +0 −49 test/functional/cursor_fail_test.rb
  107. +0 −43 test/functional/cursor_message_test.rb
  108. +0 −548 test/functional/cursor_test.rb
  109. +0 −805 test/functional/db_api_test.rb
  110. +0 −13 test/functional/db_connection_test.rb
  111. +0 −282 test/functional/db_test.rb
  112. +0 −273 test/functional/grid_file_system_test.rb
  113. +0 −238 test/functional/grid_io_test.rb
  114. +0 −259 test/functional/grid_test.rb
  115. +0 −47 test/functional/pool_test.rb
  116. +0 −84 test/functional/safe_test.rb
  117. +0 −48 test/functional/support_test.rb
  118. +0 −95 test/functional/threading_test.rb
  119. +0 −60 test/functional/timeout_test.rb
  120. +0 −200 test/functional/uri_test.rb
  121. +0 −104 test/functional/write_concern_test.rb
  122. +0 −23 test/replica_set/authentication_test.rb
  123. +0 −133 test/replica_set/basic_test.rb
  124. +0 −249 test/replica_set/client_test.rb
  125. +0 −64 test/replica_set/complex_connect_test.rb
  126. +0 −116 test/replica_set/connection_test.rb
  127. +0 −50 test/replica_set/count_test.rb
  128. +0 −198 test/replica_set/cursor_test.rb
  129. +0 −50 test/replica_set/insert_test.rb
  130. +0 −61 test/replica_set/max_values_test.rb
  131. +0 −41 test/replica_set/pinning_test.rb
  132. +0 −59 test/replica_set/query_test.rb
  133. +0 −200 test/replica_set/read_preference_test.rb
  134. +0 −130 test/replica_set/refresh_test.rb
  135. +0 −74 test/replica_set/replication_ack_test.rb
  136. +0 −155 test/sharded_cluster/basic_test.rb
  137. +0 −49 test/shared/authentication.rb
  138. +0 −204 test/test_helper.rb
  139. +0 −80 test/threading/basic_test.rb
  140. +0 −16 test/tools/keyfile.txt
  141. +0 −562 test/tools/mongo_config.rb
  142. +0 −146 test/tools/mongo_config_test.rb
  143. +0 −252 test/unit/client_test.rb
  144. +0 −176 test/unit/collection_test.rb
  145. +0 −246 test/unit/connection_test.rb
  146. +0 −273 test/unit/cursor_test.rb
  147. +0 −112 test/unit/db_test.rb
  148. +0 −62 test/unit/grid_test.rb
  149. +0 −32 test/unit/mongo_sharded_client_test.rb
  150. +0 −78 test/unit/node_test.rb
  151. +0 −94 test/unit/pool_manager_test.rb
  152. +0 −9 test/unit/pool_test.rb
  153. +0 −145 test/unit/read_test.rb
  154. +0 −144 test/unit/safe_test.rb
  155. +0 −88 test/unit/sharding_pool_manager_test.rb
  156. +0 −55 test/unit/util_test.rb
  157. +0 −161 test/unit/write_concern_test.rb
View
17 Gemfile
@@ -1,30 +1,23 @@
source 'https://rubygems.org'
-gem 'json'
-gem 'rake', :require => ['rake/testtask']
-gem 'rake-compiler', :require => ['rake/extensiontask', 'rake/javaextensiontask']
-gem 'activesupport'
+gem 'bson', :git => 'git://github.com/mongodb/bson-ruby.git'
group :deploy do
gem 'git'
gem 'yard'
- gem 'version_bumper'
gem 'redcarpet' unless RUBY_PLATFORM =~ /java/
end
group :testing do
- gem 'test-unit'
- gem 'mocha', ">=0.13.0", :require => 'mocha/setup'
- gem 'shoulda', ">=3.3.2"
+ gem 'rake'
gem 'rspec'
+end
+
+group :development do
- gem 'sfl'
- gem 'simplecov', :require => false
end
platforms :jruby do
- gem 'bouncy-castle-java'
- gem 'jruby-openssl'
gem 'jruby-launcher'
gem 'jruby-jars'
end
View
344 README.md
@@ -1,3 +1,5 @@
+# MongoDB Ruby Driver
+
[![Build Status][travis-img]][travis-url] [![Jenkins Status][jenkins-img]][jenkins-url] [![Code Climate][codeclimate-img]][codeclimate-url]
[travis-img]: https://secure.travis-ci.org/mongodb/mongo-ruby-driver.png
@@ -6,346 +8,4 @@
[codeclimate-url]: https://codeclimate.com/github/mongodb/mongo-ruby-driver
[jenkins-img]: https://jenkins.10gen.com/job/mongo-ruby-driver/badge/icon
[jenkins-url]: https://jenkins.10gen.com/job/mongo-ruby-driver/
-[api-url]: http://api.mongodb.org/ruby/current
-
-# Documentation
-
-This API documentation is available online at [http://api.mongodb.org/ruby](http://api.mongodb.org/ruby)
-for all releases of the MongoDB Ruby driver. Please reference the exact version of the documentation
-that matches the release of the Ruby driver that you are using. Note that the
-[Ruby Language Center for MongoDB](http://www.mongodb.org/display/DOCS/Ruby+Language+Center)
-has a link to API Documentation for the current release.
-
-If you have the source, you can generate the matching documentation by typing
-
- $ rake docs
-
-Once generated, the API documentation can be found in the docs/ folder.
-
-# Introduction
-
-This is the 10gen-supported Ruby driver for [MongoDB](http://www.mongodb.org).
-
-For the api reference please see the [API][api-url]
-
-The [wiki](https://github.com/mongodb/mongo-ruby-driver/wiki) has other articles of interest, including:
-
-1. [A tutorial](https://github.com/mongodb/mongo-ruby-driver/wiki/Tutorial).
-2. [Replica Sets in Ruby](https://github.com/mongodb/mongo-ruby-driver/wiki/Replica-Sets).
-3. [Write Concern in Ruby](https://github.com/mongodb/mongo-ruby-driver/wiki/Write-Concern).
-4. [Tailable Cursors in Ruby](https://github.com/mongodb/mongo-ruby-driver/wiki/Tailable-Cursors).
-5. [Read Preference in Ruby](https://github.com/mongodb/mongo-ruby-driver/wiki/Read-Preference).
-6. [GridFS in Ruby](https://github.com/mongodb/mongo-ruby-driver/wiki/GridFS).
-7. [Frequently Asked Questions](https://github.com/mongodb/mongo-ruby-driver/wiki/FAQ).
-8. [History](https://github.com/mongodb/mongo-ruby-driver/wiki/History).
-9. [Release plan](https://github.com/mongodb/mongo-ruby-driver/wiki/Releases).
-10. [Credits](https://github.com/mongodb/mongo-ruby-driver/wiki/Credits).
-
-Here's a quick code sample. Again, see the [MongoDB Ruby Tutorial](https://github.com/mongodb/mongo-ruby-driver/wiki/Tutorial) for much more:
-
-```ruby
-require 'rubygems'
-require 'mongo'
-
-include Mongo
-
-@client = MongoClient.new('localhost', 27017)
-@db = @client['sample-db']
-@coll = @db['test']
-
-@coll.remove
-
-3.times do |i|
- @coll.insert({'a' => i+1})
-end
-
-puts "There are #{@coll.count} records. Here they are:"
-@coll.find.each { |doc| puts doc.inspect }
-```
-
-# Installation
-
-### Ruby Versions
-
-The driver works and is consistently tested on Ruby 1.8.7 and 1.9.3 as well as JRuby 1.6.x and 1.7.x.
-
-Note that if you're on 1.8.7, be sure that you're using a patchlevel >= 249. There are some IO bugs in earlier versions.
-
-### Gems
-
- $ gem update --system
- $ gem install mongo
-
-For a significant performance boost, you'll want to install the C extension:
-
- $ gem install bson_ext
-
-Note that bson_ext isn't used with JRuby. Instead, we use some native Java extensions are bundled with the bson gem. If you ever need to modify these extensions, you can recompile with the following rake task:
-
- $ rake compile:jbson
-
-### From the GitHub source
-
-The source code is available at http://github.com/mongodb/mongo-ruby-driver.
-You can either clone the git repository or download a tarball or zip file.
-Once you have the source, you can use it from wherever you downloaded it or
-you can install it as a gem from the source by typing:
-
- $ rake install
-
-# Examples
-
-For extensive examples, see the [MongoDB Ruby Tutorial](https://github.com/mongodb/mongo-ruby-driver/wiki/Tutorial).
-
-# GridFS
-
-The Ruby driver include two abstractions for storing large files: Grid and GridFileSystem.
-
-The Grid class is a Ruby implementation of MongoDB's GridFS file storage
-specification. GridFileSystem is essentially the same, but provides a more filesystem-like API and assumes that filenames are unique.
-
-An instance of both classes represents an individual file store. See the API reference for details.
-
-Examples:
-
-```ruby
-# Write a file on disk to the Grid
-file = File.open('image.jpg')
-grid = Mongo::Grid.new(db)
-id = grid.put(file)
-
-# Retrieve the file
-file = grid.get(id)
-file.read
-
-# Get all the file's metata
-file.filename
-file.content_type
-file.metadata
-```
-
-# Notes
-
-## Thread Safety
-
-The driver is thread-safe.
-
-## Connection Pooling
-
-The driver implements connection pooling. By default, only one
-socket connection will be opened to MongoDB. However, if you're running a
-multi-threaded application, you can specify a maximum pool size and a maximum
-timeout for waiting for old connections to be released to the pool.
-
-To set up a pooled connection to a single MongoDB instance:
-
-```ruby
- @client = MongoClient.new("localhost", 27017, :pool_size => 5, :timeout => 5)
-```
-
-Though the pooling architecture will undoubtedly evolve, it currently owes much credit
-to the connection pooling implementations in ActiveRecord and PyMongo.
-
-## Forking
-
-Certain Ruby application servers work by forking, and it has long been necessary to
-re-establish the child process's connection to the database after fork. But with the release
-of v1.3.0, the Ruby driver detects forking and reconnects automatically.
-
-## Environment variable `MONGODB_URI`
-
-`Mongo::MongoClient.from_uri`, `Mongo::MongoClient.new` and `Mongo::MongoReplicaSetClient.new` will use <code>ENV["MONGODB_URI"]</code> if no other args are provided.
-
-The URI must fit this specification:
-
- mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
-
-If the type of connection (direct or replica set) should be determined entirely from <code>ENV["MONGODB_URI"]</code>, you may want to use `Mongo::MongoClient.from_uri` because it will return either `Mongo::MongoClient` or a `Mongo::MongoReplicaSetClient` depending on how many hosts are specified. Trying to use `Mongo::MongoClient.new` with multiple hosts in <code>ENV["MONGODB_URI"]</code> will raise an exception.
-
-## String Encoding
-
-The BSON ("Binary JSON") format used to communicate with Mongo requires that
-strings be UTF-8 (http://en.wikipedia.org/wiki/UTF-8).
-
-Ruby 1.9 has built-in character encoding support. All strings sent to Mongo
-and received from Mongo are converted to UTF-8 when necessary, and strings
-read from Mongo will have their character encodings set to UTF-8.
-
-When used with Ruby 1.8, the bytes in each string are written to and read from
-Mongo as is. If the string is ASCII, all is well, because ASCII is a subset of
-UTF-8. If the string is not ASCII, it may not be a well-formed UTF-8
-string.
-
-## Primary Keys
-
-The `_id` field is a primary key. It is treated specially by the database, and
-its use makes many operations more efficient. The value of an _id may be of
-any type. The database itself inserts an _id value if none is specified when
-a record is inserted.
-
-### Primary Key Factories
-
-A primary key factory is a class you supply to a DB object that knows how to
-generate _id values. If you want to control _id values or even their types,
-using a PK factory lets you do so.
-
-You can tell the Ruby Mongo driver how to create primary keys by passing in
-the :pk option to the MongoClient#db method.
-
-```ruby
-include Mongo
-db = MongoClient.new('localhost', 27017).db('dbname', :pk => MyPKFactory.new)
-```
-
-A primary key factory object must respond to :create_pk, which should
-take a hash and return a hash which merges the original hash with any
-primary key fields the factory wishes to inject.
-
-NOTE: if the object already has a primary key, the factory should not
-inject a new key; this means that the object may already exist in the
-database. The idea here is that whenever a record is inserted, the
-:pk object's +create_pk+ method will be called and the new hash
-returned will be inserted.
-
-Here is a sample primary key factory, taken from the tests:
-```ruby
-class TestPKFactory
- def create_pk(doc)
- doc['_id'] ||= BSON::ObjectId.new
- doc
- end
-end
-```
-Here's a slightly more sophisticated one that handles both symbol and string
-keys. This is the PKFactory that comes with the MongoRecord code (an
-ActiveRecord-like framework for non-Rails apps) and the AR Mongo adapter code
-(for Rails):
-```ruby
-class PKFactory
- def create_pk(doc)
- return doc if doc[:_id]
- doc.delete(:_id) # in case it exists but the value is nil
- doc['_id'] ||= BSON::ObjectId.new
- doc
- end
-end
-```
-
-A database's PK factory object may be set either when a DB object is created
-or immediately after you obtain it, but only once. The only reason it is
-changeable at all is so that libraries such as MongoRecord that use this
-driver can set the PK factory after obtaining the database but before using it
-for the first time.
-
-## The DB Class
-
-### Strict mode
-
-_**NOTE:** Support for strict mode has been deprecated and will be removed in version 2.0 of the driver._
-
-Each database has an optional strict mode. If strict mode is on, then asking
-for a collection that does not exist will raise an error, as will asking to
-create a collection that already exists. Note that both these operations are
-completely harmless; strict mode is a programmer convenience only.
-
-To turn on strict mode, either pass in :strict => true when obtaining a DB
-object or call the `:strict=` method:
-
-```ruby
-db = MongoClient.new('localhost', 27017).db('dbname', :strict => true)
-# I'm feeling lax
-db.strict = false
-# No, I'm not!
-db.strict = true
-```
-
-The method DB#strict? returns the current value of that flag.
-
-## Cursors
-
-Notes:
-
-* Cursors are enumerable (and have a #to_a method).
-
-* The query doesn't get run until you actually attempt to retrieve data from a
- cursor.
-
-* Cursors will timeout on the server after 10 minutes. If you need to keep a cursor
- open for more than 10 minutes, specify `:timeout => false` when you create the cursor.
-
-## Socket timeouts
-
-The Ruby driver support timeouts on socket read operations. To enable them, set the
-`:op_timeout` option when you create a `Mongo::MongoClient` object.
-
-If implementing higher-level timeouts, using tools like `Rack::Timeout`, it's very important
-to call `Mongo::MongoClient#close` to prevent the subsequent operation from receiving the previous
-request.
-
-# Testing
-
-Before running the tests, make sure you install all test dependencies by running:
-
- $ gem install bundler; bundle install
-
-To run all default test suites (without the BSON extensions) just type:
-
- $ rake test
-
-If you want to run the default test suite using the BSON extensions:
-
- $ rake test:ext
-
-These will run both unit and functional tests. To run these tests alone:
-
- $ rake test:unit
- $ rake test:functional
-
-To run any individual rake tasks with the BSON extension disabled, just pass BSON_EXT_DISABLED=true to the task:
-
- $ rake test:unit BSON_EXT_DISABLED=true
-
-If you want to test replica set, you can run the following task:
-
- $ rake test:replica_set
-
-To run a single test at the top level, add -Itest since we no longer modify LOAD_PATH:
-
- $ ruby -Itest -Ilib test/bson/bson_test.rb
-
-To run a single test from the test directory, add -I. since we no longer modify LOAD_PATH:
-
- $ ruby -I. -I../lib bson/bson_test.rb
-
-To run a single test from its subdirectory, add -I.. since we no longer modify LOAD_PATH:
-
- $ ruby -I.. -I../../lib bson_test.rb
-
-To fix the following error on Mac OS X - "/.../lib/bson_ext/cbson.bundle: [BUG] Segmentation fault":
-
- $ rake compile
-
-# Release Notes
-
-See [history](https://github.com/mongodb/mongo-ruby-driver/wiki/History).
-
-
-# Credits
-
-See [credits](https://github.com/mongodb/mongo-ruby-driver/wiki/Credits).
-
-# License
-
- Copyright (C) 2008-2013 10gen Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
View
@@ -1 +0,0 @@
-1.8.5
File renamed without changes.
Oops, something went wrong.

0 comments on commit 1fc62d9

Please sign in to comment.