peace_love 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -25,7 +25,7 @@ module Bear
25
25
  end
26
26
  end
27
27
 
28
- eg 'loading object' do
28
+ eg 'loading doc' do
29
29
  $db['bears'].remove()
30
30
  $db['bears'].insert(:name => 'yogi', :liver => 'pure', :kind => {:fictional => true, :cartoon => true})
31
31
 
@@ -38,22 +38,36 @@ eg 'loading object' do
38
38
  Show(yogi.kind.for_kids?)
39
39
  end
40
40
 
41
+ eg 'loading a non-existant doc' do
42
+ $db['bears'].remove()
43
+ PeaceLove['bears'].mixin = Bear
44
+ b = PeaceLove['bears'].find_one(:name => 'bertrand')
45
+ Assert( b.nil? )
46
+ end
47
+
41
48
  eg 'wrapping the cursor' do
42
49
  $db['bears'].remove()
43
50
  $db['bears'].insert(:name => 'yogi' , :liver => 'pure', :kind => {:fictional => true, :cartoon => true})
44
51
  $db['bears'].insert(:name => 'humphrey', :liver => 'cihrrotic', :kind => {:fictional => true, :cartoon => false})
45
52
 
53
+ i = 0
46
54
  PeaceLove['bears'].find.each {|b|
47
55
  Show(b)
48
- Show(b.liver)
56
+ if i == 0
57
+ Assert(b.liver == 'PURE')
58
+ elsif i == 1
59
+ Assert(b.liver == 'CIHRROTIC')
60
+ end
61
+ i += 1
49
62
  }
50
63
  end
51
64
 
52
65
  eg 'sub collection' do
53
66
  $db['bears'].remove()
54
- $db['bears'].insert(:name => 'yogi', :liver => 'pure', :kind => {:fictional => true, :cartoon => true}, :lovers => [
55
- {:name => 'mrs. yogi', :liver => 'donated'}, {:name => 'yogi paw', :liver => 'jaundiced'}
56
- ])
67
+ $db['bears'].insert(:name => 'yogi', :liver => 'pure', :kind => {:fictional => true, :cartoon => true}, :lovers =>
68
+ [
69
+ {:name => 'mrs. yogi', :liver => 'donated'}, {:name => 'yogi paw', :liver => 'jaundiced'}
70
+ ])
57
71
 
58
72
  yogi = PeaceLove['bears'].find_one(:name => 'yogi')
59
73
 
@@ -28,6 +28,8 @@ module PeaceLove
28
28
  end
29
29
 
30
30
  def __wrap(hash)
31
+ return nil unless hash.respond_to?(:to_hash)
32
+
31
33
  hash = __extend( AngryHash[ hash ] )
32
34
  hash.extend mixin if mixin
33
35
  hash
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{peace_love}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lachie Cox"]
12
- s.date = %q{2010-06-24}
12
+ s.date = %q{2010-06-28}
13
13
  s.description = %q{A simple mixin layer for enhancing hashes retrieved from MongoDB. It eschews the normal 'mapping' compulsion of mongo libraries.}
14
14
  s.email = %q{lachie@smartbomb.com.au}
15
15
  s.files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lachie Cox
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-24 00:00:00 +10:00
17
+ date: 2010-06-28 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency