Class: SportDb::Import::Catalog
- Inherits:
-
Object
- Object
- SportDb::Import::Catalog
- Defined in:
- lib/sportdb/config/catalog.rb
Instance Method Summary collapse
- #build_club_index ⇒ Object
-
#build_country_index ⇒ Object
todo/check: rename to setup_country_index or read_country_index - why? why not?.
- #build_event_index ⇒ Object
- #build_league_index ⇒ Object
- #build_national_team_index ⇒ Object
- #build_season_index ⇒ Object
- #build_team_index ⇒ Object
- #clubs ⇒ Object
- #config ⇒ Object
-
#countries ⇒ Object
todo/check: rename to country_mappings/index - why? why not? or countries_by_code or countries_by_key.
- #events ⇒ Object
- #leagues ⇒ Object
- #national_teams ⇒ Object
- #seasons ⇒ Object
- #teams ⇒ Object
Instance Method Details
#build_club_index ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 ⇒ Object
todo/check: rename to setup_country_index or read_country_index - why? why not?
24 25 26 |
# 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 ⇒ Object
77 78 79 80 81 82 83 84 |
# 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 ⇒ Object
68 69 70 71 72 73 74 |
# 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 ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 ⇒ Object
86 87 88 89 |
# 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 ⇒ Object
22 |
# File 'lib/sportdb/config/catalog.rb', line 22 def build_team_index() TeamIndex.new; end |
#clubs ⇒ Object
14 |
# File 'lib/sportdb/config/catalog.rb', line 14 def clubs() @clubs ||= build_club_index; end |
#config ⇒ Object
7 |
# File 'lib/sportdb/config/catalog.rb', line 7 def config() Import.config; end |
#countries ⇒ Object
todo/check: rename to country_mappings/index - why? why not?
or countries_by_code or countries_by_key
12 |
# File 'lib/sportdb/config/catalog.rb', line 12 def countries() @countries ||= build_country_index; end |
#events ⇒ Object
18 |
# File 'lib/sportdb/config/catalog.rb', line 18 def events() @events ||= build_event_index; end |
#leagues ⇒ Object
16 |
# File 'lib/sportdb/config/catalog.rb', line 16 def leagues() @leagues ||= build_league_index; end |
#national_teams ⇒ Object
13 |
# File 'lib/sportdb/config/catalog.rb', line 13 def national_teams() @national_teams ||= build_national_team_index; end |
#seasons ⇒ Object
19 |
# File 'lib/sportdb/config/catalog.rb', line 19 def seasons() @seasons ||= build_season_index; end |
#teams ⇒ Object
15 |
# File 'lib/sportdb/config/catalog.rb', line 15 def teams() @teams ||= build_team_index; end |