dkastner-moneta 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source :rubygems
2
2
 
3
3
  gemspec
4
+
5
+ gem 'mongo'
@@ -14,22 +14,27 @@ module Moneta
14
14
  include Moneta::Defaults
15
15
 
16
16
  def initialize(options = {})
17
- if options[:uri]
18
- conn = Mongo::Connection.from_uri options[:uri]
19
- db_name = URI.parse(options[:uri]).path.sub('/','')
20
- db_name ||= options[:db]
17
+ collection = options.delete(:collection) || 'cache'
18
+
19
+ if uri = options.delete(:uri)
20
+ db_name = URI.parse(uri).path.sub('/','')
21
+ db_name ||= options.delete :db
22
+ conn = Mongo::Connection.from_uri uri, options
21
23
  else
22
24
  options = {
23
25
  :host => ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
24
26
  :port => ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT,
25
- :db => 'cache',
26
- :collection => 'cache'
27
+ :db => 'cache'
27
28
  }.update(options)
28
- conn = Mongo::Connection.new(options[:host], options[:port])
29
- db_name = options[:db]
29
+
30
+ host = options.delete :host
31
+ port = options.delete :port
32
+ db_name = options.delete :db
33
+
34
+ conn = Mongo::Connection.new(host, port, options)
30
35
  end
31
- db = conn.db(db_name)
32
- @cache = db.collection(options[:collection])
36
+ db = conn.db db_name
37
+ @cache = db.collection collection
33
38
  end
34
39
 
35
40
  def key?(key, *)
@@ -1,3 +1,3 @@
1
1
  module Moneta
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -13,7 +13,7 @@ begin
13
13
  it 'should initialize with a URI' do
14
14
  mock_mongo = mock(Object, :db => mock(Object, :collection => []))
15
15
  Mongo::Connection.should_receive(:from_uri).
16
- with('mongodb://a:b@localhost:27059/cache').
16
+ with('mongodb://a:b@localhost:27059/cache', {}).
17
17
  and_return mock_mongo
18
18
  m = Moneta::Adapters::MongoDB.new :uri => 'mongodb://a:b@localhost:27059/cache'
19
19
  end
@@ -22,6 +22,14 @@ begin
22
22
  m['example'] = 3.0
23
23
  m['example'].should == 3.0
24
24
  end
25
+ it 'should pass any extra options to Mongo::Connection.new' do
26
+ mock_mongo = mock(Object, :db => mock(Object, :collection => nil))
27
+ Mongo::Connection.should_receive(:new).with('localhost', 27059,
28
+ hash_including(:pool_size => 5, :timeout => 22)).
29
+ and_return(mock_mongo)
30
+ m = Moneta::Adapters::MongoDB.new :uri => 'mongodb://a:b@localhost:27059/cache',
31
+ :pool_size => 5, :timeout => 22
32
+ end
25
33
  end
26
34
 
27
35
  context 'initialized' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dkastner-moneta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-02-10 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- requirement: &2154443400 !ruby/object:Gem::Requirement
17
+ requirement: &2160566480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2154443400
25
+ version_requirements: *2160566480
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2154442860 !ruby/object:Gem::Requirement
28
+ requirement: &2160566060 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2154442860
36
+ version_requirements: *2160566060
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &2154441780 !ruby/object:Gem::Requirement
39
+ requirement: &2160565640 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2154441780
47
+ version_requirements: *2160565640
48
48
  description: A unified interface to key/value stores
49
49
  email:
50
50
  - wycats@gmail.com
@@ -120,18 +120,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  - - ! '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
- segments:
124
- - 0
125
- hash: -3990472740534807466
126
123
  required_rubygems_version: !ruby/object:Gem::Requirement
127
124
  none: false
128
125
  requirements:
129
126
  - - ! '>='
130
127
  - !ruby/object:Gem::Version
131
128
  version: '0'
132
- segments:
133
- - 0
134
- hash: -3990472740534807466
135
129
  requirements: []
136
130
  rubyforge_project:
137
131
  rubygems_version: 1.8.5