beerdb 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -30,4 +30,5 @@ lib/beerdb/server/views/layout.erb
30
30
  lib/beerdb/stats.rb
31
31
  lib/beerdb/version.rb
32
32
  test/helper.rb
33
+ test/test_fixture_matchers.rb
33
34
  test/test_values.rb
data/lib/beerdb/reader.rb CHANGED
@@ -13,25 +13,25 @@ module BeerDb
13
13
 
14
14
  module FixtureMatcher
15
15
 
16
- def match_xxx_for_country( name, xxx ) # xxx e.g. beers|breweries
16
+ def match_xxx_for_country( name, xxx, blk ) # xxx e.g. beers|breweries
17
17
  if name =~ /(?:^|\/)([a-z]{2})-[^\/]+\/#{xxx}/
18
18
  # new style: e.g. /at-austria/beers or ^at-austria!/beers
19
19
  # auto-add required country code (from folder structure)
20
20
  country_key = $1.dup
21
- yield( country_key )
21
+ blk.call( country_key )
22
22
  true # bingo - match found
23
23
  elsif name =~ /\/([a-z]{2})\/#{xxx}/
24
24
  # classic style: e.g. /at/beers (europe/at/beers)
25
25
  # auto-add required country code (from folder structure)
26
26
  country_key = $1.dup
27
- yield( country_key )
27
+ blk.call( country_key )
28
28
  true
29
29
  else
30
30
  false # no match found
31
31
  end
32
32
  end
33
33
 
34
- def match_xxx_for_country_n_region( name, xxx ) # xxx e.g. beers|breweries
34
+ def match_xxx_for_country_n_region( name, xxx, blk ) # xxx e.g. beers|breweries
35
35
  if name =~ /(?:^|\/)([a-z]{2})-[^\/]+\/([a-z]{1,2})-[^\/]+\/#{xxx}/
36
36
  # new style: e.g. /at-austria/w-wien/beers or
37
37
  # ^at-austria!/w-wien/beers
@@ -40,7 +40,7 @@ module FixtureMatcher
40
40
  # auto-add required country n region code (from folder structure)
41
41
  country_key = $1.dup
42
42
  region_key = $2.dup
43
- yield( country_key, region_key )
43
+ blk.call( country_key, region_key )
44
44
  true # bingo - match found
45
45
  else
46
46
  false # no match found
@@ -48,20 +48,20 @@ module FixtureMatcher
48
48
  end
49
49
 
50
50
 
51
- def match_beers_for_country( name, &block )
52
- match_xxx_for_country( name, 'beers', block )
51
+ def match_beers_for_country( name, &blk )
52
+ match_xxx_for_country( name, 'beers', blk )
53
53
  end
54
54
 
55
- def match_beers_for_country_n_region( name, &block )
56
- match_xxx_for_country_n_region( name, 'beers', block )
55
+ def match_beers_for_country_n_region( name, &blk )
56
+ match_xxx_for_country_n_region( name, 'beers', blk )
57
57
  end
58
58
 
59
- def match_breweries_for_country( name, &block )
60
- match_xxx_for_country( name, 'breweries', block )
59
+ def match_breweries_for_country( name, &blk )
60
+ match_xxx_for_country( name, 'breweries', blk )
61
61
  end
62
62
 
63
- def match_breweries_for_country_n_region( name, &block )
64
- match_xxx_for_country_n_region( name, 'breweries', block )
63
+ def match_breweries_for_country_n_region( name, &blk )
64
+ match_xxx_for_country_n_region( name, 'breweries', blk )
65
65
  end
66
66
 
67
67
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BeerDb
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
4
4
  end
@@ -0,0 +1,77 @@
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 BeerDb::FixtureMatcher
11
+
12
+
13
+ def test_country
14
+
15
+ beers_at = [
16
+ 'europe/at/beers',
17
+ 'europe/at-austria/beers',
18
+ 'at-austria/beers',
19
+ 'at-austria!/beers'
20
+ ]
21
+
22
+ beers_at.each do |name|
23
+ found = match_beers_for_country( name ) do |country_key|
24
+ assert( country_key == 'at')
25
+ end
26
+ assert( found == true )
27
+ end
28
+
29
+ breweries_at = [
30
+ 'europe/at/breweries',
31
+ 'europe/at-austria/breweries',
32
+ 'at-austria/breweries',
33
+ 'at-austria!/breweries'
34
+ ]
35
+
36
+ breweries_at.each do |name|
37
+ found = match_breweries_for_country( name ) do |country_key|
38
+ assert( country_key == 'at')
39
+ end
40
+ assert( found == true )
41
+ end
42
+ end # method test_country
43
+
44
+
45
+ def test_country_n_region
46
+
47
+ beers_at = [
48
+ 'europe/at-austria/w-wien/beers',
49
+ 'at-austria/w-wien/beers',
50
+ 'at-austria!/w-wien/beers'
51
+ ]
52
+
53
+ beers_at.each do |name|
54
+ found = match_beers_for_country_n_region( name ) do |country_key,region_key|
55
+ assert( country_key == 'at')
56
+ assert( region_key == 'w' )
57
+ end
58
+ assert( found == true )
59
+ end
60
+
61
+ breweries_at = [
62
+ 'europe/at-austria/w-wien/breweries',
63
+ 'at-austria/w-wien/breweries',
64
+ 'at-austria!/w-wien/breweries'
65
+ ]
66
+
67
+ breweries_at.each do |name|
68
+ found = match_breweries_for_country_n_region( name ) do |country_key,region_key|
69
+ assert( country_key == 'at')
70
+ assert( region_key == 'w' )
71
+ end
72
+ assert( found == true )
73
+ end
74
+ end # method test_country_n_region
75
+
76
+
77
+ end # class TestFixtureMatchers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beerdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &72946910 !ruby/object:Gem::Requirement
16
+ requirement: &71631860 !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: *72946910
24
+ version_requirements: *71631860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: worlddb
27
- requirement: &72946690 !ruby/object:Gem::Requirement
27
+ requirement: &71631640 !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: *72946690
35
+ version_requirements: *71631640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: commander
38
- requirement: &72946470 !ruby/object:Gem::Requirement
38
+ requirement: &71631420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 4.1.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *72946470
46
+ version_requirements: *71631420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &72946250 !ruby/object:Gem::Requirement
49
+ requirement: &71631200 !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: *72946250
57
+ version_requirements: *71631200
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &72946030 !ruby/object:Gem::Requirement
60
+ requirement: &71630980 !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: *72946030
68
+ version_requirements: *71630980
69
69
  description: beerdb - beer.db command line tool
70
70
  email: beerdb@googlegroups.com
71
71
  executables:
@@ -106,6 +106,7 @@ files:
106
106
  - lib/beerdb/stats.rb
107
107
  - lib/beerdb/version.rb
108
108
  - test/helper.rb
109
+ - test/test_fixture_matchers.rb
109
110
  - test/test_values.rb
110
111
  - .gemtest
111
112
  homepage: https://github.com/geraldb/beer.db.ruby
@@ -137,3 +138,4 @@ specification_version: 3
137
138
  summary: beerdb - beer.db command line tool
138
139
  test_files:
139
140
  - test/test_values.rb
141
+ - test/test_fixture_matchers.rb