beerdb 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,6 @@ class Brewery < ActiveRecord::Base
29
29
  end
30
30
 
31
31
 
32
-
33
32
  def self.create_or_update_from_values( new_attributes, values )
34
33
 
35
34
  ## fix: add/configure logger for ActiveRecord!!!
@@ -92,7 +91,7 @@ class Brewery < ActiveRecord::Base
92
91
  # fix: support more url format (e.g. w/o www. - look for .com .country code etc.)
93
92
  new_attributes[ :web ] = value
94
93
  elsif value =~ /\/{2}/ # if value includes // assume address e.g. 3970 Weitra // Sparkasseplatz 160
95
- new_attributes[ :address ] = value
94
+ new_attributes[ :address ] = normalize_address( value )
96
95
  elsif value =~ /^brands:/ # brands:
97
96
  value_brands = value[7..-1] ## cut off brands: prefix
98
97
  value_brands = value_brands.strip # remove leading and trailing spaces
@@ -205,6 +204,27 @@ class Brewery < ActiveRecord::Base
205
204
  ### todo/fix:
206
205
  # reuse method - put into helper in textutils or somewhere else ??
207
206
 
207
+ def self.normalize_address( old_address_line )
208
+ # for now only checks german 5-digit zip code
209
+ #
210
+ # e.g. Alte Plauener Straße 24 // 95028 Hof becomes
211
+ # 95028 Hof // Alte Plauener Straße 24
212
+
213
+ new_address_line = old_address_line # default - do nothing - just path through
214
+
215
+ lines = old_address_line.split( '//' )
216
+
217
+ if lines.size == 2 # two lines / check for switching lines
218
+ line1 = lines[0].strip
219
+ line2 = lines[1].strip
220
+ if line2 =~ /^[0-9]{5}\s/
221
+ new_address_line = "#{line2} // #{line1}" # swap - let line w/ 5-digit zip code go first
222
+ end
223
+ end
224
+
225
+ new_address_line
226
+ end
227
+
208
228
  def self.title_to_key( title )
209
229
 
210
230
  ## NB: downcase does NOT work for accented chars (thus, include in alternatives)
@@ -2,6 +2,7 @@ module WorldDb::Models
2
2
 
3
3
  class City
4
4
  has_many :beers, :class_name => 'BeerDb::Models::Beer', :foreign_key => 'city_id'
5
+ has_many :brands, :class_name => 'BeerDb::Models::Brand', :foreign_key => 'city_id'
5
6
  has_many :breweries, :class_name => 'BeerDb::Models::Brewery', :foreign_key => 'city_id'
6
7
  end # class Country
7
8
 
@@ -3,6 +3,7 @@ module WorldDb::Models
3
3
 
4
4
  class Country
5
5
  has_many :beers, :class_name => 'BeerDb::Models::Beer', :foreign_key => 'country_id'
6
+ has_many :brands, :class_name => 'BeerDb::Models::Brand', :foreign_key => 'country_id'
6
7
  has_many :breweries, :class_name => 'BeerDb::Models::Brewery', :foreign_key => 'country_id'
7
8
  end # class Country
8
9
 
@@ -3,6 +3,7 @@ module WorldDb::Models
3
3
 
4
4
  class Region
5
5
  has_many :beers, :class_name => 'BeerDb::Models::Beer', :foreign_key => 'region_id'
6
+ has_many :brands, :class_name => 'BeerDb::Models::Brand', :foreign_key => 'region_id'
6
7
  has_many :breweries, :class_name => 'BeerDb::Models::Brewery', :foreign_key => 'region_id'
7
8
  end # class Region
8
9
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BeerDb
3
- VERSION = '0.6.3'
3
+ VERSION = '0.6.4'
4
4
  end
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.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &77345520 !ruby/object:Gem::Requirement
16
+ requirement: &83421770 !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: *77345520
24
+ version_requirements: *83421770
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: worlddb
27
- requirement: &77345300 !ruby/object:Gem::Requirement
27
+ requirement: &83421550 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.6'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *77345300
35
+ version_requirements: *83421550
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: commander
38
- requirement: &77345080 !ruby/object:Gem::Requirement
38
+ requirement: &83421330 !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: *77345080
46
+ version_requirements: *83421330
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &77344860 !ruby/object:Gem::Requirement
49
+ requirement: &83421110 !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: *77344860
57
+ version_requirements: *83421110
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &77344640 !ruby/object:Gem::Requirement
60
+ requirement: &83420890 !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: *77344640
68
+ version_requirements: *83420890
69
69
  description: beerdb - beer.db command line tool
70
70
  email: beerdb@googlegroups.com
71
71
  executables: