lib/sportdb/reader.rb in sportdb-1.8.22 vs lib/sportdb/reader.rb in sportdb-1.8.23
- old
+ new
@@ -72,10 +72,14 @@
elsif name =~ /^tracks/ # e.g. tracks.txt in ski.db
reader = TrackReader.new( include_path )
reader.read( name )
elsif name =~ /^drivers/ # e.g. drivers.txt in formula1.db
load_persons( name )
+ elsif match_players_for_country( name ) do |country_key|
+ country = Country.find_by_key!( country_key )
+ load_persons( name, country_id: country.id )
+ end
elsif match_skiers_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/skiers/
# auto-add country code (from folder structure) for country-specific skiers (persons)
# e.g. at/skiers or at-austria/skiers.men
country = Country.find_by_key!( country_key )
load_persons( name, country_id: country.id )
@@ -137,19 +141,16 @@
end
end # method load
####
- ## fix: move to persondb for (re)use
+ # fix: move to persondb for (re)use
def load_persons( name, more_attribs={} )
-
- reader = ValuesReaderV2.new( name, include_path, more_attribs )
-
- reader.each_line do |new_attributes, values|
- Person.create_or_update_from_values( new_attributes, values )
- end # each lines
-
+ reader = PersonDb::PersonReader.new( include_path )
+ ## fix: add more_attribs !!!!! -- check other readers as an example
+ ## - gets added to new or read??
+ reader.read( name )
end # load_persons
end # class Reader
end # module SportDb