winedb 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/winedb.rb +1 -2
- data/lib/winedb/models/forward.rb +13 -1
- data/lib/winedb/models/person.rb +7 -5
- data/lib/winedb/reader.rb +8 -1
- data/lib/winedb/schema.rb +0 -30
- data/lib/winedb/version.rb +1 -1
- data/test/helper.rb +6 -4
- data/test/test_fixture_matchers.rb +13 -6
- metadata +23 -12
data/Rakefile
CHANGED
data/lib/winedb.rb
CHANGED
@@ -7,6 +7,7 @@ require 'active_record' ## todo: add sqlite3? etc.
|
|
7
7
|
require 'logutils'
|
8
8
|
require 'textutils'
|
9
9
|
require 'worlddb'
|
10
|
+
require 'persondb'
|
10
11
|
|
11
12
|
|
12
13
|
### our own code
|
@@ -75,7 +76,6 @@ module WineDb
|
|
75
76
|
Model::Family.delete_all
|
76
77
|
Model::Variety.delete_all
|
77
78
|
Model::Vineyard.delete_all
|
78
|
-
Model::Person.delete_all
|
79
79
|
Model::Shop.delete_all
|
80
80
|
Model::Tavern.delete_all
|
81
81
|
Model::Vintage.delete_all
|
@@ -89,7 +89,6 @@ module WineDb
|
|
89
89
|
puts " #{Model::Family.count} (wine) families"
|
90
90
|
puts " #{Model::Variety.count} (wine) varieties"
|
91
91
|
puts " #{Model::Vineyard.count} vineyards"
|
92
|
-
puts " #{Model::Person.count} persons (winemakers)"
|
93
92
|
puts " #{Model::Shop.count} shops (vinothek/enotecia)"
|
94
93
|
puts " #{Model::Tavern.count} taverns (heurige)"
|
95
94
|
puts " #{Model::Vintage.count} vintages"
|
@@ -17,13 +17,15 @@ module WineDb
|
|
17
17
|
|
18
18
|
Prop = WorldDb::Model::Prop
|
19
19
|
|
20
|
+
Person = PersonDb::Model::Person
|
21
|
+
|
22
|
+
|
20
23
|
class Wine < ActiveRecord::Base ; end
|
21
24
|
class Winery < ActiveRecord::Base ; end
|
22
25
|
class Grape < ActiveRecord::Base ; end
|
23
26
|
class Family < ActiveRecord::Base ; end
|
24
27
|
class Variety < ActiveRecord::Base ; end
|
25
28
|
class Vineyard < ActiveRecord::Base ; end
|
26
|
-
class Person < ActiveRecord::Base ; end
|
27
29
|
class Shop < ActiveRecord::Base ; end
|
28
30
|
class Tavern < ActiveRecord::Base ; end
|
29
31
|
class Vintage < ActiveRecord::Base ; end
|
@@ -45,3 +47,13 @@ module WorldDb
|
|
45
47
|
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
module PersonDb
|
52
|
+
module Model
|
53
|
+
|
54
|
+
Wine = WineDb::Model::Wine
|
55
|
+
Winery = WineDb::Model::Winery
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/winedb/models/person.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
########
|
4
|
+
# NOTE: model resides in persondb gem
|
5
|
+
|
6
|
+
module PersonDb
|
4
7
|
module Model
|
5
8
|
|
6
9
|
###
|
7
|
-
#
|
10
|
+
# extensions for winemaker
|
8
11
|
|
9
|
-
class Person
|
12
|
+
class Person
|
10
13
|
|
11
|
-
self.table_name = 'persons'
|
12
14
|
## to be done
|
13
15
|
|
14
16
|
end # class Person
|
15
17
|
|
16
18
|
end # module Model
|
17
|
-
end # module
|
19
|
+
end # module PersonDb
|
data/lib/winedb/reader.rb
CHANGED
@@ -61,6 +61,7 @@ module Matcher
|
|
61
61
|
|
62
62
|
|
63
63
|
def match_wines_for_country( name, &blk )
|
64
|
+
## check: allow/add synonyms e.g. weine, vinos etc. ???
|
64
65
|
match_xxx_for_country( name, 'wines', &blk )
|
65
66
|
end
|
66
67
|
|
@@ -73,6 +74,7 @@ module Matcher
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def match_wineries_for_country_n_region( name, &blk )
|
77
|
+
## check: allow/add synonyms e.g. producers ? weingueter ??
|
76
78
|
fix_match_xxx_for_country_n_region( name, 'wineries', &blk )
|
77
79
|
end
|
78
80
|
|
@@ -82,13 +84,18 @@ module Matcher
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def match_shops_for_country_n_region( name, &blk )
|
87
|
+
## check: allow/add synonyms e.g. vinotheken, enotecas
|
85
88
|
fix_match_xxx_for_country_n_region( name, 'shops', &blk )
|
86
89
|
end
|
87
90
|
|
88
91
|
def match_taverns_for_country_n_region( name, &blk )
|
89
|
-
|
92
|
+
## also try synonyms e.g. heurige (if not match for taverns)
|
93
|
+
found = fix_match_xxx_for_country_n_region( name, 'taverns', &blk )
|
94
|
+
found = fix_match_xxx_for_country_n_region( name, 'heurige', &blk ) unless found
|
95
|
+
found
|
90
96
|
end
|
91
97
|
|
98
|
+
|
92
99
|
end # module Matcher
|
93
100
|
|
94
101
|
|
data/lib/winedb/schema.rb
CHANGED
@@ -191,36 +191,6 @@ create_table :vineyards do |t|
|
|
191
191
|
t.timestamps
|
192
192
|
end
|
193
193
|
|
194
|
-
#########################
|
195
|
-
# persons (wine makers)
|
196
|
-
# e.g. Anton Bauer (1971) etc.
|
197
|
-
#
|
198
|
-
# note: use persons table (not makers table) and use kind/typ for (wine)maker
|
199
|
-
#
|
200
|
-
# todo: move persons to friends.db project for (re)use;
|
201
|
-
# see player in football.db too ???
|
202
|
-
# and drivers in formula1.db too and
|
203
|
-
# and skiers in ski.db etc.
|
204
|
-
|
205
|
-
create_table :persons do |t| # use people ? instead of persons (person/persons makes it easier?)
|
206
|
-
t.string :key, null: false # import/export key
|
207
|
-
t.string :name, null: false
|
208
|
-
t.string :synonyms # comma separated list of synonyms
|
209
|
-
|
210
|
-
## todo: add gender flag (male/female -man/lady how?)
|
211
|
-
t.date :born_at # optional date of birth (birthday)
|
212
|
-
## todo: add country of birth might not be the same as nationality
|
213
|
-
|
214
|
-
t.references :city
|
215
|
-
t.references :region
|
216
|
-
t.references :country ## , null: false
|
217
|
-
|
218
|
-
t.references :nationality ## , null: false # by default assume same as country of birth (see above)
|
219
|
-
|
220
|
-
t.timestamps
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
194
|
|
225
195
|
end # method up
|
226
196
|
|
data/lib/winedb/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -25,9 +25,11 @@ require 'active_record'
|
|
25
25
|
require 'winedb'
|
26
26
|
require 'logutils/db' # NB: explict require required for LogDb (not automatic)
|
27
27
|
|
28
|
-
Country
|
29
|
-
Region
|
30
|
-
City
|
28
|
+
Country = WorldDb::Model::Country
|
29
|
+
Region = WorldDb::Model::Region
|
30
|
+
City = WorldDb::Model::City
|
31
|
+
|
32
|
+
Person = PersonDb::Model::Person
|
31
33
|
|
32
34
|
## todo: get all models aliases (e.g. from console script)
|
33
35
|
|
@@ -35,7 +37,6 @@ Grape = WineDb::Model::Grape
|
|
35
37
|
Family = WineDb::Model::Family
|
36
38
|
Variety = WineDb::Model::Variety
|
37
39
|
Vineyard = WineDb::Model::Vineyard
|
38
|
-
Person = WineDb::Model::Person
|
39
40
|
Shop = WineDb::Model::Shop
|
40
41
|
Tavern = WineDb::Model::Tavern
|
41
42
|
Vintage = WineDb::Model::Vintage
|
@@ -65,6 +66,7 @@ def setup_in_memory_db
|
|
65
66
|
|
66
67
|
LogDb.create
|
67
68
|
WorldDb.create
|
69
|
+
PersonDb.create
|
68
70
|
WineDb.create
|
69
71
|
end
|
70
72
|
|
@@ -126,17 +126,24 @@ class TestFixtureMatchers < MiniTest::Unit::TestCase
|
|
126
126
|
|
127
127
|
|
128
128
|
def test_misc
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
taverns = [
|
130
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram/feuersbrunn--taverns',
|
131
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram/feuersbrunn--heurige'
|
132
|
+
]
|
132
133
|
|
133
|
-
|
134
|
+
taverns.each do |tavern|
|
135
|
+
found = match_taverns_for_country_n_region( tavern ) do |country_key,region_key|
|
134
136
|
assert( country_key == 'at')
|
135
137
|
assert( region_key == 'n' )
|
138
|
+
end
|
139
|
+
assert( found == true )
|
136
140
|
end
|
137
|
-
assert( found == true )
|
138
141
|
|
139
|
-
|
142
|
+
|
143
|
+
vineyards = 'at-austria!/1--n-niederoesterreich--eastern/wagram/feuersbrunn--vineyards'
|
144
|
+
shops = 'at-austria!/1--n-niederoesterreich--eastern/wagram/shops'
|
145
|
+
|
146
|
+
found = match_vineyards_for_country_n_region( vineyards ) do |country_key,region_key|
|
140
147
|
assert( country_key == 'at')
|
141
148
|
assert( region_key == 'n' )
|
142
149
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winedb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &75024810 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *75024810
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: worlddb
|
27
|
-
requirement: &
|
27
|
+
requirement: &75024420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: '1.7'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *75024420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: persondb
|
38
|
+
requirement: &75024150 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *75024150
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: gli
|
38
|
-
requirement: &
|
49
|
+
requirement: &75023560 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: 2.5.6
|
44
55
|
type: :runtime
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *75023560
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rdoc
|
49
|
-
requirement: &
|
60
|
+
requirement: &75022950 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ~>
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '3.10'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *75022950
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: hoe
|
60
|
-
requirement: &
|
71
|
+
requirement: &75022510 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ~>
|
@@ -65,7 +76,7 @@ dependencies:
|
|
65
76
|
version: '3.3'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *75022510
|
69
80
|
description: winedb - wine.db command line tool
|
70
81
|
email: winedb@googlegroups.com
|
71
82
|
executables: []
|