beerdb 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,7 +134,7 @@ class Beer < ActiveRecord::Base
134
134
  value_tag_keys += tag_keys
135
135
  else
136
136
  # issue warning: unknown type for value
137
- logger.warn "unknown type for value >#{value}<"
137
+ logger.warn "unknown type for value >#{value}< - key #{new_attributes[:key]}"
138
138
  end
139
139
  end # each value
140
140
 
@@ -36,6 +36,7 @@ class Brewery < ActiveRecord::Base
36
36
  logger = LogKernel::Logger.root
37
37
 
38
38
  value_tag_keys = []
39
+ value_brands = ''
39
40
 
40
41
  ### check for "default" tags - that is, if present new_attributes[:tags] remove from hash
41
42
 
@@ -84,13 +85,18 @@ class Brewery < ActiveRecord::Base
84
85
  end
85
86
  elsif value =~ /^[0-9]{4}$/ # founded/established year e.g. 1776
86
87
  new_attributes[ :since ] = value.to_i
87
- elsif value =~ /^(?:([0-9][0-9_]*[0-9]|[0-9])\s?hl)$/ # e.g. 20_0000 hl or 50hl etc.
88
- new_attributes[ :prod ] << $1.gsub(/_/, '').to_i
88
+ elsif value =~ /^(?:([0-9][0-9_ ]+[0-9]|[0-9]{1,2})\s*hl)$/ # e.g. 20_000 hl or 50hl etc.
89
+ value_prod = $1.gsub( /[ _]/, '' ).to_i
90
+ new_attributes[ :prod ] = value_prod
89
91
  elsif value =~ /^www\.|\.com$/ # check for url/internet address e.g. www.ottakringer.at
90
92
  # fix: support more url format (e.g. w/o www. - look for .com .country code etc.)
91
93
  new_attributes[ :web ] = value
92
94
  elsif value =~ /\/{2}/ # if value includes // assume address e.g. 3970 Weitra // Sparkasseplatz 160
93
95
  new_attributes[ :address ] = value
96
+ elsif value =~ /^brands:/ # brands:
97
+ value_brands = value[7..-1] ## cut off brands: prefix
98
+ value_brands = value_brands.strip # remove leading and trailing spaces
99
+ # NB: brands get processed after record gets created (see below)
94
100
  elsif (values.size==(index+1)) && value =~ /^[a-z0-9\|_ ]+$/ # tags must be last entry
95
101
 
96
102
  logger.debug " found tags: >>#{value}<<"
@@ -107,7 +113,7 @@ class Brewery < ActiveRecord::Base
107
113
  value_tag_keys += tag_keys
108
114
  else
109
115
  # issue warning: unknown type for value
110
- logger.warn "unknown type for value >#{value}<"
116
+ logger.warn "unknown type for value >#{value}< - key #{new_attributes[:key]}"
111
117
  end
112
118
  end # each value
113
119
 
@@ -125,6 +131,14 @@ class Brewery < ActiveRecord::Base
125
131
 
126
132
  rec.update_attributes!( new_attributes )
127
133
 
134
+ ###################
135
+ # auto-add brands if presents
136
+
137
+ if value_brands.present?
138
+ logger.debug " auto-adding brands >#{value_brands}<"
139
+ # fix: to be done!
140
+ end
141
+
128
142
  ##################
129
143
  ## add taggings
130
144
 
data/lib/beerdb/reader.rb CHANGED
@@ -115,8 +115,8 @@ class Reader
115
115
  reader.each do |key, value|
116
116
  brewery = Brewery.find_by_key!( key )
117
117
 
118
- if value =~ /(?:([0-9][0-9_]*[0-9]|[0-9])\s*hl)/ # e.g. 20_0000 hl or 50hl etc.
119
- prod = $1.gsub(/_/, '').to_i
118
+ if value =~ /(?:([0-9][0-9_ ]+[0-9]|[0-9]{1,2})\s*hl)/ # e.g. 20_0000 hl or 50hl etc.
119
+ prod = $1.gsub(/[ _]/, '').to_i
120
120
  logger.debug " adding #{key} => >#{prod}<"
121
121
  brewery.prod = prod
122
122
  brewery.save!
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BeerDb
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
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.0
4
+ version: 0.6.1
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: &73799560 !ruby/object:Gem::Requirement
16
+ requirement: &81839750 !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: *73799560
24
+ version_requirements: *81839750
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: worlddb
27
- requirement: &73799340 !ruby/object:Gem::Requirement
27
+ requirement: &81839530 !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: *73799340
35
+ version_requirements: *81839530
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: commander
38
- requirement: &73799120 !ruby/object:Gem::Requirement
38
+ requirement: &81839310 !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: *73799120
46
+ version_requirements: *81839310
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &73798900 !ruby/object:Gem::Requirement
49
+ requirement: &81839090 !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: *73798900
57
+ version_requirements: *81839090
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &73798680 !ruby/object:Gem::Requirement
60
+ requirement: &81838870 !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: *73798680
68
+ version_requirements: *81838870
69
69
  description: beerdb - beer.db command line tool
70
70
  email: beerdb@googlegroups.com
71
71
  executables: