Skip to content

Commit

Permalink
Updated to Mongo gems v0.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SFEley committed Apr 12, 2010
1 parent cab223e commit 4804f58
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Rakefile
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/candy/crunch.rb
Expand Up @@ -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

Expand Down
17 changes: 5 additions & 12 deletions 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'

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/candy/crunch_spec.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/candy/piece_spec.rb
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/candy/wrapper_spec.rb
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 4804f58

Please sign in to comment.