worlddb 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,20 +6,28 @@ module Matcher
6
6
 
7
7
  def match_xxx_for_country( name, xxx ) # xxx e.g. cities|regions|beers|breweries
8
8
  # auto-add required country code (from folder structure)
9
- if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/#{xxx}/ || # (1)
10
- name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/#{xxx}/ || # (2)
11
- name =~ /(?:^|\/)([a-z]{2,3})\/#{xxx}/ # (3)
9
+ # note: always let match_xxx_for_country_n_region go first
10
+
11
+ # note: allow /cities and /1--hokkaido--cities
12
+ xxx_pattern = "(?:#{xxx}|[0-9]+--[^\\/]+?--#{xxx})" # note: double escape \\ required for backslash
13
+
14
+ if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/#{xxx_pattern}/ || # (1)
15
+ name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/#{xxx_pattern}/ || # (2)
16
+ name =~ /(?:^|\/)([a-z]{2,3})\/#{xxx_pattern}/ || # (3)
17
+ name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/[0-9]+--[^\/]+\/#{xxx_pattern}/ # (4)
12
18
 
13
19
  country_key = $1.dup
14
20
  yield( country_key )
15
21
  true # bingo - match found
16
22
 
17
23
  ######
18
- # (1) new style: e.g. /at-austria/beers or ^at-austria!/beers
24
+ # (1) new style: e.g. /at-austria/beers or ^at-austria!/cities
19
25
  #
20
- # (2) new-new style e.g. /1--at-austria--central/beers
26
+ # (2) new-new style e.g. /1--at-austria--central/cities
21
27
  #
22
- # (3) classic style: e.g. /at/beers (europe/at/beers)
28
+ # (3) classic style: e.g. /at/beers (europe/at/cities)
29
+ #
30
+ # (4) new style w/ region w/o abbrev/code e.g. /ja-japon/1--hokkaido/cities
23
31
  else
24
32
  false # no match found
25
33
  end
@@ -27,25 +35,29 @@ module Matcher
27
35
 
28
36
  def match_xxx_for_country_n_region( name, xxx ) # xxx e.g. beers|breweries
29
37
  # auto-add required country n region code (from folder structure)
30
- if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/([a-z]{1,3})-[^\/]+\/#{xxx}/ || # (1)
31
- name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/[0-9]+--([a-z]{1,3})-[^\/]+\/#{xxx}/ || # (2)
32
- name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/[0-9]+--([a-z]{1,3})-[^\/]+\/#{xxx}/ || # (3)
33
- name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/([a-z]{1,3})-[^\/]+\/#{xxx}/ # (4)
34
-
38
+
39
+ # note: allow /cities and /1--hokkaido--cities
40
+ xxx_pattern = "(?:#{xxx}|[0-9]+--[^\\/]+?--#{xxx})" # note: double escape \\ required for backslash
41
+
42
+ if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/([a-z]{1,3})-[^\/]+\/#{xxx_pattern}/ || # (1)
43
+ name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/[0-9]+--([a-z]{1,3})-[^\/]+\/#{xxx_pattern}/ || # (2)
44
+ name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/[0-9]+--([a-z]{1,3})-[^\/]+\/#{xxx_pattern}/ || # (3)
45
+ name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/([a-z]{1,3})-[^\/]+\/#{xxx_pattern}/ # (4)
46
+
35
47
  #######
36
48
  # nb: country must start name (^) or coming after / e.g. europe/at-austria/...
37
49
  # (1)
38
- # new style: e.g. /at-austria/w-wien/beers or
39
- # ^at-austria!/w-wien/beers
50
+ # new style: e.g. /at-austria/w-wien/cities or
51
+ # ^at-austria!/w-wien/cities
40
52
  # (2)
41
- # new new style e.g. /1--at-austria--central/1--w-wien--eastern/beers
53
+ # new new style e.g. /1--at-austria--central/1--w-wien--eastern/cities
42
54
  #
43
55
  # (3)
44
- # new new mixed style e.g. /at-austria/1--w-wien--eastern/beers
56
+ # new new mixed style e.g. /at-austria/1--w-wien--eastern/cities
45
57
  # "classic" country plus new new region
46
58
  #
47
59
  # (4)
48
- # new new mixed style e.g. /1--at-austria--central/w-wien/beers
60
+ # new new mixed style e.g. /1--at-austria--central/w-wien/cities
49
61
  # new new country plus "classic" region
50
62
 
51
63
  country_key = $1.dup
@@ -1,6 +1,6 @@
1
1
 
2
2
  module WorldDb
3
- VERSION = '1.8.1' # sync version w/ sport.db - why? why not?
3
+ VERSION = '1.8.2' # sync version w/ sport.db - why? why not?
4
4
  end
5
5
 
6
6
  ###########################################
@@ -14,7 +14,10 @@ class TestFixtureMatchers < MiniTest::Unit::TestCase
14
14
  'europe/at/cities',
15
15
  'europe/at-austria/cities',
16
16
  'at-austria/cities',
17
- 'at-austria!/cities'
17
+ 'at-austria!/cities',
18
+ 'at-austria!/1--niederoesterreich--eastern--cities',
19
+ 'at-austria!/1--niederoesterreich--eastern/cities', # region w/o code/abbrev
20
+ 'at-austria!/1--niederoesterreich--eastern/1--waldviertel--cities'
18
21
  ]
19
22
 
20
23
  cities_at.each do |name|
@@ -33,7 +36,12 @@ class TestFixtureMatchers < MiniTest::Unit::TestCase
33
36
  'at-austria/beers',
34
37
  'at-austria!/beers',
35
38
  '1--at-austria--central/beers',
36
- 'europe/1--at-austria--central/beers'
39
+ '1--at-austria--central/1--niederoesterreich--eastern--beers',
40
+ 'europe/1--at-austria--central/beers',
41
+ 'europe/1--at-austria--central/1--niederosterreich--eastern--beers',
42
+ 'at-austria!/1--niederoesterreich--eastern--beers',
43
+ 'at-austria!/1--niederoesterreich--eastern/beers', # region w/o code/abbrev
44
+ 'at-austria!/1--niederoesterreich--eastern/1--waldviertel--beers'
37
45
  ]
38
46
 
39
47
  beers_at.each do |name|
@@ -64,13 +72,16 @@ class TestFixtureMatchers < MiniTest::Unit::TestCase
64
72
  beers_at = [
65
73
  'europe/at-austria/w-wien/beers',
66
74
  'at-austria/w-wien/beers',
75
+ 'at-austria/w-wien/2--leopoldstadt--beers',
67
76
  'at-austria!/w-wien/beers',
68
77
  '1--at-austria--central/1--w-wien--eastern/beers',
78
+ '1--at-austria--central/1--w-wien--eastern/2--leopoldstadt--beers',
69
79
  'europe/1--at-austria--central/1--w-wien--eastern/beers',
70
80
  'at-austria/1--w-wien--eastern/beers',
71
81
  'europe/at-austria!/1--w-wien--eastern/beers',
72
82
  '1--at-austria--central/w-wien/beers',
73
- 'europe/1--at-austria--central/w-wien/beers'
83
+ 'europe/1--at-austria--central/w-wien/beers',
84
+ 'europe/1--at-austria--central/w-wien/2--leopoldstadt--beers'
74
85
  ]
75
86
 
76
87
  beers_at.each do |name|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worlddb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
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-01-17 00:00:00.000000000 Z
12
+ date: 2014-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: textutils
16
- requirement: &20570436 !ruby/object:Gem::Requirement
16
+ requirement: &21659688 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20570436
24
+ version_requirements: *21659688
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: commander
27
- requirement: &20570136 !ruby/object:Gem::Requirement
27
+ requirement: &21659316 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 4.1.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20570136
35
+ version_requirements: *21659316
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activerecord
38
- requirement: &20569776 !ruby/object:Gem::Requirement
38
+ requirement: &21658944 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *20569776
46
+ version_requirements: *21658944
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &20569236 !ruby/object:Gem::Requirement
49
+ requirement: &21658572 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '4.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *20569236
57
+ version_requirements: *21658572
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &20568840 !ruby/object:Gem::Requirement
60
+ requirement: &21658176 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.7'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *20568840
68
+ version_requirements: *21658176
69
69
  description: worlddb - world.db command line tool
70
70
  email: openmundi@googlegroups.com
71
71
  executables: