Class: SportDb::ZipReader
Constant Summary
Constants included
from Model
Model::City, Model::Continent, Model::Country, Model::Person, Model::Prop, Model::Region
Instance Method Summary
collapse
-
#close ⇒ Object
-
#create_assoc_reader(name) ⇒ Object
-
#create_club_squad_reader(name, more_attribs = {}) ⇒ Object
-
#create_event_reader(name, more_attribs = {}) ⇒ Object
-
#create_fixture_reader(name) ⇒ Object
-
#create_game_reader(name, more_attribs = {}) ⇒ Object
-
#create_ground_reader(name, more_attribs = {}) ⇒ Object
-
#create_league_reader(name, more_attribs = {}) ⇒ Object
-
#create_national_team_squad_reader(name, more_attribs = {}) ⇒ Object
-
#create_person_reader(name, more_attribs = {}) ⇒ Object
-
#create_season_reader(name) ⇒ Object
-
#create_team_reader(name, more_attribs = {}) ⇒ Object
-
#initialize(name, include_path, opts = {}) ⇒ ZipReader
constructor
A new instance of ZipReader.
Methods inherited from ReaderBase
#load, #load_setup
Methods included from Matcher
#match_clubs_for_country, #match_leagues_for_country, #match_players_for_country, #match_stadiums_for_country, #match_teams_for_country
Constructor Details
#initialize(name, include_path, opts = {}) ⇒ ZipReader
Returns a new instance of ZipReader.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/sportdb/reader_zip.rb', line 8
def initialize( name, include_path, opts = {} )
path = "#{include_path}/#{name}.zip"
@zip_file = Zip::File.open( path )
@zip_prefix = ''
end
|
Instance Method Details
#close ⇒ Object
30
31
32
33
|
# File 'lib/sportdb/reader_zip.rb', line 30
def close
@zip_file.close
end
|
#create_assoc_reader(name) ⇒ Object
85
86
87
88
89
90
|
# File 'lib/sportdb/reader_zip.rb', line 85
def create_assoc_reader( name )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (assoc) '#{name}' (#{path})..."
AssocReader.from_zip( @zip_file, path )
end
|
#create_club_squad_reader(name, more_attribs = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/sportdb/reader_zip.rb', line 64
def create_club_squad_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (club squad) '#{name}' (#{path})..."
ClubSquadReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_event_reader(name, more_attribs = {}) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/sportdb/reader_zip.rb', line 113
def create_event_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name, '.yml' )
logger.info "parsing data in zip (event) '#{name}' (#{path})..."
EventReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_fixture_reader(name) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/sportdb/reader_zip.rb', line 36
def create_fixture_reader( name )
query = "**/#{name}.txt"
candidates = @zip_file.glob( query )
pp candidates
path = candidates[0].name
logger.debug " zip entry path >>#{path}<<"
@zip_prefix = path[ 0...(path.size-(name.size+4)) ]
logger.debug " zip entry prefix >>#{@zip_prefix}<<"
logger.info "parsing data in zip '#{name}' (#{path})..."
FixtureReader.from_zip( @zip_file, path )
end
|
#create_game_reader(name, more_attribs = {}) ⇒ Object
120
121
122
123
124
125
126
|
# File 'lib/sportdb/reader_zip.rb', line 120
def create_game_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name, '.yml' )
logger.info "parsing data in zip (fixture) '#{name}' (#{path})..."
GameReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_ground_reader(name, more_attribs = {}) ⇒ Object
92
93
94
95
96
97
|
# File 'lib/sportdb/reader_zip.rb', line 92
def create_ground_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (ground) '#{name}' (#{path})..."
GroundReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_league_reader(name, more_attribs = {}) ⇒ Object
99
100
101
102
103
104
|
# File 'lib/sportdb/reader_zip.rb', line 99
def create_league_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (league) '#{name}' (#{path})..."
LeagueReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_national_team_squad_reader(name, more_attribs = {}) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/sportdb/reader_zip.rb', line 71
def create_national_team_squad_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (national team squad) '#{name}' (#{path})..."
NationalTeamSquadReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_person_reader(name, more_attribs = {}) ⇒ Object
129
130
131
132
133
|
# File 'lib/sportdb/reader_zip.rb', line 129
def create_person_reader( name, more_attribs={} )
end
|
#create_season_reader(name) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/sportdb/reader_zip.rb', line 78
def create_season_reader( name )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (season) '#{name}' (#{path})..."
SeasonReader.from_zip( @zip_file, path )
end
|
#create_team_reader(name, more_attribs = {}) ⇒ Object
106
107
108
109
110
111
|
# File 'lib/sportdb/reader_zip.rb', line 106
def create_team_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data in zip (team) '#{name}' (#{path})..."
TeamReader.from_zip( @zip_file, path, more_attribs )
end
|