thingtank 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,80 @@
1
+ require_relative 'helper'
2
+ require 'pp'
3
+
4
+ class Car < ThingTank::Role
5
+ property :name
6
+ end
7
+
8
+ class House < ThingTank::Role
9
+ property :name
10
+ end
11
+
12
+ class Ship < ThingTank::Role
13
+ property :name
14
+ property :weight
15
+ end
16
+
17
+
18
+ class Tanker < ThingTank
19
+
20
+ design do
21
+ role_view Car, :by_name, :by => ['name']
22
+ role_view House, :by_name, :by => ['name']
23
+ role_view Ship, :by_name, :by => ['name']
24
+ end
25
+
26
+ end
27
+
28
+
29
+ describe "with a car view" do
30
+
31
+ before do
32
+ reset_test_db!
33
+ end
34
+
35
+ it "should get all cars" do
36
+ car1 = Tanker.create
37
+ car1.as(Car) do |c|
38
+ c.name = "Volvo"
39
+ end
40
+
41
+ car2 = Tanker.create
42
+ car2.as(Car) do |c|
43
+ c.name = "Ferrari"
44
+ end
45
+
46
+ ship = Tanker.create
47
+ ship.as(Ship) do |s|
48
+ s.name = "MS Dolphin"
49
+ s.weight = "1000 pound"
50
+ end
51
+ ship.is(House) # too!
52
+
53
+ ship.save
54
+
55
+ house = Tanker.create
56
+ house.as(House) do |h|
57
+ h.name = "Villa Kunterbunt"
58
+ end
59
+
60
+ house.save
61
+
62
+ car1.save
63
+ car2.save
64
+
65
+ cars = Tanker.car_by_name.rows
66
+ houses = Tanker.house_by_name.rows
67
+ ships = Tanker.ship_by_name.rows
68
+
69
+ assert_equal 2, cars.size
70
+ assert_equal "Ferrari", cars.first["key"]
71
+ assert_equal "Volvo", cars.last["key"]
72
+ assert_equal 2, houses.size # MS Dolphin is a House too!
73
+ assert_equal "Villa Kunterbunt", houses.last["key"]
74
+ assert_equal "MS Dolphin", houses.first["key"]
75
+ assert_equal 1, ships.size
76
+ assert_equal "MS Dolphin", ships.first["key"]
77
+ end
78
+
79
+ end
80
+
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thingtank
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marc Rene Arns
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: couchrest
16
+ requirement: &27295920 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *27295920
25
+ - !ruby/object:Gem::Dependency
26
+ name: couchrest_model
27
+ requirement: &27295340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *27295340
36
+ - !ruby/object:Gem::Dependency
37
+ name: yard
38
+ requirement: &27294780 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.6.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *27294780
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &27294260 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *27294260
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &27293640 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.6.4
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *27293640
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &27293020 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *27293020
80
+ - !ruby/object:Gem::Dependency
81
+ name: linecache19
82
+ requirement: &27292360 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *27292360
91
+ - !ruby/object:Gem::Dependency
92
+ name: ruby-debug19
93
+ requirement: &27291740 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *27291740
102
+ description:
103
+ email: ! 'Base64.decode64(bGludXhAbWFyY3JlbmVhcm5zLmRl
104
+
105
+ )'
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files:
109
+ - LICENSE.txt
110
+ - README.md
111
+ files:
112
+ - .document
113
+ - Gemfile
114
+ - LICENSE.txt
115
+ - README.md
116
+ - Rakefile
117
+ - VERSION
118
+ - examples/bear_julius.rb
119
+ - examples/first_marriage.rb
120
+ - examples/immortal_julius.rb
121
+ - examples/marriage_improvement.rb
122
+ - examples/second_marriage.rb
123
+ - lib/couchrest/extensions/view.rb
124
+ - lib/thingtank.rb
125
+ - lib/thingtank/callbacks.rb
126
+ - lib/thingtank/dependencies.rb
127
+ - lib/thingtank/fakebase.rb
128
+ - lib/thingtank/force_update.rb
129
+ - lib/thingtank/instance_methods.rb
130
+ - lib/thingtank/role.rb
131
+ - lib/thingtank/role_handling.rb
132
+ - lib/thingtank/shared_methods.rb
133
+ - lib/thingtank/shortcuts.rb
134
+ - lib/thingtank/thingtank.rb
135
+ - test/examples/test_bear_julius.rb
136
+ - test/examples/test_first_marriage.rb
137
+ - test/examples/test_immortal_julius.rb
138
+ - test/examples/test_marriage_improvement.rb
139
+ - test/examples/test_second_marriage.rb
140
+ - test/helper.rb
141
+ - test/test_fakebase.rb
142
+ - test/test_thingtank.rb
143
+ - test/test_views.rb
144
+ homepage: http://github.com/metakeule/thingtank
145
+ licenses:
146
+ - MIT
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ segments:
158
+ - 0
159
+ hash: 2907587350418629037
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 1.8.6
169
+ signing_key:
170
+ specification_version: 3
171
+ summary: thin wrapper around couchrest
172
+ test_files: []