adapter-mongo 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -7,3 +7,4 @@ rvm:
7
7
  notifications:
8
8
  email: false
9
9
  bundler_args: --without development
10
+ services: mongodb
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency 'adapter', '~> 0.5'
20
+ s.add_dependency 'adapter', '~> 0.6.1'
21
21
  s.add_dependency 'mongo', '~> 1.5'
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module Adapter
2
2
  module Mongo
3
- VERSION = "0.5.6"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
data/lib/adapter/mongo.rb CHANGED
@@ -3,8 +3,6 @@ require 'mongo'
3
3
 
4
4
  module Adapter
5
5
  module Mongo
6
- NonHashValueKeyName = '_value'
7
-
8
6
  def read(key)
9
7
  if doc = client.find_one('_id' => key_for(key))
10
8
  decode(doc)
@@ -23,22 +21,9 @@ module Adapter
23
21
  client.remove
24
22
  end
25
23
 
26
- def key_for(key)
27
- case key
28
- when BSON::ObjectId, Hash
29
- key
30
- else
31
- super
32
- end
33
- end
34
-
35
- def encode(value)
36
- value.is_a?(Hash) ? value : {NonHashValueKeyName => value}
37
- end
38
-
39
24
  def decode(value)
40
- return if value.nil?
41
- value.key?(NonHashValueKeyName) ? value[NonHashValueKeyName] : value
25
+ value.delete('_id')
26
+ value
42
27
  end
43
28
  end
44
29
  end
data/spec/helper.rb CHANGED
@@ -7,7 +7,6 @@ require 'bundler'
7
7
  Bundler.require(:default, :test)
8
8
 
9
9
  require 'adapter/spec/an_adapter'
10
- require 'adapter/spec/types'
11
10
  require 'adapter-mongo'
12
11
 
13
12
  require 'support/shared_mongo_adapter'
@@ -19,7 +19,6 @@ describe "Mongo atomic adapter" do
19
19
  adapter.write(oid, {'a' => 'c', 'b' => 'd'})
20
20
  adapter.write(oid, {'a' => 'z'})
21
21
  adapter.read(oid).should eq({
22
- '_id' => oid,
23
22
  'a' => 'z',
24
23
  'b' => 'd',
25
24
  })
@@ -1,33 +1,28 @@
1
1
  shared_examples_for "a mongo adapter" do
2
2
  it_should_behave_like 'an adapter'
3
3
 
4
- Adapter::Spec::Types.each do |type, (key, key2)|
5
- it "writes Object values to keys that are #{type}s like a Hash" do
6
- adapter[key] = {:foo => :bar}
7
- # mongo knows hashes and can serialize symbol values
8
- adapter[key].should == {'_id' => 'key', 'foo' => :bar}
9
- end
10
- end
11
-
12
4
  it "allows using object id's as keys in correct type" do
13
5
  id = BSON::ObjectId.new
14
- adapter.write(id, 'ham')
6
+ attributes = {'one' => 'two'}
7
+ adapter.write(id, attributes)
15
8
  client.find_one('_id' => id).should_not be_nil
16
- adapter.read(id).should == 'ham'
9
+ adapter.read(id).should == attributes
17
10
  end
18
11
 
19
12
  it "allows using ordered hashes as keys" do
20
13
  key = BSON::OrderedHash['d', 1, 'n', 1]
21
- adapter.write(key, 'ham')
14
+ attributes = {'one' => 'two'}
15
+ adapter.write(key, attributes)
22
16
  client.find_one('_id' => key).should_not be_nil
23
- adapter.read(key).should == 'ham'
17
+ adapter.read(key).should == attributes
24
18
  end
25
19
 
26
20
  it "allows using hashes as keys" do
27
21
  key = {:d => 1}
28
- adapter.write(key, 'ham')
22
+ attributes = {'one' => 'two'}
23
+ adapter.write(key, attributes)
29
24
  client.find_one('_id' => key).should_not be_nil
30
- adapter.read(key).should == 'ham'
25
+ adapter.read(key).should == attributes
31
26
  end
32
27
 
33
28
  it "stores hashes right in document" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adapter-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: adapter
16
- requirement: &70364766280940 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.5'
21
+ version: 0.6.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70364766280940
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.6.1
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mongo
27
- requirement: &70364766280440 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '1.5'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70364766280440
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.5'
36
46
  description: Adapter for mongo
37
47
  email:
38
48
  - nunemaker@gmail.com
@@ -73,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
83
  version: '0'
74
84
  segments:
75
85
  - 0
76
- hash: 3131877323408847219
86
+ hash: -1642697742902591333
77
87
  required_rubygems_version: !ruby/object:Gem::Requirement
78
88
  none: false
79
89
  requirements:
@@ -82,10 +92,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
92
  version: '0'
83
93
  segments:
84
94
  - 0
85
- hash: 3131877323408847219
95
+ hash: -1642697742902591333
86
96
  requirements: []
87
97
  rubyforge_project:
88
- rubygems_version: 1.8.10
98
+ rubygems_version: 1.8.23
89
99
  signing_key:
90
100
  specification_version: 3
91
101
  summary: Adapter for mongo