-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
executable file
·54 lines (45 loc) · 1.2 KB
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'rouge'
cmds = [
{'group' => 'wine',
'data' => {
'name' => 'super',
'grape' => 'valpolicella',
'price' => '23.00',
'year' => '1998',
'flavour' => 'cherry',
'region' => 'roma',
'country' => 'italy'}
},
{'group' => 'wine',
'data' => {
'name' => 'woofer',
'grape' => 'shiraz',
'price' => '22.00',
'year' => '2001',
'flavour' => 'chocolate',
'region' => 'alcoy',
'country' => 'spain'}
},
{'group' => 'wine',
'data' => {
'name' => 'fuffer',
'grape' => 'shiraz',
'price' => '8.00',
'year' => '1999',
'flavour' => 'nuts',
'region' => 'ottawotta',
'country' => 'italy'}
}
]
r = Rouge.new
# Clear the database of all data for testing
r.cmd "flushall"
# Add some data ...
cmds.each do |x|
group, data = x['group'], x['data']
r.store_record(group, data)
end
# These are the bits of info I want from the database
fields_I_want = ["price", "year", "grape"]
# I want the first highest priced wines
p r.sort("wine", "price", 0, 3, fields_I_want)