factor out deps. formatting code.

This commit is contained in:
ahoward 2012-07-23 18:23:48 -06:00
parent bf57261f19
commit b024d8d707
4 changed files with 445 additions and 392 deletions

View File

@ -1,16 +1,61 @@
require "mongoid"
require "mime/types"
require "digest/md5"
require "cgi"
class GridFS
##
#
class GridFS
const_set :Version, '1.1.0'
class << GridFS
def version
"1.0.0"
const_get :Version
end
def dependencies
{
'mongoid' => [ 'mongoid' , ' >= 3.0.1' ] ,
'mime/types' => [ 'mime-types' , ' >= 1.19' ] ,
}
end
def libdir(*args, &block)
@libdir ||= File.expand_path(__FILE__).sub(/\.rb$/,'')
args.empty? ? @libdir : File.join(@libdir, *args)
ensure
if block
begin
$LOAD_PATH.unshift(@libdir)
block.call()
ensure
$LOAD_PATH.shift()
end
end
end
def load(*libs)
libs = libs.join(' ').scan(/[^\s+]+/)
libdir{ libs.each{|lib| Kernel.load(lib) } }
end
end
begin
require 'rubygems'
rescue LoadError
nil
end
if defined?(gem)
dependencies.each do |lib, dependency|
gem(*dependency)
require(lib)
end
end
require "digest/md5"
require "cgi"
end
##
#
class GridFS
class << GridFS
attr_accessor :namespace
attr_accessor :file_model
attr_accessor :chunk_model
@ -414,6 +459,8 @@ class GridFS
end
end
##
#
GridFs = GridFS
GridFS.init!

View File

@ -3,7 +3,7 @@
Gem::Specification::new do |spec|
spec.name = "mongoid-grid_fs"
spec.version = "1.0.0"
spec.version = "1.1.0"
spec.platform = Gem::Platform::RUBY
spec.summary = "mongoid-grid_fs"
spec.description = "a mongoid 3/moped compatible implementation of the grid_fs specification"
@ -26,6 +26,10 @@ Gem::Specification::new do |spec|
spec.test_files = nil
spec.add_dependency(*["mongoid", " >= 3.0.1"])
spec.add_dependency(*["mime-types", " >= 1.19"])
spec.extensions.push(*[])

Binary file not shown.

View File

@ -142,6 +142,8 @@ Testing GridFs do
protected
def object_id_re
%r| \w{#{ BSON::ObjectId.new.to_s.size }} |iomx
object_id = defined?(Moped) ? Moped::BSON::ObjectId.new : BSON::ObjectId.new
%r| \w{#{ object_id.to_s.size }} |iomx
end
end