class SportDb::Import::Catalog
Public Instance Methods
build_club_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 44 def build_club_index ## unify team names; team (builtin/known/shared) name mappings ## cleanup team names - use local ("native") name with umlaut etc. ## todo/fix: add to teamreader ## check that name and alt_names for a club are all unique (not duplicates) clubs = if config.clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil) ClubIndex.build( config.clubs_dir ) else ## no clubs_dir set - try using builtin from footballdb-clubs FootballDb::Import::build_club_index end if clubs.errors? puts "" puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" puts " #{clubs.errors.size} errors:" pp clubs.errors ## exit 1 end clubs end
build_country_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 24 def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not? CountryIndex.new( Fifa.countries ) end
build_event_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 77 def build_event_index if config.leagues_dir ## (re)use leagues dir for now - add separate seasons_dir - why? why not? EventIndex.build( config.leagues_dir ) else puts "!! WARN - no leagues_dir set; for now buit-in events in catalog - fix!!!!" EventIndex.new ## return empty event index end end
build_league_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 68 def build_league_index leagues = if config.leagues_dir ## check if clubs_dir is defined / set (otherwise it's nil) LeagueIndex.build( config.leagues_dir ) else ## no leagues_dir set - try using builtin from footballdb-leagues FootballDb::Import.build_league_index end end
build_national_team_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 28 def build_national_team_index ## auto-build national teams from Fifa.countries for now teams = [] Fifa.countries.each do |country| team = NationalTeam.new( key: country.code.downcase, ## note: use country code (fifa) name: country.name, code: country.code, ## note: use country code (fifa) alt_names: country.alt_names ) team.country = country teams << team end NationalTeamIndex.new( teams ) end
build_season_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 86 def build_season_index # note: for now always (re)use the events from the event (info) index SeasonIndex.new( events ) end
build_team_index()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 22 def build_team_index() TeamIndex.new; end
clubs()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 14 def clubs() @clubs ||= build_club_index; end
config()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 7 def config() Import.config; end
countries()
click to toggle source
todo/check: rename to country_mappings/index - why? why not?
or countries_by_code or countries_by_key
# File lib/sportdb/config/catalog.rb, line 12 def countries() @countries ||= build_country_index; end
events()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 18 def events() @events ||= build_event_index; end
leagues()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 16 def leagues() @leagues ||= build_league_index; end
national_teams()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 13 def national_teams() @national_teams ||= build_national_team_index; end
seasons()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 19 def seasons() @seasons ||= build_season_index; end
teams()
click to toggle source
# File lib/sportdb/config/catalog.rb, line 15 def teams() @teams ||= build_team_index; end