beerdb 0.6.15 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,8 @@ lib/beerdb/models/region.rb
18
18
  lib/beerdb/models/tag.rb
19
19
  lib/beerdb/reader.rb
20
20
  lib/beerdb/schema.rb
21
+ lib/beerdb/serializers/beer.rb
22
+ lib/beerdb/serializers/brewery.rb
21
23
  lib/beerdb/server.rb
22
24
  lib/beerdb/server/public/style.css
23
25
  lib/beerdb/server/views/_debug.erb
@@ -27,3 +29,5 @@ lib/beerdb/server/views/index.erb
27
29
  lib/beerdb/server/views/layout.erb
28
30
  lib/beerdb/stats.rb
29
31
  lib/beerdb/version.rb
32
+ test/helper.rb
33
+ test/test_values.rb
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Hoe.spec 'beerdb' do
21
21
  ['activerecord', '~> 3.2'], # NB: will include activesupport,etc.
22
22
  ### ['sqlite3', '~> 1.3'] # NB: install on your own; remove dependency
23
23
 
24
- ['worlddb', '~> 1.6'], # NB: worlddb already includes
24
+ ['worlddb', '~> 1.7'], # NB: worlddb already includes
25
25
  # - commander
26
26
  # - logutils
27
27
  # - textutils
@@ -4,9 +4,11 @@ module BeerDb::Models
4
4
 
5
5
  class Beer < ActiveRecord::Base
6
6
 
7
+ extend TextUtils::TagHelper # will add self.find_tags, self.find_tags_in_attribs!, etc.
8
+
7
9
  # NB: use extend - is_<type>? become class methods e.g. self.is_<type>? for use in
8
10
  # self.create_or_update_from_values
9
- extend TextUtils::ValueHelper # e.g. is_year?, is_region?, is_address?, is_taglist? etc.
11
+ extend TextUtils::ValueHelper # e.g. self.is_year?, self.is_region?, self.is_address?, is_taglist? etc.
10
12
 
11
13
  belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
12
14
  belongs_to :region, :class_name => 'WorldDb::Models::Region', :foreign_key => 'region_id'
@@ -47,117 +49,100 @@ class Beer < ActiveRecord::Base
47
49
  puts "*** depreceated fn api - use og="
48
50
  self.og = value
49
51
  end
52
+
53
+ def as_json_v2( opts={} )
54
+ # NB: do NOT overwrite "default" / builtin as_json, thus, lets use as_json_v2
55
+ BeerSerializer.new( self ).as_json
56
+ end
50
57
 
51
58
 
52
- def self.create_or_update_from_values( new_attributes, values )
53
-
54
- ## fix: add/configure logger for ActiveRecord!!!
59
+ def self.create_or_update_from_values( values, more_attribs={} )
60
+
61
+ attribs, more_values = find_key_n_title( values )
62
+ attribs = attribs.merge( more_attribs )
63
+
64
+ # check for optional values
65
+ Beer.create_or_update_from_attribs( attribs, more_values )
66
+ end
67
+
68
+
69
+ def self.create_or_update_from_attribs( attribs, values )
70
+
71
+ # fix: add/configure logger for ActiveRecord!!!
55
72
  logger = LogKernel::Logger.root
56
73
 
57
74
  value_tag_keys = []
58
75
 
59
- ## check for grades (e.g. ***/**/*) in titles (will add new_attributes[:grade] to hash)
76
+ ## check for grades (e.g. ***/**/*) in titles (will add attribs[:grade] to hash)
60
77
  ## if grade missing; set default to 4; lets us update overwrite 1,2,3 values on update
61
- new_attributes[ :grade ] ||= 4
78
+ attribs[ :grade ] ||= 4
62
79
 
63
- ### check for "default" tags - that is, if present new_attributes[:tags] remove from hash
64
-
65
- if new_attributes[:tags].present?
66
- more_tag_keys = new_attributes[:tags].split('|')
67
- new_attributes.delete(:tags)
68
-
69
- ## unify; replace _ w/ space; remove leading n trailing whitespace
70
- more_tag_keys = more_tag_keys.map do |key|
71
- key = key.gsub( '_', ' ' )
72
- key = key.strip
73
- key
74
- end
75
-
76
- value_tag_keys += more_tag_keys
77
- end
78
-
80
+ ### check for "default" tags - that is, if present attribs[:tags] remove from hash
81
+ value_tag_keys += find_tags_in_attribs!( attribs )
79
82
 
80
83
  ## check for optional values
81
84
  values.each_with_index do |value,index|
82
- if value =~ /^country:/ ## country:
83
- value_country_key = value[8..-1] ## cut off country: prefix
84
- value_country = Country.find_by_key!( value_country_key )
85
- new_attributes[ :country_id ] = value_country.id
86
- elsif value =~ /^region:/ ## region:
87
- value_region_key = value[7..-1] ## cut off region: prefix
88
- value_region = Region.find_by_key_and_country_id!( value_region_key, new_attributes[:country_id] )
89
- new_attributes[ :region_id ] = value_region.id
90
- elsif is_region?( value ) ## assume region code e.g. TX or N
91
- value_region = Region.find_by_key_and_country_id!( value.downcase, new_attributes[:country_id] )
92
- new_attributes[ :region_id ] = value_region.id
93
- elsif value =~ /^city:/ ## city:
94
- value_city_key = value[5..-1] ## cut off city: prefix
95
- value_city = City.find_by_key( value_city_key )
96
- if value_city.present?
97
- new_attributes[ :city_id ] = value_city.id
98
- else
99
- ## todo/fix: add strict mode flag - fail w/ exit 1 in strict mode
100
- logger.warn "city with key #{value_city_key} missing"
101
- end
102
- elsif value =~ /^by:/ ## by: -brewed by/brewery
103
- value_brewery_key = value[3..-1] ## cut off by: prefix
104
- value_brewery = Brewery.find_by_key!( value_brewery_key )
105
- new_attributes[ :brewery_id ] = value_brewery.id
106
-
107
- # for easy queries cache city and region ids
85
+ if match_country(value) do |country|
86
+ attribs[ :country_id ] = country.id
87
+ end
88
+ elsif match_region_for_country(value, attribs[:country_id]) do |region|
89
+ attribs[ :region_id ] = region.id
90
+ end
91
+ elsif match_city(value) do |city|
92
+ if city.present?
93
+ attribs[ :city_id ] = city.id
94
+ else
95
+ ## todo/fix: add strict mode flag - fail w/ exit 1 in strict mode
96
+ logger.warn "city with key #{value[5..-1]} missing for beer #{attribs[:key]}"
97
+ end
98
+ end
99
+ elsif match_brewery(value) do |brewery|
100
+ attribs[ :brewery_id ] = brewery.id
101
+
102
+ # for easy queries cache city and region ids
108
103
 
109
- # 1) check if brewery has city - if yes, use it for beer too
110
- if value_brewery.city.present?
111
- new_attributes[ :city_id ] = value_brewery.city.id
112
- end
113
-
114
- # 2) check if brewery has city w/ region if yes, use it for beer to
115
- # if not check for region for brewery
116
- if value_brewery.city.present? && value_brewery.city.region.present?
117
- new_attributes[ :region_id ] = value_brewery.city.region.id
118
- elsif value_brewery.region.present?
119
- new_attributes[ :region_id ] = value_brewery.region.id
120
- end
121
-
122
- elsif is_year?( value ) # founded/established year e.g. 1776
123
- new_attributes[ :since ] = value.to_i
124
- elsif is_website?( value ) # check for url/internet address e.g. www.ottakringer.at
125
- # fix: support more url format (e.g. w/o www. - look for .com .country code etc.)
126
- new_attributes[ :web ] = value
127
- elsif value =~ /^<?\s*(\d+(?:\.\d+)?)\s*%$/ ## abv (alcohol by volumee)
128
- ## nb: allow leading < e.g. <0.5%
129
- value_abv_str = $1.dup # convert to decimal? how? use float?
130
- new_attributes[ :abv ] = value_abv_str
131
- elsif value =~ /^(\d+(?:\.\d+)?)°$/ ## plato (stammwuerze/gravity?) e.g. 11.2°
132
- ## nb: no whitespace allowed between ° and number e.g. 11.2°
133
- value_og_str = $1.dup # convert to decimal? how? use float?
134
- new_attributes[ :og ] = value_og_str
135
- elsif value =~ /^(\d+(?:\.\d+)?)\s*kcal(?:\/100ml)?$/ ## kcal
136
- ## nb: allow 44.4 kcal/100ml or 44.4 kcal or 44.4kcal
137
- value_kcal_str = $1.dup # convert to decimal? how? use float?
138
- new_attributes[ :kcal ] = value_kcal_str
104
+ # 1) check if brewery has city - if yes, use it for beer too
105
+ if brewery.city.present?
106
+ attribs[ :city_id ] = brewery.city.id
107
+ end
108
+
109
+ # 2) check if brewery has city w/ region if yes, use it for beer to
110
+ # if not check for region for brewery
111
+ if brewery.city.present? && brewery.city.region.present?
112
+ attribs[ :region_id ] = brewery.city.region.id
113
+ elsif brewery.region.present?
114
+ attribs[ :region_id ] = brewery.region.id
115
+ end
116
+ end
117
+ elsif match_year( value ) do |num| # founded/established year e.g. 1776
118
+ attribs[ :since ] = num
119
+ end
120
+ elsif match_website( value ) do |website| # check for url/internet address e.g. www.ottakringer.at
121
+ attribs[ :web ] = website
122
+ end
123
+ elsif match_abv( value ) do |num| # abv (alcohol by volume)
124
+ # nb: also allows leading < e.g. <0.5%
125
+ attribs[ :abv ] = num
126
+ end
127
+ elsif match_og( value ) do |num| # plato (stammwuerze/gravity?) e.g. 11.2°
128
+ # nb: no whitespace allowed between ° and number e.g. 11.2°
129
+ attribs[ :og ] = num
130
+ end
131
+ elsif match_kcal( value ) do |num| # kcal
132
+ # nb: allow 44.4 kcal/100ml or 44.4 kcal or 44.4kcal
133
+ attribs[ :kcal ] = num
134
+ end
139
135
  elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
140
-
141
136
  logger.debug " found tags: >>#{value}<<"
142
-
143
- tag_keys = value.split('|')
144
-
145
- ## unify; replace _ w/ space; remove leading n trailing whitespace
146
- tag_keys = tag_keys.map do |key|
147
- key = key.gsub( '_', ' ' )
148
- key = key.strip
149
- key
150
- end
151
-
152
- value_tag_keys += tag_keys
137
+ value_tag_keys += find_tags( value )
153
138
  else
154
139
  # issue warning: unknown type for value
155
- logger.warn "unknown type for value >#{value}< - key #{new_attributes[:key]}"
140
+ logger.warn "unknown type for value >#{value}< - key #{attribs[:key]}"
156
141
  end
157
142
  end # each value
158
143
 
159
- # rec = Beer.find_by_key_and_country_id( new_attributes[ :key ], new_attributes[ :country_id] )
160
- rec = Beer.find_by_key( new_attributes[ :key ] )
144
+ # rec = Beer.find_by_key_and_country_id( attribs[ :key ], attribs[ :country_id] )
145
+ rec = Beer.find_by_key( attribs[ :key ] )
161
146
 
162
147
  if rec.present?
163
148
  logger.debug "update Beer #{rec.id}-#{rec.key}:"
@@ -166,9 +151,9 @@ class Beer < ActiveRecord::Base
166
151
  rec = Beer.new
167
152
  end
168
153
 
169
- logger.debug new_attributes.to_json
154
+ logger.debug attribs.to_json
170
155
 
171
- rec.update_attributes!( new_attributes )
156
+ rec.update_attributes!( attribs )
172
157
 
173
158
  ##################
174
159
  # add taggings
@@ -4,6 +4,9 @@ module BeerDb::Models
4
4
 
5
5
  class Brand < ActiveRecord::Base
6
6
 
7
+ # NB: use extend - is_<type>? become class methods e.g. self.is_<type>?
8
+ extend TextUtils::ValueHelper # e.g. self.find_key_n_title, self.is_year?, self.is_region?, is_address?, is_taglist? etc.
9
+
7
10
  belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
8
11
  belongs_to :region, :class_name => 'WorldDb::Models::Region', :foreign_key => 'region_id'
9
12
  belongs_to :city, :class_name => 'WorldDb::Models::City', :foreign_key => 'city_id'
@@ -14,6 +17,44 @@ class Brand < ActiveRecord::Base
14
17
 
15
18
  validates :key, :format => { :with => /^[a-z][a-z0-9]+$/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' }
16
19
 
20
+
21
+ def self.create_or_update_from_values( values, more_attribs = {} )
22
+ attribs, more_values = find_key_n_title( values )
23
+ attribs = attribs.merge( more_attribs )
24
+
25
+ Brand.create_or_update_from_attribs( attribs, more_values )
26
+ end
27
+
28
+ # convenience helper Brand.create_or_update_from_title
29
+ def self.create_or_update_from_title( title, more_attribs = {} )
30
+ values = [title]
31
+ Brand.create_or_update_from_values( values, more_attribs )
32
+ end
33
+
34
+
35
+ def self.create_or_update_from_attribs( attribs, values )
36
+
37
+ ## fix: add/configure logger for ActiveRecord!!!
38
+ logger = LogKernel::Logger.root
39
+
40
+ ## check for grades (e.g. ***/**/*) in titles (will add attribs[:grade] to hash)
41
+ ## if grade missing; set default to 4; lets us update overwrite 1,2,3 values on update
42
+ attribs[:grade] ||= 4
43
+
44
+ rec = Brand.find_by_key( attribs[:key] )
45
+
46
+ if rec.present?
47
+ logger.debug "update Brand #{rec.id}-#{rec.key}:"
48
+ else
49
+ logger.debug "create Brand:"
50
+ rec = Brand.new
51
+ end
52
+
53
+ logger.debug attribs.to_json
54
+
55
+ rec.update_attributes!( attribs )
56
+ end
57
+
17
58
  end # class Brand
18
59
 
19
60
  end # module BeerDb::Models
@@ -4,10 +4,12 @@ module BeerDb::Models
4
4
 
5
5
  class Brewery < ActiveRecord::Base
6
6
 
7
+ extend TextUtils::TagHelper # will add self.find_tags, self.find_tags_in_attribs!, etc.
8
+
7
9
  # NB: use extend - is_<type>? become class methods e.g. self.is_<type>? for use in
8
10
  # self.create_or_update_from_values
9
- extend TextUtils::ValueHelper # e.g. is_year?, is_region?, is_address?, is_taglist? etc.
10
- extend TextUtils::AddressHelper # e.g normalize_address, find_city_for_country, etc.
11
+ extend TextUtils::ValueHelper # e.g. self.is_year?, self.is_region?, is_address?, is_taglist? etc.
12
+ extend TextUtils::AddressHelper # e.g self.normalize_addr, self.find_city_in_addr, etc.
11
13
 
12
14
  self.table_name = 'breweries'
13
15
 
@@ -40,9 +42,23 @@ class Brewery < ActiveRecord::Base
40
42
  self.since = value
41
43
  end
42
44
 
45
+ def as_json_v2( opts={} )
46
+ # NB: do NOT overwrite "default" / builtin as_json, thus, lets use as_json_v2
47
+ BrewerySerializer.new( self ).as_json
48
+ end
49
+
43
50
 
44
51
 
45
- def self.create_or_update_from_values( new_attributes, values )
52
+ def self.create_or_update_from_values( values, more_attribs={} )
53
+ attribs, more_values = find_key_n_title( values )
54
+ attribs = attribs.merge( more_attribs )
55
+
56
+ # check for optional values
57
+ Brewery.create_or_update_from_attribs( attribs, more_values )
58
+ end
59
+
60
+
61
+ def self.create_or_update_from_attribs( new_attributes, values )
46
62
 
47
63
  ## fix: add/configure logger for ActiveRecord!!!
48
64
  logger = LogKernel::Logger.root
@@ -55,78 +71,49 @@ class Brewery < ActiveRecord::Base
55
71
  new_attributes[ :grade ] ||= 4
56
72
 
57
73
  ### check for "default" tags - that is, if present new_attributes[:tags] remove from hash
58
-
59
- if new_attributes[:tags].present?
60
- more_tag_keys = new_attributes[:tags].split('|')
61
- new_attributes.delete(:tags)
62
-
63
- ## unify; replace _ w/ space; remove leading n trailing whitespace
64
- more_tag_keys = more_tag_keys.map do |key|
65
- key = key.gsub( '_', ' ' )
66
- key = key.strip
67
- key
68
- end
69
-
70
- value_tag_keys += more_tag_keys
71
- end
72
-
74
+ value_tag_keys += find_tags_in_attribs!( new_attributes )
73
75
 
74
76
  ## check for optional values
75
77
  values.each_with_index do |value,index|
76
- if value =~ /^country:/ ## country:
77
- value_country_key = value[8..-1] ## cut off country: prefix
78
- value_country = Country.find_by_key!( value_country_key )
79
- new_attributes[ :country_id ] = value_country.id
80
- elsif value =~ /^region:/ ## region:
81
- value_region_key = value[7..-1] ## cut off region: prefix
82
- value_region = Region.find_by_key_and_country_id!( value_region_key, new_attributes[:country_id] )
83
- new_attributes[ :region_id ] = value_region.id
84
- elsif is_region?( value ) ## assume region code e.g. TX or N
85
- value_region = Region.find_by_key_and_country_id!( value.downcase, new_attributes[:country_id] )
86
- new_attributes[ :region_id ] = value_region.id
87
- elsif value =~ /^city:/ ## city:
88
- value_city_key = value[5..-1] ## cut off city: prefix
89
- value_city = City.find_by_key( value_city_key )
90
- if value_city.present?
91
- new_attributes[ :city_id ] = value_city.id
92
- else
93
- ## todo/fix: add strict mode flag - fail w/ exit 1 in strict mode
94
- logger.warn "city with key #{value_city_key} missing"
95
- end
96
-
97
- ## for easy queries: cache region_id (from city)
98
- # - check if city w/ region if yes, use it for brewery too
99
- if value_city.present? && value_city.region.present?
100
- new_attributes[ :region_id ] = value_city.region.id
101
- end
102
- elsif is_year?( value ) # founded/established year e.g. 1776
103
- new_attributes[ :since ] = value.to_i
104
- elsif value =~ /^(?:([0-9][0-9_ ]+[0-9]|[0-9]{1,2})\s*hl)$/ # e.g. 20_000 hl or 50hl etc.
105
- value_prod = $1.gsub( /[ _]/, '' ).to_i
106
- new_attributes[ :prod ] = value_prod
107
- elsif is_website?( value ) # check for url/internet address e.g. www.ottakringer.at
108
- # fix: support more url format (e.g. w/o www. - look for .com .country code etc.)
109
- new_attributes[ :web ] = value
78
+ if match_country(value) do |country|
79
+ new_attributes[ :country_id ] = country.id
80
+ end
81
+ elsif match_region_for_country(value,new_attributes[:country_id]) do |region|
82
+ new_attributes[ :region_id ] = region.id
83
+ end
84
+ elsif match_city(value) do |city|
85
+ if city.present?
86
+ new_attributes[ :city_id ] = city.id
87
+ else
88
+ ## todo/fix: add strict mode flag - fail w/ exit 1 in strict mode
89
+ logger.warn "city with key #{value[5..-1]} missing - for brewery #{new_attributes[:key]}"
90
+ end
91
+
92
+ ## for easy queries: cache region_id (from city)
93
+ # - check if city w/ region if yes, use it for brewery too
94
+ if city.present? && city.region.present?
95
+ new_attributes[ :region_id ] = city.region.id
96
+ end
97
+ end
98
+ elsif match_year( value ) do |num| # founded/established year e.g. 1776
99
+ new_attributes[ :since ] = num
100
+ end
101
+ elsif match_hl( value ) do |num| # e.g. 20_000 hl or 50hl etc.
102
+ new_attributes[ :prod ] = num
103
+ end
104
+ elsif match_website( value ) do |website| # check for url/internet address e.g. www.ottakringer.at
105
+ # fix: support more url format (e.g. w/o www. - look for .com .country code etc.)
106
+ new_attributes[ :web ] = website
107
+ end
110
108
  elsif is_address?( value ) # if value includes // assume address e.g. 3970 Weitra // Sparkasseplatz 160
111
- new_attributes[ :address ] = normalize_address( value )
109
+ new_attributes[ :address ] = normalize_addr( value )
112
110
  elsif value =~ /^brands:/ # brands:
113
111
  value_brands = value[7..-1] ## cut off brands: prefix
114
112
  value_brands = value_brands.strip # remove leading and trailing spaces
115
113
  # NB: brands get processed after record gets created (see below)
116
114
  elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
117
-
118
115
  logger.debug " found tags: >>#{value}<<"
119
-
120
- tag_keys = value.split('|')
121
-
122
- ## unify; replace _ w/ space; remove leading n trailing whitespace
123
- tag_keys = tag_keys.map do |key|
124
- key = key.gsub( '_', ' ' )
125
- key = key.strip
126
- key
127
- end
128
-
129
- value_tag_keys += tag_keys
116
+ value_tag_keys += find_tags( value )
130
117
  else
131
118
  # issue warning: unknown type for value
132
119
  logger.warn "unknown type for value >#{value}< - key #{new_attributes[:key]}"
@@ -161,40 +148,20 @@ class Brewery < ActiveRecord::Base
161
148
 
162
149
  ## todo: how to handle nil/empty address lines?
163
150
 
164
- ## todo: use find_city_in_adr_for_country ?? too long ?? use adr or addr
165
- city_title = find_city_for_country( country_key, new_attributes[:address] )
151
+ city_title = find_city_in_addr( new_attributes[:address], country_key )
166
152
 
167
153
  if city_title.present?
168
154
 
169
- # remove optional english translation in square brackets ([]) e.g. Wien [Vienna]
170
- city_title = TextUtils.strip_translations( city_title )
171
- # remove optional longer title part in {} e.g. Ottakringer {Bio} or {Alkoholfrei}
172
- city_title = TextUtils.strip_tags( city_title )
173
-
174
- city_key = TextUtils.title_to_key( city_title )
175
-
176
- city = City.find_by_key( city_key )
177
-
155
+ city_values = [city_title]
178
156
  city_attributes = {
179
- title: city_title,
180
157
  country_id: rec.country_id,
181
158
  region_id: rec.region_id
182
- ### fix/todo: add new autoadd flag too?
183
159
  }
160
+ # todo: add convenience helper create_or_update_from_title
161
+ city = City.create_or_update_from_values( city_values, city_attributes )
184
162
 
185
- if city.present?
186
- logger.debug "update City #{city.id}-#{city.key}:"
187
- # todo: check - any point in updating city? for now no new attributes
188
- # update only for title - title will change?
189
- else
190
- logger.debug "create City:"
191
- city = City.new
192
- city_attributes[ :key ] = city_key # NB: new record; include/update key
193
- end
194
-
195
- logger.debug city_attributes.to_json
196
-
197
- city.update_attributes!( city_attributes )
163
+ ### fix/todo: set new autoadd flag too?
164
+ ## e.g. check if updated? e.g. timestamp created <> updated otherwise assume created?
198
165
 
199
166
  ## now at last add city_id to brewery!
200
167
  rec.city_id = city.id
@@ -212,46 +179,26 @@ class Brewery < ActiveRecord::Base
212
179
  if value_brands.present?
213
180
  logger.debug " auto-adding brands >#{value_brands}<"
214
181
 
215
- # remove optional english translation in square brackets ([]) e.g. Wien [Vienna]
216
- value_brands = TextUtils.strip_translations( value_brands )
217
-
182
+ ## todo/fix: use strip_inline_comments (e.g #() or (()) - why?? why not??)
183
+ # - allows titles as usual (use new syntax for inline comments e.g. #() or (()) for example)
184
+
218
185
  # remove optional longer title part in () e.g. Las Palmas (de Gran Canaria), Palma (de Mallorca)
219
186
  value_brands = TextUtils.strip_subtitles( value_brands )
220
187
 
221
- # remove optional longer title part in {} e.g. Ottakringer {Bio} or {Alkoholfrei}
222
- value_brands = TextUtils.strip_tags( value_brands )
223
-
224
- value_brand_titles = value_brands.split( ',' )
188
+ brand_titles = value_brands.split( ',' )
225
189
 
226
190
  # pass 1) remove leading n trailing spaces
227
- value_brand_titles = value_brand_titles.map { |value| value.strip }
228
-
229
- value_brand_titles.each do |brand_title|
230
-
231
- # autogenerate key from title
232
- brand_key = TextUtils.title_to_key( brand_title )
233
-
234
- brand = Brand.find_by_key( brand_key )
191
+ brand_titles = brand_titles.map { |value| value.strip }
235
192
 
236
- brand_attributes = {
237
- title: brand_title,
238
- brewery_id: rec.id,
239
- country_id: rec.country_id,
240
- region_id: rec.region_id,
241
- city_id: rec.city_id
242
- }
243
-
244
- if brand.present?
245
- logger.debug "update Brand #{brand.id}-#{brand.key}:"
246
- else
247
- logger.debug "create Brand:"
248
- brand = Brand.new
249
- brand_attributes[ :key ] = brand_key # NB: new record; include/update key
250
- end
251
-
252
- logger.debug brand_attributes.to_json
193
+ brand_attribs = {
194
+ brewery_id: rec.id,
195
+ country_id: rec.country_id,
196
+ region_id: rec.region_id,
197
+ city_id: rec.city_id
198
+ }
253
199
 
254
- brand.update_attributes!( brand_attributes )
200
+ brand_titles.each do |brand_title|
201
+ Brand.create_or_update_from_title( brand_title, brand_attribs )
255
202
  end
256
203
  end
257
204
 
@@ -66,12 +66,9 @@ class Reader
66
66
  end
67
67
  end
68
68
 
69
- def load_brewery_wikipedia( lang_key, name )
70
- path = "#{include_path}/#{name}.yml"
71
69
 
72
- logger.info "parsing data '#{name}' (#{path})..."
73
-
74
- reader = HashReader.new( path )
70
+ def load_brewery_wikipedia( lang_key, name )
71
+ reader = HashReaderV2.new( name, include_path )
75
72
 
76
73
  reader.each do |key, value|
77
74
  brewery = Brewery.find_by_key!( key )
@@ -81,17 +78,11 @@ class Reader
81
78
  brewery.wikipedia = wikipedia
82
79
  brewery.save!
83
80
  end
84
-
85
- Prop.create_from_fixture!( name, path )
86
81
  end
87
82
 
88
83
 
89
84
  def load_brewery_prod( name )
90
- path = "#{include_path}/#{name}.yml"
91
-
92
- logger.info "parsing data '#{name}' (#{path})..."
93
-
94
- reader = HashReader.new( path )
85
+ reader = HashReaderV2.new( name, include_path )
95
86
 
96
87
  reader.each do |key, value|
97
88
  brewery = Brewery.find_by_key!( key )
@@ -105,11 +96,9 @@ class Reader
105
96
  logger.warn " unknown type for brewery prod value >#{value}<; regex pattern match failed"
106
97
  end
107
98
  end
108
-
109
- Prop.create_from_fixture!( name, path )
110
99
  end
111
100
 
112
- def load_beers_for_country_n_region( country_key, region_key, name, more_values={} )
101
+ def load_beers_for_country_n_region( country_key, region_key, name, more_attribs={} )
113
102
  country = Country.find_by_key!( country_key )
114
103
  logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
115
104
 
@@ -117,41 +106,35 @@ class Reader
117
106
  region = Region.find_by_key_and_country_id!( region_key, country.id )
118
107
  logger.debug "Region #{region.key} >#{region.title}<"
119
108
 
120
- more_values[ :country_id ] = country.id
121
- more_values[ :region_id ] = region.id
109
+ more_attribs[ :country_id ] = country.id
110
+ more_attribs[ :region_id ] = region.id
122
111
 
123
- more_values[ :txt ] = name # store source ref
112
+ more_attribs[ :txt ] = name # store source ref
124
113
 
125
- load_beers_worker( name, more_values )
114
+ load_beers_worker( name, more_attribs )
126
115
  end
127
116
 
128
- def load_beers_for_country( country_key, name, more_values={} )
117
+ def load_beers_for_country( country_key, name, more_attribs={} )
129
118
  country = Country.find_by_key!( country_key )
130
119
  logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
131
120
 
132
- more_values[ :country_id ] = country.id
121
+ more_attribs[ :country_id ] = country.id
133
122
 
134
- more_values[ :txt ] = name # store source ref
123
+ more_attribs[ :txt ] = name # store source ref
135
124
 
136
- load_beers_worker( name, more_values )
125
+ load_beers_worker( name, more_attribs )
137
126
  end
138
127
 
139
- def load_beers_worker( name, more_values={} )
140
- path = "#{include_path}/#{name}.txt"
141
-
142
- logger.info "parsing data '#{name}' (#{path})..."
143
-
144
- reader = ValuesReader.new( path, more_values )
128
+ def load_beers_worker( name, more_attribs={} )
129
+ reader = ValuesReaderV2.new( name, include_path, more_attribs )
145
130
 
146
131
  reader.each_line do |new_attributes, values|
147
- Beer.create_or_update_from_values( new_attributes, values )
132
+ Beer.create_or_update_from_attribs( new_attributes, values )
148
133
  end # each_line
149
-
150
- Prop.create_from_fixture!( name, path )
151
134
  end
152
135
 
153
136
 
154
- def load_breweries_for_country_n_region( country_key, region_key, name, more_values={} )
137
+ def load_breweries_for_country_n_region( country_key, region_key, name, more_attribs={} )
155
138
  country = Country.find_by_key!( country_key )
156
139
  logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
157
140
 
@@ -159,37 +142,31 @@ class Reader
159
142
  region = Region.find_by_key_and_country_id!( region_key, country.id )
160
143
  logger.debug "Region #{region.key} >#{region.title}<"
161
144
 
162
- more_values[ :country_id ] = country.id
163
- more_values[ :region_id ] = region.id
145
+ more_attribs[ :country_id ] = country.id
146
+ more_attribs[ :region_id ] = region.id
164
147
 
165
- more_values[ :txt ] = name # store source ref
148
+ more_attribs[ :txt ] = name # store source ref
166
149
 
167
- load_breweries_worker( name, more_values )
150
+ load_breweries_worker( name, more_attribs )
168
151
  end
169
152
 
170
- def load_breweries_for_country( country_key, name, more_values={} )
153
+ def load_breweries_for_country( country_key, name, more_attribs={} )
171
154
  country = Country.find_by_key!( country_key )
172
155
  logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
173
156
 
174
- more_values[ :country_id ] = country.id
157
+ more_attribs[ :country_id ] = country.id
175
158
 
176
- more_values[ :txt ] = name # store source ref
159
+ more_attribs[ :txt ] = name # store source ref
177
160
 
178
- load_breweries_worker( name, more_values )
161
+ load_breweries_worker( name, more_attribs )
179
162
  end
180
163
 
181
- def load_breweries_worker( name, more_values={} )
182
- path = "#{include_path}/#{name}.txt"
164
+ def load_breweries_worker( name, more_attribs={} )
165
+ reader = ValuesReaderV2.new( name, include_path, more_attribs )
183
166
 
184
- logger.info "parsing data '#{name}' (#{path})..."
185
-
186
- reader = ValuesReader.new( path, more_values )
187
-
188
167
  reader.each_line do |new_attributes, values|
189
- Brewery.create_or_update_from_values( new_attributes, values )
168
+ Brewery.create_or_update_from_attribs( new_attributes, values )
190
169
  end # each_line
191
-
192
- Prop.create_from_fixture!( name, path )
193
170
  end
194
171
 
195
172
  end # class Reader
@@ -0,0 +1,45 @@
1
+ # encoding: UTF-8
2
+
3
+ module BeerDb::Models
4
+
5
+ class BeerSerializer
6
+
7
+ def initialize( beer )
8
+ @beer = beer
9
+ end
10
+
11
+ attr_reader :beer
12
+
13
+ def as_json
14
+ brewery = {}
15
+ if beer.brewery.present?
16
+ brewery = { key: beer.brewery.key,
17
+ title: beer.brewery.title }
18
+ end
19
+
20
+ tags = []
21
+ if beer.tags.present?
22
+ beer.tags.each { |tag| tags << tag.key }
23
+ end
24
+
25
+ country = {
26
+ key: beer.country.key,
27
+ title: beer.country.title
28
+ }
29
+
30
+ data = { key: beer.key,
31
+ title: beer.title,
32
+ synonyms: beer.synonyms,
33
+ abv: beer.abv,
34
+ srm: beer.srm,
35
+ og: beer.og,
36
+ tags: tags,
37
+ brewery: brewery,
38
+ country: country }
39
+
40
+ data.to_json
41
+ end
42
+
43
+ end # class BeerSerializer
44
+
45
+ end # module BeerDb::Models
@@ -0,0 +1,46 @@
1
+ # encoding: UTF-8
2
+
3
+ module BeerDb::Models
4
+
5
+ class BrewerySerializer
6
+
7
+ def initialize( brewery )
8
+ @brewery = brewery
9
+ end
10
+
11
+ attr_reader :brewery
12
+
13
+ def as_json
14
+
15
+ beers = []
16
+ brewery.beers.each do |b|
17
+ beers << { key: b.key, title: b.title }
18
+ end
19
+
20
+ tags = []
21
+ if brewery.tags.present?
22
+ brewery.tags.each { |tag| tags << tag.key }
23
+ end
24
+
25
+ country = {
26
+ key: brewery.country.key,
27
+ title: brewery.country.title
28
+ }
29
+
30
+ data = { key: brewery.key,
31
+ title: brewery.title,
32
+ synonyms: brewery.synonyms,
33
+ since: brewery.since,
34
+ address: brewery.address,
35
+ web: brewery.web,
36
+ prod: brewery.prod, # (estimated) annual production in hl e.g. 2_000 hl
37
+ tags: tags,
38
+ beers: beers,
39
+ country: country }
40
+
41
+ data.to_json
42
+ end
43
+
44
+ end # class BrewerySerializer
45
+
46
+ end # module BeerDb::Models
@@ -72,34 +72,13 @@ class Server < Sinatra::Base
72
72
 
73
73
  if ['r', 'rnd', 'rand', 'random'].include?( key )
74
74
  # special key for random beer
75
+ # NB: use .first (otherwise will get ActiveRelation not Model)
75
76
  beer = Beer.rnd.first
76
77
  else
77
78
  beer = Beer.find_by_key!( key )
78
79
  end
79
80
 
80
- brewery = {}
81
- if beer.brewery.present?
82
- brewery = { key: beer.brewery.key,
83
- title: beer.brewery.title }
84
- end
85
-
86
- tags = []
87
- if beer.tags.present?
88
- beer.tags.each { |tag| tags << tag.key }
89
- end
90
-
91
- country = {
92
- key: beer.country.key,
93
- title: beer.country.title
94
- }
95
-
96
- data = { key: beer.key, title: beer.title, synonyms: beer.synonyms,
97
- abv: beer.abv, srm: beer.srm, og: beer.og,
98
- tags: tags,
99
- brewery: brewery,
100
- country: country }
101
-
102
- json_or_jsonp( data )
81
+ json_or_jsonp( beer.as_json_v2 )
103
82
  end
104
83
 
105
84
 
@@ -107,55 +86,29 @@ class Server < Sinatra::Base
107
86
 
108
87
  if ['r', 'rnd', 'rand', 'random'].include?( key )
109
88
  # special key for random brewery
89
+ # NB: use .first (otherwise will get ActiveRelation not Model)
110
90
  brewery = Brewery.rnd.first
111
91
  else
112
92
  brewery = Brewery.find_by_key!( key )
113
93
  end
114
94
 
115
-
116
- beers = []
117
- brewery.beers.each do |b|
118
- beers << { key: b.key, title: b.title }
119
- end
120
-
121
- tags = []
122
- if brewery.tags.present?
123
- brewery.tags.each { |tag| tags << tag.key }
124
- end
125
-
126
- country = {
127
- key: brewery.country.key,
128
- title: brewery.country.title
129
- }
130
-
131
- data = { key: brewery.key,
132
- title: brewery.title,
133
- synonyms: brewery.synonyms,
134
- since: brewery.since,
135
- address: brewery.address,
136
- web: brewery.web,
137
- prod: brewery.prod, # (estimated) annual production in hl e.g. 2_000 hl
138
- tags: tags,
139
- beers: beers,
140
- country: country }
141
-
142
- json_or_jsonp( data )
95
+ json_or_jsonp( brewery.as_json_v2 )
143
96
  end
144
97
 
145
98
 
146
99
  ### helper for json or jsonp response (depending on callback para)
147
100
 
148
101
  private
149
- def json_or_jsonp( data )
102
+ def json_or_jsonp( json )
150
103
  callback = params.delete('callback')
151
104
  response = ''
152
105
 
153
106
  if callback
154
107
  content_type :js
155
- response = "#{callback}(#{data.to_json})"
108
+ response = "#{callback}(#{json})"
156
109
  else
157
110
  content_type :json
158
- response = data.to_json
111
+ response = json
159
112
  end
160
113
 
161
114
  response
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BeerDb
3
- VERSION = '0.6.15'
3
+ VERSION = '0.7.0'
4
4
  end
@@ -0,0 +1,79 @@
1
+
2
+ ## $:.unshift(File.dirname(__FILE__))
3
+
4
+ ## minitest setup
5
+
6
+ # require 'minitest/unit'
7
+ require 'minitest/autorun'
8
+
9
+ # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
10
+
11
+
12
+ # ruby stdlibs
13
+
14
+ require 'json'
15
+ require 'uri'
16
+ require 'pp'
17
+
18
+ # ruby gems
19
+
20
+ require 'active_record'
21
+
22
+ # our own code
23
+
24
+ require 'beerdb'
25
+ require 'logutils/db' # NB: explict require required for LogDb (not automatic)
26
+
27
+ Country = WorldDb::Models::Country
28
+ Region = WorldDb::Models::Region
29
+
30
+ ## todo: get all models aliases (e.g. from console script)
31
+
32
+ Beer = BeerDb::Models::Beer
33
+ Brand = BeerDb::Models::Brand
34
+ Brewery = BeerDb::Models::Brewery
35
+
36
+
37
+ def setup_in_memory_db
38
+ # Database Setup & Config
39
+
40
+ db_config = {
41
+ adapter: 'sqlite3',
42
+ database: ':memory:'
43
+ }
44
+
45
+ pp db_config
46
+
47
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
48
+ ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
49
+
50
+ ## NB: every connect will create a new empty in memory db
51
+ ActiveRecord::Base.establish_connection( db_config )
52
+
53
+
54
+ ## build schema
55
+
56
+ LogDb.create
57
+ WorldDb.create
58
+ BeerDb.create
59
+ end
60
+
61
+ def fillup_in_memory_db
62
+ ## add some counties
63
+
64
+ at = Country.create!( key: 'at', title: 'Austria', code: 'AUT', pop: 0, area: 0 )
65
+ Region.create!( key: 'w', title: 'Wien', country_id: at.id )
66
+
67
+ de = Country.create!( key: 'de', title: 'Germany', code: 'DEU', pop: 0, area: 0 )
68
+ Region.create!( key: 'by', title: 'Bayern', country_id: de.id )
69
+
70
+ end
71
+
72
+ setup_in_memory_db()
73
+ fillup_in_memory_db()
74
+
75
+ AT = Country.find_by_key!( 'at' )
76
+ W = Region.find_by_key!( 'w' )
77
+
78
+ DE = Country.find_by_key!( 'de' )
79
+ BY = Region.find_by_key!( 'by' )
@@ -16,26 +16,26 @@ class TestValues < MiniTest::Unit::TestCase
16
16
  end
17
17
 
18
18
  def test_load_beer_values
19
-
20
- new_attributes = {
21
- key: 'ottakringerpur',
22
- title: 'Ottakringer (Gold Fassl) Pur {Bio}',
23
- synonyms: '',
24
- country_id: AT.id
25
- }
19
+
20
+ key = 'ottakringerpur'
26
21
 
27
22
  values = [
23
+ 'Ottakringer (Gold Fassl) Pur {Bio}',
28
24
  '5.2 %',
29
25
  '11.8°',
30
26
  'bio'
31
27
  ]
32
-
33
- beer = Beer.create_or_update_from_values( new_attributes, values )
34
-
35
- beer2 = Beer.find_by_key!( new_attributes[:key] )
28
+
29
+ more_attribs = {
30
+ country_id: AT.id
31
+ }
32
+
33
+ beer = Beer.create_or_update_from_values( values, more_attribs )
34
+
35
+ beer2 = Beer.find_by_key!( key )
36
36
  assert( beer.id == beer2.id )
37
37
 
38
- assert( beer.title == new_attributes[:title] )
38
+ assert( beer.title == values[0] )
39
39
  assert( beer.country_id == AT.id )
40
40
  assert( beer.country.title == AT.title )
41
41
  assert( beer.abv == 5.2 )
@@ -48,26 +48,28 @@ class TestValues < MiniTest::Unit::TestCase
48
48
  # ottakringer, Ottakringer Brauerei, 1838, www.ottakringer.at, WI, city:wien, 1160 Wien // Ottakringer Platz 1
49
49
  # brands: Ottakringer
50
50
 
51
- new_attributes = {
52
- key: 'ottakringer',
53
- title: 'Ottakringer Brauerei',
54
- synonyms: '',
55
- country_id: AT.id
56
- }
51
+ key = 'ottakringer'
57
52
 
58
53
  values = [
54
+ key,
55
+ 'Ottakringer Brauerei',
59
56
  '1838',
60
57
  'www.ottakringer.at',
61
58
  '1160 Wien // Ottakringer Platz 1',
62
59
  'brands: Ottakringer'
63
60
  ]
61
+
62
+ more_attribs = {
63
+ country_id: AT.id
64
+ }
65
+
64
66
 
65
- by = Brewery.create_or_update_from_values( new_attributes, values )
67
+ by = Brewery.create_or_update_from_values( values, more_attribs )
66
68
 
67
- by2 = Brewery.find_by_key!( new_attributes[:key] )
69
+ by2 = Brewery.find_by_key!( key )
68
70
  assert( by.id == by2.id )
69
71
 
70
- assert( by.title == new_attributes[:title] )
72
+ assert( by.title == values[1] )
71
73
  assert( by.country_id == AT.id )
72
74
  assert( by.country.title == AT.title )
73
75
  assert( by.since == 1838 )
@@ -91,23 +93,24 @@ class TestValues < MiniTest::Unit::TestCase
91
93
  # ottakringer, Ottakringer Brauerei, 1838, www.ottakringer.at, WI, city:wien, 1160 Wien // Ottakringer Platz 1
92
94
  # brands: Ottakringer
93
95
 
94
- new_attributes = {
95
- key: 'ottakringer',
96
- title: 'Ottakringer Brauerei **',
97
- synonyms: '',
98
- country_id: AT.id
99
- }
96
+ key = 'ottakringer'
100
97
 
101
98
  values = [
99
+ key,
100
+ 'Ottakringer Brauerei **',
102
101
  '1838',
103
102
  'www.ottakringer.at',
104
103
  '1160 Wien // Ottakringer Platz 1',
105
104
  'brands: Ottakringer'
106
105
  ]
107
-
108
- by = Brewery.create_or_update_from_values( new_attributes, values )
109
106
 
110
- by2 = Brewery.find_by_key!( new_attributes[:key] )
107
+ more_attribs = {
108
+ country_id: AT.id
109
+ }
110
+
111
+ by = Brewery.create_or_update_from_values( values, more_attribs )
112
+
113
+ by2 = Brewery.find_by_key!( key )
111
114
  assert( by.id == by2.id )
112
115
 
113
116
  assert( by.title == 'Ottakringer Brauerei' )
@@ -122,23 +125,24 @@ class TestValues < MiniTest::Unit::TestCase
122
125
  # ottakringer, Ottakringer Brauerei, 1838, www.ottakringer.at, WI, city:wien, 1160 Wien // Ottakringer Platz 1
123
126
  # brands: Ottakringer
124
127
 
125
- new_attributes = {
126
- key: 'ottakringer',
127
- title: 'Ottakringer Brauerei',
128
- synonyms: 'Otta **',
129
- country_id: AT.id
130
- }
128
+ key = 'ottakringer'
131
129
 
132
130
  values = [
131
+ key,
132
+ 'Ottakringer Brauerei|Otta **', # NB: title will auto-gen grade n synonyms
133
133
  '1838',
134
134
  'www.ottakringer.at',
135
135
  '1160 Wien // Ottakringer Platz 1',
136
136
  'brands: Ottakringer'
137
137
  ]
138
-
139
- by = Brewery.create_or_update_from_values( new_attributes, values )
140
138
 
141
- by2 = Brewery.find_by_key!( new_attributes[:key] )
139
+ more_attribs = {
140
+ country_id: AT.id
141
+ }
142
+
143
+ by = Brewery.create_or_update_from_values( values, more_attribs )
144
+
145
+ by2 = Brewery.find_by_key!( key )
142
146
  assert( by.id == by2.id )
143
147
 
144
148
  assert( by.title == 'Ottakringer Brauerei' )
@@ -152,27 +156,28 @@ class TestValues < MiniTest::Unit::TestCase
152
156
  # ottakringer, Ottakringer Brauerei, 1838, www.ottakringer.at, WI, city:wien, 1160 Wien // Ottakringer Platz 1
153
157
  # brands: Ottakringer
154
158
 
155
- new_attributes = {
156
- key: 'ottakringer',
157
- title: 'Ottakringer Brauerei',
158
- synonyms: '',
159
- country_id: AT.id,
160
- region_id: W.id
161
- }
159
+ key = 'ottakringer'
162
160
 
163
161
  values = [
162
+ key,
163
+ 'Ottakringer Brauerei',
164
164
  '1838',
165
165
  'www.ottakringer.at',
166
166
  '1160 Wien // Ottakringer Platz 1',
167
167
  'brands: Ottakringer'
168
168
  ]
169
-
170
- by = Brewery.create_or_update_from_values( new_attributes, values )
171
169
 
172
- by2 = Brewery.find_by_key!( new_attributes[:key] )
170
+ more_attribs = {
171
+ country_id: AT.id,
172
+ region_id: W.id
173
+ }
174
+
175
+ by = Brewery.create_or_update_from_values( values, more_attribs )
176
+
177
+ by2 = Brewery.find_by_key!( key )
173
178
  assert( by.id == by2.id )
174
179
 
175
- assert( by.title == new_attributes[:title] )
180
+ assert( by.title == values[1] )
176
181
  assert( by.country_id == AT.id )
177
182
  assert( by.country.title == AT.title )
178
183
  assert( by.since == 1838 )
@@ -197,27 +202,28 @@ class TestValues < MiniTest::Unit::TestCase
197
202
 
198
203
  # hofbraeu, Hofbräu München, 1589, www.hofbraeu-muenchen.de, 81829 München // Hofbräuallee 1
199
204
 
200
- new_attributes = {
201
- key: 'hofbraeu',
202
- title: 'Hofbräu München',
203
- synonyms: '',
204
- country_id: DE.id,
205
- region_id: BY.id
206
- }
205
+ key = 'hofbraeu'
207
206
 
208
207
  values = [
208
+ key,
209
+ 'Hofbräu München',
209
210
  '1589',
210
211
  'www.hofbraeu-muenchen.de',
211
212
  '81829 München // Hofbräuallee 1',
212
213
  'brands: Hofbräu'
213
214
  ]
214
-
215
- by = Brewery.create_or_update_from_values( new_attributes, values )
216
215
 
217
- by2 = Brewery.find_by_key!( new_attributes[:key] )
216
+ more_attribs = {
217
+ country_id: DE.id,
218
+ region_id: BY.id
219
+ }
220
+
221
+ by = Brewery.create_or_update_from_values( values, more_attribs )
222
+
223
+ by2 = Brewery.find_by_key!( key )
218
224
  assert( by.id == by2.id )
219
225
 
220
- assert( by.title == new_attributes[:title] )
226
+ assert( by.title == values[1] )
221
227
  assert( by.country_id == DE.id )
222
228
  assert( by.country.title == DE.title )
223
229
  assert( by.since == 1589 )
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.15
4
+ version: 0.7.0
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: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &87568670 !ruby/object:Gem::Requirement
16
+ requirement: &81804710 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *87568670
24
+ version_requirements: *81804710
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: worlddb
27
- requirement: &87568420 !ruby/object:Gem::Requirement
27
+ requirement: &81804490 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '1.6'
32
+ version: '1.7'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *87568420
35
+ version_requirements: *81804490
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: commander
38
- requirement: &87568190 !ruby/object:Gem::Requirement
38
+ requirement: &81804270 !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: *87568190
46
+ version_requirements: *81804270
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &87567960 !ruby/object:Gem::Requirement
49
+ requirement: &81804050 !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: *87567960
57
+ version_requirements: *81804050
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &87567740 !ruby/object:Gem::Requirement
60
+ requirement: &81803830 !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: *87567740
68
+ version_requirements: *81803830
69
69
  description: beerdb - beer.db command line tool
70
70
  email: beerdb@googlegroups.com
71
71
  executables:
@@ -94,6 +94,8 @@ files:
94
94
  - lib/beerdb/models/tag.rb
95
95
  - lib/beerdb/reader.rb
96
96
  - lib/beerdb/schema.rb
97
+ - lib/beerdb/serializers/beer.rb
98
+ - lib/beerdb/serializers/brewery.rb
97
99
  - lib/beerdb/server.rb
98
100
  - lib/beerdb/server/public/style.css
99
101
  - lib/beerdb/server/views/_debug.erb
@@ -103,6 +105,7 @@ files:
103
105
  - lib/beerdb/server/views/layout.erb
104
106
  - lib/beerdb/stats.rb
105
107
  - lib/beerdb/version.rb
108
+ - test/helper.rb
106
109
  - test/test_values.rb
107
110
  - .gemtest
108
111
  homepage: https://github.com/geraldb/beer.db.ruby