minor: removed deprecated @grid.put syntax
This commit is contained in:
parent
1e13187db6
commit
60f72937fd
|
@ -56,14 +56,8 @@ module Mongo
|
||||||
# will be validated using an md5 hash. If validation fails, an exception will be raised.
|
# will be validated using an md5 hash. If validation fails, an exception will be raised.
|
||||||
#
|
#
|
||||||
# @return [Mongo::ObjectID] the file's id.
|
# @return [Mongo::ObjectID] the file's id.
|
||||||
def put(data, opts={}, old_opts={})
|
def put(data, opts={})
|
||||||
if opts.is_a?(String)
|
filename = opts[:filename]
|
||||||
warn "The filename is now optional. Please pass the filename as a hash option: Grid#put(data, :filename => 'file.jpg')."
|
|
||||||
filename = opts
|
|
||||||
opts = old_opts
|
|
||||||
else
|
|
||||||
filename = opts[:filename]
|
|
||||||
end
|
|
||||||
opts.merge!(default_grid_io_opts)
|
opts.merge!(default_grid_io_opts)
|
||||||
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
||||||
file.write(data)
|
file.write(data)
|
||||||
|
|
|
@ -275,7 +275,7 @@ class DBAPITest < Test::Unit::TestCase
|
||||||
def test_index_information
|
def test_index_information
|
||||||
assert_equal @@coll.index_information.length, 1
|
assert_equal @@coll.index_information.length, 1
|
||||||
|
|
||||||
name = @@db.create_index(@@coll.name, 'a')
|
name = @@coll.create_index('a')
|
||||||
info = @@db.index_information(@@coll.name)
|
info = @@db.index_information(@@coll.name)
|
||||||
assert_equal name, "a_1"
|
assert_equal name, "a_1"
|
||||||
assert_equal @@coll.index_information, info
|
assert_equal @@coll.index_information, info
|
||||||
|
@ -303,7 +303,7 @@ class DBAPITest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_multiple_index_cols
|
def test_multiple_index_cols
|
||||||
name = @@db.create_index(@@coll.name, [['a', DESCENDING], ['b', ASCENDING], ['c', DESCENDING]])
|
name = @@coll.create_index([['a', DESCENDING], ['b', ASCENDING], ['c', DESCENDING]])
|
||||||
info = @@db.index_information(@@coll.name)
|
info = @@db.index_information(@@coll.name)
|
||||||
assert_equal 2, info.length
|
assert_equal 2, info.length
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ class DBAPITest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_multiple_index_cols_with_symbols
|
def test_multiple_index_cols_with_symbols
|
||||||
name = @@db.create_index(@@coll.name, [[:a, DESCENDING], [:b, ASCENDING], [:c, DESCENDING]])
|
name = @@coll.create_index([[:a, DESCENDING], [:b, ASCENDING], [:c, DESCENDING]])
|
||||||
info = @@db.index_information(@@coll.name)
|
info = @@db.index_information(@@coll.name)
|
||||||
assert_equal 2, info.length
|
assert_equal 2, info.length
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class GridTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@data = "GRIDDATA" * 50000
|
@data = "GRIDDATA" * 50000
|
||||||
@grid = Grid.new(@db, 'test-fs')
|
@grid = Grid.new(@db, 'test-fs')
|
||||||
@id = @grid.put(@data, 'sample', :metadata => {'app' => 'photos'})
|
@id = @grid.put(@data, :filename => 'sample', :metadata => {'app' => 'photos'})
|
||||||
end
|
end
|
||||||
|
|
||||||
should "retrieve the stored data" do
|
should "retrieve the stored data" do
|
||||||
|
@ -58,7 +58,7 @@ class GridTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "store the file with the old filename api" do
|
should "store the file with the old filename api" do
|
||||||
id = @grid.put(@data, 'sample', :metadata => @metadata)
|
id = @grid.put(@data, :filename => 'sample', :metadata => @metadata)
|
||||||
file = @grid.get(id)
|
file = @grid.get(id)
|
||||||
assert_equal 'sample', file.filename
|
assert_equal 'sample', file.filename
|
||||||
assert_equal @metadata, file.metadata
|
assert_equal @metadata, file.metadata
|
||||||
|
@ -106,7 +106,7 @@ class GridTest < Test::Unit::TestCase
|
||||||
context "Storing data with a length of zero" do
|
context "Storing data with a length of zero" do
|
||||||
setup do
|
setup do
|
||||||
@grid = Grid.new(@db, 'test-fs')
|
@grid = Grid.new(@db, 'test-fs')
|
||||||
@id = @grid.put('', 'sample', :metadata => {'app' => 'photos'})
|
@id = @grid.put('', :filename => 'sample', :metadata => {'app' => 'photos'})
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the zero length" do
|
should "return the zero length" do
|
||||||
|
@ -119,7 +119,7 @@ class GridTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
def read_and_write_stream(filename, read_length, opts={})
|
def read_and_write_stream(filename, read_length, opts={})
|
||||||
io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r')
|
io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r')
|
||||||
id = @grid.put(io, filename + read_length.to_s, opts)
|
id = @grid.put(io, opts.merge!(:filename => filename + read_length.to_s))
|
||||||
file = @grid.get(id)
|
file = @grid.get(id)
|
||||||
io.rewind
|
io.rewind
|
||||||
data = io.read
|
data = io.read
|
||||||
|
|
Loading…
Reference in New Issue