sportdb-models 1.18.6 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +0 -106
  3. data/Rakefile +0 -1
  4. data/lib/sportdb/deleter.rb +1 -1
  5. data/lib/sportdb/models.rb +3 -88
  6. data/lib/sportdb/version.rb +2 -2
  7. data/test/helper.rb +0 -108
  8. metadata +2 -122
  9. data/lib/sportdb/indexers/team.rb +0 -87
  10. data/lib/sportdb/matcher.rb +0 -31
  11. data/lib/sportdb/pretty_printer.rb +0 -175
  12. data/lib/sportdb/reader.rb +0 -132
  13. data/lib/sportdb/reader_file.rb +0 -131
  14. data/lib/sportdb/reader_zip.rb +0 -172
  15. data/lib/sportdb/readers/assoc.rb +0 -54
  16. data/lib/sportdb/readers/event.rb +0 -253
  17. data/lib/sportdb/readers/event_meta.rb +0 -133
  18. data/lib/sportdb/readers/event_table.rb +0 -196
  19. data/lib/sportdb/readers/game.rb +0 -912
  20. data/lib/sportdb/readers/ground.rb +0 -53
  21. data/lib/sportdb/readers/league.rb +0 -54
  22. data/lib/sportdb/readers/season.rb +0 -83
  23. data/lib/sportdb/readers/squad_club.rb +0 -201
  24. data/lib/sportdb/readers/squad_national_team.rb +0 -173
  25. data/lib/sportdb/readers/team.rb +0 -53
  26. data/lib/sportdb/rsssf_reader.rb +0 -367
  27. data/lib/sportdb/utils.rb +0 -89
  28. data/lib/sportdb/utils_date.rb +0 -26
  29. data/lib/sportdb/utils_goals.rb +0 -20
  30. data/lib/sportdb/utils_group.rb +0 -63
  31. data/lib/sportdb/utils_map.rb +0 -44
  32. data/lib/sportdb/utils_round.rb +0 -165
  33. data/lib/sportdb/utils_scores.rb +0 -17
  34. data/lib/sportdb/utils_teams.rb +0 -48
  35. data/test/data/at-austria/2013_14/bl.txt +0 -227
  36. data/test/data/at-austria/2013_14/bl.yml +0 -30
  37. data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
  38. data/test/data/at-austria/2013_14/el.txt +0 -4
  39. data/test/data/at-austria/2013_14/el.yml +0 -25
  40. data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
  41. data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
  42. data/test/data/at-austria/2014_15/1-bundesliga-ii.txt +0 -158
  43. data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
  44. data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
  45. data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
  46. data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
  47. data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
  48. data/test/data/at-austria/2015_16/cup.yml +0 -77
  49. data/test/data/at-austria/leagues.txt +0 -11
  50. data/test/data/at-austria/teams.txt +0 -68
  51. data/test/data/at-austria/teams_2.txt +0 -21
  52. data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
  53. data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
  54. data/test/data/de-deutschland/leagues.txt +0 -4
  55. data/test/data/de-deutschland/teams.txt +0 -53
  56. data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
  57. data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
  58. data/test/data/national-teams/assocs.txt +0 -231
  59. data/test/data/national-teams/europe/assocs.txt +0 -13
  60. data/test/data/national-teams/europe/teams.txt +0 -13
  61. data/test/data/national-teams/north-america/assocs.txt +0 -10
  62. data/test/data/national-teams/north-america/teams.txt +0 -7
  63. data/test/data/national-teams/teams.txt +0 -19
  64. data/test/data/players/europe/at-austria/players.txt +0 -45
  65. data/test/data/players/europe/de-deutschland/players.txt +0 -41
  66. data/test/data/players/south-america/br-brazil/players.txt +0 -51
  67. data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
  68. data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
  69. data/test/data/world-cup/1930/cup.txt +0 -71
  70. data/test/data/world-cup/1930/cup.yml +0 -23
  71. data/test/data/world-cup/1930/cup_goals.txt +0 -47
  72. data/test/data/world-cup/1930/cup_goals.yml +0 -23
  73. data/test/data/world-cup/1954/cup.txt +0 -90
  74. data/test/data/world-cup/1954/cup.yml +0 -30
  75. data/test/data/world-cup/1962/cup.txt +0 -86
  76. data/test/data/world-cup/1962/cup.yml +0 -32
  77. data/test/data/world-cup/1974/cup.yml +0 -35
  78. data/test/data/world-cup/1974/cup_finals.txt +0 -14
  79. data/test/data/world-cup/1974/cup_i.txt +0 -55
  80. data/test/data/world-cup/1974/cup_ii.txt +0 -34
  81. data/test/data/world-cup/2014/cup.txt +0 -5
  82. data/test/data/world-cup/2014/cup.yml +0 -54
  83. data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
  84. data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
  85. data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
  86. data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
  87. data/test/data/world-cup/leagues.txt +0 -5
  88. data/test/data/world-cup/seasons_1930.txt +0 -4
  89. data/test/data/world-cup/seasons_1954.txt +0 -4
  90. data/test/data/world-cup/seasons_1962.txt +0 -4
  91. data/test/data/world-cup/seasons_1974.txt +0 -5
  92. data/test/data/world-cup/teams_1930.txt +0 -26
  93. data/test/data/world-cup/teams_1954.txt +0 -30
  94. data/test/data/world-cup/teams_1962.txt +0 -29
  95. data/test/data/world-cup/teams_1974.txt +0 -29
  96. data/test/test_assoc_reader.rb +0 -199
  97. data/test/test_event_meta_reader.rb +0 -47
  98. data/test/test_event_reader.rb +0 -64
  99. data/test/test_event_table_reader.rb +0 -57
  100. data/test/test_goals.rb +0 -107
  101. data/test/test_indexer_team.rb +0 -34
  102. data/test/test_load.rb +0 -61
  103. data/test/test_pp.rb +0 -35
  104. data/test/test_reader.rb +0 -88
  105. data/test/test_reader_from_string.rb +0 -63
  106. data/test/test_round_auto.rb +0 -370
  107. data/test/test_round_def.rb +0 -109
  108. data/test/test_round_header.rb +0 -183
  109. data/test/test_rsssf_reader.rb +0 -76
  110. data/test/test_squad_club_reader.rb +0 -76
  111. data/test/test_squad_national_team_reader.rb +0 -116
  112. data/test/test_standings.rb +0 -279
  113. data/test/test_standings_ii.rb +0 -46
  114. data/test/test_utils.rb +0 -124
@@ -1,87 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module SportDb
4
-
5
-
6
- ##
7
- # todo/check:
8
- # simply add index() method to TeamReader (and remove this class) - why? why not??
9
-
10
-
11
- class TeamIndexer
12
-
13
- include LogUtils::Logging
14
-
15
- ## make models available by default with namespace
16
- # e.g. lets you use Usage instead of Model::Usage
17
- include Models
18
-
19
-
20
- def self.from_file( path, more_attribs={} )
21
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
22
- ## - see textutils/utils.rb
23
- text = File.read_utf8( path )
24
- self.from_string( text, more_attribs )
25
- end
26
-
27
- def self.from_string( text, more_attribs={} )
28
- self.new( text, more_attribs )
29
- end
30
-
31
- def initialize( text, more_attribs={} )
32
- ## todo/fix: how to add opts={} ???
33
- @text = text
34
- @more_attribs = more_attribs
35
- end
36
-
37
-
38
- def read
39
- ## return a hash (with all records) e.g.
40
- ## {"austria"=>
41
- ## {:title=>"FK Austria Wien",
42
- ## :synonyms=>["Austria Wien", "Austria"],
43
- ## :values=>
44
- ## ["1911",
45
- ## "AUS",
46
- ## "www.fk-austria.at",
47
- ## "Fischhofgasse 12 // 1100 Wien",
48
- ## "city:wien"]},
49
- ## "rapid"=>
50
- ## {:title=>"SK Rapid Wien",
51
- ## :synonyms=>["Rapid Wien", "Rapid"],
52
- ## :values=>
53
- ## ["1899",
54
- ## "RAP",
55
- ## "www.skrapid.at",
56
- ## "Keisslergasse 3 // 1140 Wien",
57
- ## "city:wien"]},
58
- ## ...
59
-
60
- reader = ValuesReader.from_string( @text, @more_attribs )
61
-
62
- h = {}
63
-
64
- reader.each_line do |new_attributes, values|
65
- puts "attribs:"
66
- pp new_attributes
67
-
68
- key = new_attributes.delete( :key ) ## remove key
69
-
70
- ## turn synonyms into an array
71
- synonyms = new_attributes[ :synonyms ]
72
- if synonyms
73
- new_attributes[ :synonyms ] = synonyms.split('|')
74
- end
75
-
76
- new_attributes[ :values ] = values
77
-
78
- h[ key ] = new_attributes
79
-
80
- end # each lines
81
-
82
- h ## return hash with all records (indexed by key)
83
- end
84
-
85
-
86
- end # class TeamIndexer
87
- end # module SportDb
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- module Matcher
6
-
7
- include WorldDb::Matcher
8
-
9
- def match_leagues_for_country( name, &blk )
10
- match_xxx_for_country( name, 'leagues', &blk )
11
- end
12
-
13
- def match_teams_for_country( name, &blk )
14
- match_xxx_for_country( name, 'teams', &blk )
15
- end
16
-
17
- def match_clubs_for_country( name, &blk )
18
- match_xxx_for_country( name, 'clubs', &blk )
19
- end
20
-
21
- def match_players_for_country( name, &blk )
22
- match_xxx_for_country( name, 'players', &blk )
23
- end
24
-
25
- def match_stadiums_for_country( name, &blk )
26
- match_xxx_for_country( name, 'stadiums', &blk )
27
- end
28
-
29
- end # module Matcher
30
-
31
- end # module SportDb
@@ -1,175 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module SportDb
4
-
5
-
6
- ###
7
- ## reads in a text files
8
- ## and tries to fix up/patch some parts
9
-
10
-
11
- class Patcher
12
-
13
- include LogUtils::Logging
14
-
15
- def initialize( root, opts={} )
16
- @root = root
17
- @path = opts[:path] || opts[:paths] # pass in regex as string
18
- @names = opts[:name] || opts[:names] # pass in regex as string
19
-
20
- @path_regex = Regexp.new( @path ) if @path
21
- @names_regex = Regexp.new( @names ) if @names
22
- end
23
-
24
-
25
- def find_files
26
- ## note: for now always filter by .txt extension
27
- files = Dir[ "#{@root}/**/*.txt" ]
28
-
29
- puts "before filter:"
30
- pp files
31
-
32
- files = files.select do |f|
33
-
34
- basename = File.basename( f )
35
- dirname = File.dirname( f ) # note: add trailing slash
36
- dirname = "#{dirname}/"
37
-
38
- puts " basename=>#{basename}<, dirname=>#{dirname}<"
39
-
40
- if @path_regex
41
- match_dirname = @path_regex === dirname # note: use === (triple) for true/false regex match
42
- else
43
- match_dirname = true
44
- end
45
-
46
- if @names_regex
47
- match_basename = @names_regex === basename
48
- else
49
- match_basename = true
50
- end
51
-
52
- match_basename && match_dirname
53
- end
54
-
55
- puts "after filter:"
56
- pp files
57
-
58
- files
59
- end # method find_files
60
-
61
-
62
- def patch( save=false)
63
- files = find_files
64
- change_logs = []
65
-
66
- files.each do |file|
67
- p = PrettyPrinter.from_file( file )
68
- new_text, change_log = p.patch
69
-
70
- next if change_log.empty? ## no changes
71
-
72
- if save
73
- File.open( file, 'w' ) do |f|
74
- f.write new_text
75
- end
76
- end
77
-
78
- change_logs << [file, change_log]
79
- end
80
-
81
- change_logs ## return change_logs or empty array
82
- end # method patch
83
-
84
- end ## class Patcher
85
-
86
-
87
- class PrettyPrinter
88
-
89
- include LogUtils::Logging
90
-
91
- def self.from_file( path, opts={} )
92
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
93
- ## - see textutils/utils.rb
94
- text = File.read_utf8( path )
95
- self.from_string( text, opts )
96
- end
97
-
98
- def self.from_string( text, opts={} )
99
- self.new( text, opts )
100
- end
101
-
102
-
103
- def initialize( text, opts={} )
104
- @old_text = text
105
- @opts = opts
106
- end
107
-
108
-
109
- ## change to DE_SCORES_REGEX or SCORES_DE_REGEX ??
110
- SCORES_REGEX = /\b
111
- (?<score1>\d{1,2})
112
- -
113
- (?<score2>\d{1,2})
114
- \b
115
- /x
116
-
117
- def patch ## return new text (and change log??)
118
- new_text = ''
119
- change_log = [] ## track changes - rename - use edits? changes? etc.
120
- line_no = 0
121
-
122
- @old_text.each_line do |line|
123
- line_no +=1
124
-
125
- # comments allow:
126
- # 1) ##### (shell/ruby style)
127
- # 2) -- comment here (haskel/?? style)
128
- # 3) % comment here (tex/latex style)
129
-
130
- if line =~ /^\s*#/ || line =~ /^\s*--/ || line =~ /^\s*%/
131
- # skip komments and do NOT copy to result (keep comments secret!)
132
- logger.debug "[#{line_no}] add comment line >#{line}<"
133
- new_text << line
134
- next
135
- end
136
-
137
- if line =~ /^\s*$/
138
- # kommentar oder leerzeile überspringen
139
- logger.debug "[#{line_no}] add blank line >#{line}<"
140
- new_text << line
141
- next
142
- end
143
-
144
- ## do nothing for now
145
- if line =~ SCORES_REGEX
146
- ## patch scores format
147
- logger.debug "** found scores >#{line}<"
148
-
149
- new_line = line.dup
150
- new_line.gsub!( SCORES_REGEX ) do |m|
151
- logger.debug " match: >#{m}< : #{m.class.name}"
152
-
153
- old_scores = m
154
- ## todo: how to use named captures? possible?
155
- new_scores = "#{$1}:#{$2}"
156
-
157
- change_log << [line_no, "changed >#{old_scores}< to >#{new_scores}< in >#{line}<"]
158
-
159
- new_scores
160
- end
161
-
162
- logger.debug "[#{line_no}] add patched line >#{new_line}<"
163
- new_text << new_line
164
- else
165
- logger.debug "[#{line_no}] add >#{line}<"
166
- new_text << line
167
- end
168
- end # each lines
169
-
170
- [new_text, change_log]
171
- end # method patch
172
-
173
-
174
- end # class PrettyPrinter
175
- end # module SportDb
@@ -1,132 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- class ReaderBase
6
-
7
- include LogUtils::Logging
8
-
9
-
10
- ## make models available in sportdb module by default with namespace
11
- # e.g. lets you use Team instead of Model::Team
12
- include SportDb::Models
13
- include SportDb::Matcher # lets us use match_teams_for_country etc.
14
-
15
-
16
- def load_setup( name )
17
- reader = create_fixture_reader( name )
18
-
19
- reader.each do |fixture_name|
20
- load( fixture_name )
21
- end
22
- end # method load_setup
23
-
24
-
25
- def load( name ) # convenience helper for all-in-one reader
26
-
27
- logger.debug "enter load( name=>>#{name}<<)" ## formerly also printed -> include_path=>>#{include_path}<<
28
-
29
- if match_players_for_country( name ) do |country_key|
30
- ## country = Country.find_by_key!( country_key )
31
- ## fix-fix-fix-fix-fix-fix: change to new format e.g. from_file, from_zip etc!!!
32
- ## reader = PersonDb::PersonReader.new( include_path )
33
- ## reader.read( name, country_id: country.id )
34
- end
35
- elsif name =~ /\/squads\/([a-z0-9]{3,})$/ # e.g. ajax.txt bayern.txt etc.
36
- ## note: for now assume club (e.g. no dash (-) allowed for country code e.g. br-brazil etc.)
37
- team = Team.find_by_key!( $1 )
38
- ## note: pass in @event.id - that is, last seen event (e.g. parsed via GameReader/MatchReader)
39
- reader = create_club_squad_reader( name, team_id: team.id, event_id: @event.id )
40
- reader.read()
41
- elsif name =~ /\/squads\/([a-z]{2,3})-[^\/]+$/
42
- ## fix: add to country matcher new format
43
- ## name is country! and parent folder is type name e.g. /squads/br-brazil
44
-
45
- # note: if two letters, assume country key
46
- # if three letters, assume team key
47
-
48
- ## allow three letter codes
49
- ## assume three letter code are *team* codes (e.g. fdr, gdr, etc)
50
- ## not country code (allows multiple teams per country)
51
-
52
- if $1.length == 2
53
- ## get national team via country
54
- country = Country.find_by_key!( $1 )
55
- ### for now assume country code matches team for now (do NOT forget to downcase e.g. BRA==bra)
56
- logger.info " assume country code == team code for #{country.code}"
57
- team = Team.find_by_key!( country.code.downcase )
58
- else # assume length == 3
59
- ## get national team directly (use three letter fifa code)
60
- team = Team.find_by_key!( $1 )
61
- end
62
- ## note: pass in @event.id - that is, last seen event (e.g. parsed via GameReader/MatchReader)
63
- reader = create_national_team_squad_reader( name, team_id: team.id, event_id: @event.id )
64
- reader.read()
65
- elsif name =~ /(?:^|\/)seasons/ # NB: ^seasons or also possible at-austria!/seasons
66
- reader = create_season_reader( name )
67
- reader.read()
68
- elsif name =~ /(?:^|\/)assocs/ # NB: ^assocs or also possible national-teams!/assocs
69
- reader = create_assoc_reader( name )
70
- reader.read()
71
- elsif match_stadiums_for_country( name ) do |country_key|
72
- country = Country.find_by_key!( country_key )
73
- reader = create_ground_reader( name, country_id: country.id )
74
- reader.read()
75
- end
76
- elsif match_leagues_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/leagues/
77
- # auto-add country code (from folder structure) for country-specific leagues
78
- # e.g. at/leagues
79
- country = Country.find_by_key!( country_key )
80
- reader = create_league_reader( name, club: true, country_id: country.id )
81
- reader.read()
82
- end
83
- elsif name =~ /(?:^|\/)leagues/ # NB: ^leagues or also possible world!/leagues - NB: make sure goes after leagues_for_country!!
84
- reader = create_league_reader( name )
85
- reader.read()
86
- elsif match_teams_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/teams/
87
- # auto-add country code (from folder structure) for country-specific teams
88
- # e.g. at/teams at/teams.2 de/teams etc.
89
- country = Country.find_by_key!( country_key )
90
- reader = create_team_reader( name, country_id: country.id )
91
- reader.read()
92
- end
93
- elsif match_clubs_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/clubs/
94
- # auto-add country code (from folder structure) for country-specific clubs
95
- # e.g. at/teams at/teams.2 de/teams etc.
96
- country = Country.find_by_key!( country_key )
97
- reader = create_team_reader( name, club: true, country_id: country.id ) ## note: always sets club flag to true
98
- reader.read()
99
- end
100
- elsif name =~ /(?:^|\/)teams/ ## fix: check if teams rule above (e.g. /^teams/ )conflicts/matches first ???
101
- ### fix: use new NationalTeamReader ??? why? why not?
102
- reader = create_team_reader( name ) ## note: always sets club flag to true / national to true
103
- reader.read()
104
- elsif name =~ /(?:^|\/)clubs/
105
- ### fix: use new ClubReader ??? why? why not?
106
- reader = create_team_reader( name, club: true ) ## note: always sets club flag to true / national to false
107
- reader.read()
108
- elsif name =~ /\.conf$/ ## e.g. 1-premierleague.conf => 1-premierleague.conf.txt
109
- reader = create_event_table_reader( name )
110
- reader.read()
111
- # note: keep a "public" reference of last event in @event - e.g. used/required by squads etc.
112
- @event = reader.event
113
- elsif name =~ /\/(\d{4}|\d{4}[_\-]\d{2})(--[^\/]+)?\// ||
114
- name =~ /\/(\d{4}|\d{4}[_\-]\d{2})$/
115
-
116
- # note: allow 2013_14 or 2013-14 (that, is dash or underscore)
117
-
118
- # e.g. must match /2012/ or /2012_13/ or /2012--xxx/ or /2012_13--xx/
119
- # or /2012 or /2012_13 e.g. brazil/2012 or brazil/2012_13
120
- reader = create_game_reader( name )
121
- reader.read()
122
- # note: keep a "public" reference of last event in @event - e.g. used/required by squads etc.
123
- @event = reader.event
124
- else
125
- logger.error "unknown sportdb fixture type >#{name}<"
126
- # todo/fix: exit w/ error
127
- end
128
- end # method load
129
-
130
-
131
- end # class Reader
132
- end # module SportDb
@@ -1,131 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- ## todo: "old" classic reader - rename to FileReader ?? why? why not?
6
-
7
- class Reader < ReaderBase
8
-
9
- attr_reader :include_path
10
-
11
- def initialize( include_path, opts={})
12
- @include_path = include_path
13
- end
14
-
15
- def create_fixture_reader( name )
16
- path = "#{@include_path}/#{name}.txt"
17
-
18
- logger.info "parsing data (setup) '#{name}' (#{path})..."
19
-
20
- FixtureReader.from_file( path )
21
- end
22
-
23
- def create_club_squad_reader( name, more_attribs={} )
24
- real_name = name_to_real_name( name )
25
- path = "#{@include_path}/#{real_name}.txt"
26
-
27
- logger.info "parsing data (club squad) '#{name}' (#{path})..."
28
- ClubSquadReader.from_file( path, more_attribs )
29
- end
30
-
31
- def create_national_team_squad_reader( name, more_attribs={} )
32
- real_name = name_to_real_name( name )
33
- path = "#{@include_path}/#{real_name}.txt"
34
-
35
- logger.info "parsing data (national team squad) '#{name}' (#{path})..."
36
- NationalTeamSquadReader.from_file( path, more_attribs )
37
- end
38
-
39
- def create_season_reader( name )
40
- real_name = name_to_real_name( name )
41
- path = "#{@include_path}/#{real_name}.txt"
42
-
43
- logger.info "parsing data (season) '#{name}' (#{path})..."
44
- SeasonReader.from_file( path )
45
- end
46
-
47
- def create_assoc_reader( name )
48
- real_name = name_to_real_name( name )
49
- path = "#{@include_path}/#{real_name}.txt"
50
-
51
- logger.info "parsing data (assoc) '#{name}' (#{path})..."
52
- AssocReader.from_file( path )
53
- end
54
-
55
- def create_ground_reader( name, more_attribs={} )
56
- real_name = name_to_real_name( name )
57
- path = "#{@include_path}/#{real_name}.txt"
58
-
59
- logger.info "parsing data (ground) '#{name}' (#{path})..."
60
- GroundReader.from_file( path, more_attribs )
61
- end
62
-
63
- def create_league_reader( name, more_attribs={} )
64
- real_name = name_to_real_name( name )
65
- path = "#{@include_path}/#{real_name}.txt"
66
-
67
- logger.info "parsing data (league) '#{name}' (#{path})..."
68
- LeagueReader.from_file( path, more_attribs )
69
- end
70
-
71
- def create_team_reader( name, more_attribs={} )
72
- real_name = name_to_real_name( name )
73
- path = "#{@include_path}/#{real_name}.txt"
74
-
75
- logger.info "parsing data (team) '#{name}' (#{path})..."
76
- TeamReader.from_file( path, more_attribs )
77
- end
78
-
79
- def create_event_reader( name, more_attribs={} )
80
- real_name = name_to_real_name( name )
81
- path = "#{@include_path}/#{real_name}.yml"
82
-
83
- logger.info "parsing data (event) '#{name}' (#{path})..."
84
- EventReader.from_file( path, more_attribs )
85
- end
86
-
87
- def create_event_table_reader( name, more_attribs={} )
88
- real_name = name_to_real_name( name )
89
- path = "#{@include_path}/#{real_name}.txt"
90
-
91
- logger.info "parsing data (event table) '#{name}' (#{path})..."
92
- EventTableReader.from_file( path, more_attribs )
93
- end
94
-
95
- def create_game_reader( name, more_attribs={} )
96
- real_name = name_to_real_name( name )
97
-
98
- ## NOTE: pass in .yml as path (that is, event config!!!!)
99
- path = "#{@include_path}/#{real_name}.yml"
100
-
101
- logger.info "parsing data (fixture) '#{name}' (#{path})..."
102
- GameReader.from_file( path, more_attribs )
103
- end
104
-
105
-
106
- def create_person_reader( name, more_attribs={} )
107
- ## fix-fix-fix: change to new format e.g. from_file, from_zip etc!!!
108
- ## reader = PersonDb::PersonReader.new( include_path )
109
- # reader.read( name, country_id: country.id )
110
- end
111
-
112
- private
113
-
114
- def name_to_real_name( name )
115
- # map name to real_name path
116
- # name might include !/ for virtual path (gets cut off)
117
- # e.g. at-austria!/w-wien/beers becomse w-wien/beers
118
- pos = name.index( '!/')
119
- if pos.nil?
120
- name # not found; real path is the same as name
121
- else
122
- # cut off everything until !/ e.g.
123
- # at-austria!/w-wien/beers becomes
124
- # w-wien/beers
125
- name[ (pos+2)..-1 ]
126
- end
127
- end # method name_to_real_name
128
-
129
-
130
- end # class Reader
131
- end # module SportDb