Permalink
Browse files

Updated to Mongo gems v0.20.1

  • Loading branch information...
1 parent cab223e commit 4804f585a77b589bf25f4f38ba2bfa307885d6d1 @SFEley committed Apr 12, 2010
Showing with 16 additions and 21 deletions.
  1. +3 −1 Rakefile
  2. +1 −1 lib/candy/crunch.rb
  3. +5 −12 lib/candy/wrapper.rb
  4. +2 −2 spec/candy/crunch_spec.rb
  5. +2 −2 spec/candy/piece_spec.rb
  6. +3 −3 spec/candy/wrapper_spec.rb
View
4 Rakefile
@@ -16,7 +16,9 @@ DESCRIPTION
gem.email = "sfeley@gmail.com"
gem.homepage = "http://github.com/SFEley/candy"
gem.authors = ["Stephen Eley"]
- gem.add_dependency "mongo", ">= 0.19.1"
+ gem.add_dependency "bson", ">= 0.20.1"
+ gem.add_dependency "bson_ext", '>= 0.20.1'
+ gem.add_dependency "mongo", ">= 0.20.1"
gem.add_development_dependency "rspec", ">= 1.2.9"
# gem.add_development_dependency "yard", ">= 0"
gem.add_development_dependency "mocha", ">= 0.9.8"
View
2 lib/candy/crunch.rb
@@ -140,7 +140,7 @@ def index(property, direction=:asc)
else
raise TypeError, "Index direction should be :asc or :desc"
end
- collection.create_index(property => mongo_direction)
+ collection.create_index([[property, mongo_direction]])
end
end
View
17 lib/candy/wrapper.rb
@@ -1,4 +1,4 @@
-require 'mongo'
+require 'bson'
require 'date' # Only so we know what one is. Argh.
require 'candy/qualified_const_get'
@@ -16,10 +16,10 @@ module Wrapper
Float,
Time,
Regexp,
- ByteBuffer,
- Mongo::ObjectID,
- Mongo::Code,
- Mongo::DBRef]
+ BSON::ByteBuffer,
+ BSON::ObjectID,
+ BSON::Code,
+ BSON::DBRef]
# Makes an object safe for the sharp pointy edges of MongoDB. Types properly serialized
# by the BSON.serialize call get passed through unmolested; others are unpacked and their
@@ -28,8 +28,6 @@ def self.wrap(thing)
# Pass the simple cases through
return thing if BSON_SAFE.include?(thing.class)
case thing
- # when Symbol
- # wrap_symbol(thing)
when Array
wrap_array(thing)
when Hash
@@ -71,11 +69,6 @@ def self.wrap_hash(hash)
wrapped
end
- # Returns a string that's distinctive enough for us to unwrap later and produce the same symbol.
- def self.wrap_symbol(symbol)
- "__:" + symbol.to_s
- end
-
# Returns a nested hash containing the class and instance variables of the object. It's not the
# deepest we could ever go (it doesn't handle singleton methods, etc.) but it's a start.
def self.wrap_object(object)
View
4 spec/candy/crunch_spec.rb
@@ -128,12 +128,12 @@ class PeanutBrittle
describe "index" do
it "can be created with just a property name" do
PeanutBrittle.index(:blah)
- PeanutBrittle.collection.index_information.values[1].should == [["blah", Mongo::ASCENDING]]
+ PeanutBrittle.collection.index_information.values[1]['key'].should == {"blah" => Mongo::ASCENDING}
end
it "can be created with a direction" do
PeanutBrittle.index(:fwah, :desc)
- PeanutBrittle.collection.index_information.values[1].should == [["fwah", Mongo::DESCENDING]]
+ PeanutBrittle.collection.index_information.values[1]['key'].should == {"fwah" => Mongo::DESCENDING}
end
it "throws an exception if you give it a type other than :asc or :desc" do
View
4 spec/candy/piece_spec.rb
@@ -21,7 +21,7 @@ class Nougat
it "knows its ID after inserting" do
@this.name = 'Zagnut'
- @this.id.should be_a(Mongo::ObjectID)
+ @this.id.should be_a(BSON::ObjectID)
end
@@ -112,7 +112,7 @@ class Nougat
end
it "returns nil on an object that can't be found" do
- id = Mongo::ObjectID.new
+ id = BSON::ObjectID.new
Zagnut(id).should be_nil
end
View
6 spec/candy/wrapper_spec.rb
@@ -50,7 +50,7 @@ def explode
end
it "can wrap an ObjectID" do
- i = Mongo::ObjectID.new
+ i = BSON::ObjectID.new
Wrapper.wrap(i).should == i
end
@@ -65,12 +65,12 @@ def explode
end
it "can wrap a Mongo code object (if we ever need to)" do
- c = Mongo::Code.new('5')
+ c = BSON::Code.new('5')
Wrapper.wrap(c).should == c
end
it "can wrap a Mongo DBRef (if we ever need to)" do
- d = Mongo::DBRef.new('foo', Mongo::ObjectID.new)
+ d = BSON::DBRef.new('foo', BSON::ObjectID.new)
Wrapper.wrap(d).should == d
end

0 comments on commit 4804f58

Please sign in to comment.