winedb 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -0
- data/lib/winedb/reader.rb +35 -7
- data/lib/winedb/version.rb +1 -1
- data/test/test_fixture_matchers.rb +120 -0
- metadata +14 -12
data/Manifest.txt
CHANGED
data/lib/winedb/reader.rb
CHANGED
@@ -9,17 +9,37 @@ module Matcher
|
|
9
9
|
match_xxx_for_country( name, 'wines', &blk )
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def match_wines_for_country_n_region( name, &blk )
|
13
|
+
### fix allow prefixes for wines (move into core!!!) e.g.
|
14
|
+
##
|
15
|
+
# at-austria!/1--n-niederoesterreich--eastern/wagram--wines
|
16
|
+
# at-austria!/1--n-niederoesterreich--eastern/wagram--wagram--wines
|
17
|
+
|
18
|
+
### strip subregion if present e.g.
|
19
|
+
# /wagram--wines becomes /wines n
|
20
|
+
# /wagram--wagram--wines becomes / wines etc.
|
21
|
+
name_fixed = name.sub( /\/([a-z]+--)*wines$/, "/wines" )
|
22
|
+
|
23
|
+
match_xxx_for_country_n_region( name_fixed, 'wines', &blk )
|
24
|
+
end
|
15
25
|
|
16
26
|
def match_wineries_for_country( name, &blk )
|
17
27
|
match_xxx_for_country( name, 'wineries', &blk )
|
18
28
|
end
|
19
29
|
|
20
|
-
|
21
|
-
|
22
|
-
|
30
|
+
def match_wineries_for_country_n_region( name, &blk )
|
31
|
+
### fix allow prefixes for wineries (move into core!!!) e.g.
|
32
|
+
##
|
33
|
+
# at-austria!/1--n-niederoesterreich--eastern/wagram--wineries
|
34
|
+
# at-austria!/1--n-niederoesterreich--eastern/wagram--wagram--wineries
|
35
|
+
|
36
|
+
### strip subregion if present e.g.
|
37
|
+
# /wagram--wineries becomes /wineries n
|
38
|
+
# /wagram--wagram--wineries becomes / wineries etc.
|
39
|
+
name_fixed = name.sub( /\/([a-z]+--)*wineries$/, "/wineries" )
|
40
|
+
|
41
|
+
match_xxx_for_country_n_region( name_fixed, 'wineries', &blk )
|
42
|
+
end
|
23
43
|
|
24
44
|
end # module Matcher
|
25
45
|
|
@@ -56,9 +76,17 @@ class Reader
|
|
56
76
|
|
57
77
|
def load( name )
|
58
78
|
|
59
|
-
if
|
79
|
+
if match_wines_for_country_n_region( name ) do |country_key, region_key|
|
80
|
+
### fix: use region_key too
|
81
|
+
load_wines_for_country( country_key, name )
|
82
|
+
end
|
83
|
+
elsif match_wines_for_country( name ) do |country_key|
|
60
84
|
load_wines_for_country( country_key, name )
|
61
85
|
end
|
86
|
+
elsif match_wineries_for_country_n_region( name ) do |country_key, region_key|
|
87
|
+
### fix: use region_key too
|
88
|
+
load_wineries_for_country( country_key, name )
|
89
|
+
end
|
62
90
|
elsif match_wineries_for_country( name ) do |country_key|
|
63
91
|
load_wineries_for_country( country_key, name )
|
64
92
|
end
|
data/lib/winedb/version.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
require 'helper'
|
5
|
+
|
6
|
+
### todo/fix: move to worlddb along with fixture matcher module!!
|
7
|
+
|
8
|
+
class TestFixtureMatchers < MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
include WorldDb::Matcher
|
11
|
+
include WineDb::Matcher
|
12
|
+
|
13
|
+
|
14
|
+
def test_country
|
15
|
+
|
16
|
+
wines_at = [
|
17
|
+
'europe/at/wines',
|
18
|
+
'europe/at-austria/wines',
|
19
|
+
'at-austria/wines',
|
20
|
+
'at-austria!/wines',
|
21
|
+
'1--at-austria--central/wines',
|
22
|
+
'europe/1--at-austria--central/wines'
|
23
|
+
]
|
24
|
+
|
25
|
+
wines_at.each do |name|
|
26
|
+
found = match_wines_for_country( name ) do |country_key|
|
27
|
+
assert( country_key == 'at')
|
28
|
+
end
|
29
|
+
assert( found == true )
|
30
|
+
end
|
31
|
+
|
32
|
+
wineries_at = [
|
33
|
+
'europe/at/wineries',
|
34
|
+
'europe/at-austria/wineries',
|
35
|
+
'at-austria/wineries',
|
36
|
+
'at-austria!/wineries',
|
37
|
+
'1--at-austria--central/wineries',
|
38
|
+
'europe/1--at-austria--central/wineries'
|
39
|
+
]
|
40
|
+
|
41
|
+
wineries_at.each do |name|
|
42
|
+
found = match_wineries_for_country( name ) do |country_key|
|
43
|
+
assert( country_key == 'at')
|
44
|
+
end
|
45
|
+
assert( found == true )
|
46
|
+
end
|
47
|
+
end # method test_country
|
48
|
+
|
49
|
+
|
50
|
+
def test_country_n_region
|
51
|
+
|
52
|
+
wines_at = [
|
53
|
+
'europe/at-austria/n-niederoesterreich/wines',
|
54
|
+
'at-austria/n-niederoesterreich/wines',
|
55
|
+
'at-austria!/n-niederoesterreich/wines',
|
56
|
+
'1--at-austria--central/1--n-niederoesterreich--eastern/wines',
|
57
|
+
'europe/1--at-austria--central/1--n-niederoesterreich--eastern/wines'
|
58
|
+
]
|
59
|
+
|
60
|
+
wines_at.each do |name|
|
61
|
+
found = match_wines_for_country_n_region( name ) do |country_key,region_key|
|
62
|
+
assert( country_key == 'at')
|
63
|
+
assert( region_key == 'n' )
|
64
|
+
end
|
65
|
+
assert( found == true )
|
66
|
+
end
|
67
|
+
|
68
|
+
wineries_at = [
|
69
|
+
'europe/at-austria/n-niederoesterreich/wineries',
|
70
|
+
'at-austria/n-niederoesterreich/wineries',
|
71
|
+
'at-austria!/n-niederoesterreich/wineries',
|
72
|
+
'1--at-austria--central/1--n-niederoesterreich--eastern/wineries',
|
73
|
+
'europe/1--at-austria--central/1--n-niederoesterreich--eastern/wineries'
|
74
|
+
]
|
75
|
+
|
76
|
+
wineries_at.each do |name|
|
77
|
+
found = match_wineries_for_country_n_region( name ) do |country_key,region_key|
|
78
|
+
assert( country_key == 'at')
|
79
|
+
assert( region_key == 'n' )
|
80
|
+
end
|
81
|
+
assert( found == true )
|
82
|
+
end
|
83
|
+
end # method test_country_n_region
|
84
|
+
|
85
|
+
|
86
|
+
def test_wine_region ### sub region e.g. wagram, wachau, etc.
|
87
|
+
|
88
|
+
wines_at = [
|
89
|
+
'at-austria!/1--n-niederoesterreich--eastern/wines',
|
90
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--wines',
|
91
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--feuersbrunn--wines',
|
92
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--wagram--wines'
|
93
|
+
]
|
94
|
+
|
95
|
+
wines_at.each do |name|
|
96
|
+
found = match_wines_for_country_n_region( name ) do |country_key,region_key|
|
97
|
+
assert( country_key == 'at')
|
98
|
+
assert( region_key == 'n' )
|
99
|
+
end
|
100
|
+
assert( found == true )
|
101
|
+
end
|
102
|
+
|
103
|
+
wineries_at = [
|
104
|
+
'at-austria!/1--n-niederoesterreich--eastern/wineries',
|
105
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--wineries',
|
106
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--feuersbrunn--wineries',
|
107
|
+
'at-austria!/1--n-niederoesterreich--eastern/wagram--wagram--wineries'
|
108
|
+
]
|
109
|
+
|
110
|
+
wineries_at.each do |name|
|
111
|
+
found = match_wineries_for_country_n_region( name ) do |country_key,region_key|
|
112
|
+
assert( country_key == 'at')
|
113
|
+
assert( region_key == 'n' )
|
114
|
+
end
|
115
|
+
assert( found == true )
|
116
|
+
end
|
117
|
+
end # method test_wine_region
|
118
|
+
|
119
|
+
|
120
|
+
end # class TestFixtureMatchers
|
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.1
|
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-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &71105380 !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: *71105380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: worlddb
|
27
|
-
requirement: &
|
27
|
+
requirement: &71105150 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.7'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *71105150
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: gli
|
38
|
-
requirement: &
|
38
|
+
requirement: &71104870 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.5.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *71104870
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &71104610 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.10'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *71104610
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe
|
60
|
-
requirement: &
|
60
|
+
requirement: &71104340 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '3.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *71104340
|
69
69
|
description: winedb - wine.db command line tool
|
70
70
|
email: winedb@googlegroups.com
|
71
71
|
executables: []
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/winedb/schema.rb
|
90
90
|
- lib/winedb/version.rb
|
91
91
|
- test/helper.rb
|
92
|
+
- test/test_fixture_matchers.rb
|
92
93
|
- test/test_models.rb
|
93
94
|
- .gemtest
|
94
95
|
homepage: https://github.com/geraldb/wine.db.ruby
|
@@ -120,3 +121,4 @@ specification_version: 3
|
|
120
121
|
summary: winedb - wine.db command line tool
|
121
122
|
test_files:
|
122
123
|
- test/test_models.rb
|
124
|
+
- test/test_fixture_matchers.rb
|