Class: WorldDb::ZipReader
Instance Method Summary
collapse
-
#close ⇒ Object
-
#create_city_reader(name, more_attribs = {}) ⇒ Object
-
#create_country_reader(name, more_attribs = {}) ⇒ Object
-
#create_county_reader(name, more_attribs = {}) ⇒ Object
-
#create_fixture_reader(name) ⇒ Object
-
#create_hash_reader(name) ⇒ Object
-
#create_lang_reader(name) ⇒ Object
-
#create_line_reader(name) ⇒ Object
-
#create_muni_reader(name, more_attribs = {}) ⇒ Object
-
#create_part_reader(name, more_attribs = {}) ⇒ Object
-
#create_state_reader(name, more_attribs = {}) ⇒ Object
-
#create_tree_reader(name, more_attribs = {}) ⇒ Object
-
#create_usage_reader(name) ⇒ Object
-
#create_values_reader(name, more_attribs = {}) ⇒ Object
-
#initialize(name, include_path, opts = {}) ⇒ ZipReader
constructor
A new instance of ZipReader.
Methods inherited from ReaderBase
#load, #load_codes, #load_continent_defs, #load_continent_refs, #load_setup, #load_states_xxx, #skip_tags?, #strict?
#is_state?, #match_city, #match_country, #match_metro, #match_metro_flag, #match_metro_pop, #match_state_for_country, #match_supra, #match_supra_flag
Methods included from Matcher
#match_adm2_counties_for_country, #match_adm2_parts_for_country, #match_adm3_counties_for_country, #match_cities_for_country, #match_countries_for_continent, #match_states_abbr_for_country, #match_states_for_country, #match_states_iso_for_country, #match_states_nuts_for_country, #match_tree_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/worlddb/reader_zip.rb', line 8
def initialize( name, include_path, opts = {} )
super( 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/worlddb/reader_zip.rb', line 30
def close
@zip_file.close
end
|
#create_city_reader(name, more_attribs = {}) ⇒ Object
125
126
127
128
129
130
|
# File 'lib/worlddb/reader_zip.rb', line 125
def create_city_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (city) in zip '#{name}' (#{path})..."
CityReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_country_reader(name, more_attribs = {}) ⇒ Object
81
82
83
84
85
86
|
# File 'lib/worlddb/reader_zip.rb', line 81
def create_country_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (country) in zip '#{name}' (#{path})..."
CountryReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_county_reader(name, more_attribs = {}) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/worlddb/reader_zip.rb', line 102
def create_county_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (county) in zip '#{name}' (#{path})..."
CountyReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_fixture_reader(name) ⇒ Object
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
63
|
# File 'lib/worlddb/reader_zip.rb', line 37
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 (setup) in zip '#{name}' (#{path})..."
FixtureReader.from_zip( @zip_file, path )
end
|
#create_hash_reader(name) ⇒ Object
133
134
135
136
137
138
|
# File 'lib/worlddb/reader_zip.rb', line 133
def create_hash_reader( name )
path = name_to_zip_entry_path( name, '.yml' ) logger.info "parsing data (hash) in zip '#{name}' (#{path})..."
HashReader.from_zip( @zip_file, path )
end
|
#create_lang_reader(name) ⇒ Object
66
67
68
69
70
71
|
# File 'lib/worlddb/reader_zip.rb', line 66
def create_lang_reader( name )
path = name_to_zip_entry_path( name, '.yml' ) logger.info "parsing data (lang) in zip '#{name}' (#{path})..."
LangReader.from_zip( @zip_file, path )
end
|
#create_line_reader(name) ⇒ Object
147
148
149
150
151
152
|
# File 'lib/worlddb/reader_zip.rb', line 147
def create_line_reader( name )
path = name_to_zip_entry_path( name )
logger.info "parsing data (line) in zip '#{name}' (#{path})..."
LineReader.from_zip( @zip_file, path )
end
|
#create_muni_reader(name, more_attribs = {}) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/worlddb/reader_zip.rb', line 109
def create_muni_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (muni) in zip '#{name}' (#{path})..."
MuniReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_part_reader(name, more_attribs = {}) ⇒ Object
95
96
97
98
99
100
|
# File 'lib/worlddb/reader_zip.rb', line 95
def create_part_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (part) in zip '#{name}' (#{path})..."
PartReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_state_reader(name, more_attribs = {}) ⇒ Object
88
89
90
91
92
93
|
# File 'lib/worlddb/reader_zip.rb', line 88
def create_state_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (state) in zip '#{name}' (#{path})..."
StateReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_tree_reader(name, more_attribs = {}) ⇒ Object
117
118
119
120
121
122
|
# File 'lib/worlddb/reader_zip.rb', line 117
def create_tree_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (state tree) in zip '#{name}' (#{path})..."
StateTreeReader.from_zip( @zip_file, path, more_attribs )
end
|
#create_usage_reader(name) ⇒ Object
73
74
75
76
77
78
|
# File 'lib/worlddb/reader_zip.rb', line 73
def create_usage_reader( name )
path = name_to_zip_entry_path( name, '.yml' ) logger.info "parsing data (usage) in zip '#{name}' (#{path})..."
UsageReader.from_zip( @zip_file, path )
end
|
#create_values_reader(name, more_attribs = {}) ⇒ Object
140
141
142
143
144
145
|
# File 'lib/worlddb/reader_zip.rb', line 140
def create_values_reader( name, more_attribs={} )
path = name_to_zip_entry_path( name )
logger.info "parsing data (values) in zip '#{name}' (#{path})..."
ValuesReader.from_zip( @zip_file, path, more_attribs )
end
|