lib/beerdb/reader.rb in beerdb-0.6.13 vs lib/beerdb/reader.rb in beerdb-0.6.14
- old
+ new
@@ -45,11 +45,11 @@
load_beers_for_country( $1, name )
elsif name =~ /\.hl$/ # e.g. breweries.hl # NB: must end w/ .hl
load_brewery_prod( name )
elsif name =~ /\/([a-z]{2})\.wikipedia/ # e.g. de.wikipedia
# auto-add required lang e.g. de or en etc.
- load_brewery_wiki( $1, name )
+ load_brewery_wikipedia( $1, name )
elsif name =~ /\/([a-z]{2})-[^\/]+\/([a-z]{1,2})-[^\/]+\/breweries/
# new style: e.g. /at-austria/w-wien/breweries
# auto-add required country n region code (from folder structure)
load_breweries_for_country_n_region( $1, $2, name )
elsif name =~ /\/([a-z]{2})-[^\/]+\/breweries/
@@ -64,23 +64,23 @@
logger.error "unknown beer.db fixture type >#{name}<"
# todo/fix: exit w/ error
end
end
- def load_brewery_wiki( lang_key, name )
+ def load_brewery_wikipedia( lang_key, name )
path = "#{include_path}/#{name}.yml"
logger.info "parsing data '#{name}' (#{path})..."
reader = HashReader.new( path )
reader.each do |key, value|
brewery = Brewery.find_by_key!( key )
- wiki = "#{lang_key}.wikipedia.org/wiki/#{value.strip}"
- logger.debug " adding #{key} => >#{wiki}<"
- brewery.wiki = wiki
+ wikipedia = "#{lang_key}.wikipedia.org/wiki/#{value.strip}"
+ logger.debug " adding #{key} => >#{wikipedia}<"
+ brewery.wikipedia = wikipedia
brewery.save!
end
Prop.create_from_fixture!( name, path )
end
@@ -117,20 +117,24 @@
region = Region.find_by_key_and_country_id!( region_key, country.id )
logger.debug "Region #{region.key} >#{region.title}<"
more_values[ :country_id ] = country.id
more_values[ :region_id ] = region.id
+
+ more_values[ :txt ] = name # store source ref
load_beers_worker( name, more_values )
end
def load_beers_for_country( country_key, name, more_values={} )
country = Country.find_by_key!( country_key )
logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
more_values[ :country_id ] = country.id
+ more_values[ :txt ] = name # store source ref
+
load_beers_worker( name, more_values )
end
def load_beers_worker( name, more_values={} )
path = "#{include_path}/#{name}.txt"
@@ -156,17 +160,21 @@
logger.debug "Region #{region.key} >#{region.title}<"
more_values[ :country_id ] = country.id
more_values[ :region_id ] = region.id
+ more_values[ :txt ] = name # store source ref
+
load_breweries_worker( name, more_values )
end
def load_breweries_for_country( country_key, name, more_values={} )
country = Country.find_by_key!( country_key )
logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
more_values[ :country_id ] = country.id
+
+ more_values[ :txt ] = name # store source ref
load_breweries_worker( name, more_values )
end
def load_breweries_worker( name, more_values={} )