lib/sportdb/reader.rb in sportdb-1.6.1 vs lib/sportdb/reader.rb in sportdb-1.6.2

- old
+ new

@@ -91,13 +91,19 @@ load_leagues( name, club: true ) else # e.g. leagues load_leagues( name ) end + elsif name =~ /^([a-z]{2})\/leagues/ + # auto-add country code (from folder structure) for country-specific leagues + # e.g. at/leagues + country_key = $1 + country = Country.find_by_key!( country_key ) + load_leagues( name, club: true, country_id: country.id ) elsif name =~ /^([a-z]{2})\/teams/ # auto-add country code (from folder structure) for country-specific teams - # e.g. at/teams at/teams2 de/teams etc. + # e.g. at/teams at/teams.2 de/teams etc. country_key = $1 country = Country.find_by_key!( country_key ) load_teams( name, club: true, country_id: country.id ) elsif name =~ /\/teams/ if name =~ /club/ @@ -148,11 +154,11 @@ def load_seasons( name ) path = "#{include_path}/#{name}.yml" - puts "*** parsing data '#{name}' (#{path})..." + logger.info "parsing data '#{name}' (#{path})..." reader = HashReader.new( path ) reader.each_typed do |key, value| @@ -234,11 +240,11 @@ elsif key == 'start_at' if value.is_a?(DateTime) || value.is_a?(Date) start_at = value else # assume it's a string - start_at = DateTime.strptime( value.to_s.strip, '%Y-%m-%d %H:%M' ) + start_at = DateTime.strptime( value.to_s.strip, '%Y-%m-%d' ) end event_attribs['start_at'] = start_at elsif key == 'teams' @@ -296,11 +302,11 @@ def load_fixtures( event_key, name ) # load from file system path = "#{include_path}/#{name}.txt" - puts "*** parsing data '#{name}' (#{path})..." + logger.info "parsing data '#{name}' (#{path})..." SportDB.lang.lang = LangChecker.new.analyze( name, include_path ) reader = LineReader.new( path ) @@ -311,10 +317,10 @@ def load_teams( name, more_values={} ) path = "#{include_path}/#{name}.txt" - puts "*** parsing data '#{name}' (#{path})..." + logger.info "parsing data '#{name}' (#{path})..." reader = ValuesReader.new( path, more_values ) load_teams_worker( reader )