geonames_rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require 'geonames_rails/mappings/base'
2
2
  require 'geonames_rails/mappings/city'
3
3
  require 'geonames_rails/mappings/country'
4
+ require 'zip/zipfilesystem'
4
5
 
5
6
  module GeonamesRails
6
7
 
@@ -15,7 +16,7 @@ module GeonamesRails
15
16
  def load_data
16
17
  @puller.pull if @puller # pull geonames files down
17
18
 
18
- load_countries
19
+ #load_countries
19
20
 
20
21
  load_cities
21
22
 
@@ -47,8 +48,11 @@ module GeonamesRails
47
48
  def load_cities_file(city_file)
48
49
  log_message "Loading city file #{city_file}"
49
50
  cities = []
50
- File.open(File.join(Rails.root, 'tmp', "#{city_file}.txt"), 'r') do |f|
51
- f.each_line { |line| cities << Mappings::City.new(line) }
51
+
52
+ Zip::ZipFile.open(File.join(Rails.root, 'tmp', "#{city_file}.zip"), 'r') do |zipfile|
53
+ zipfile.each do |f|
54
+ zipfile.read(f).split(/\n/).each { |line| cities << Mappings::City.new(line) }
55
+ end
52
56
  end
53
57
 
54
58
  log_message "#{cities.length} cities to process"
@@ -19,10 +19,10 @@ module GeonamesRails
19
19
  @temp_geonames_files << target_file_name
20
20
 
21
21
  file_base_name, file_extension = file_name.split('.')
22
- if file_extension == 'zip'
23
- `unzip #{target_file_name} -d #{target_dir}`
24
- @temp_geonames_files << File.join(target_dir, "#{file_base_name}.txt")
25
- end
22
+ #if file_extension == 'zip'
23
+ # `unzip #{target_file_name} -d #{target_dir}`
24
+ # @temp_geonames_files << File.join(target_dir, "#{file_base_name}.txt")
25
+ #end
26
26
 
27
27
  end
28
28
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marius Andra
@@ -18,8 +18,33 @@ cert_chain: []
18
18
 
19
19
  date: 2012-02-18 00:00:00 +01:00
20
20
  default_executable:
21
- dependencies: []
22
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rubyzip
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rubyzip
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
23
48
  description: Fetch data from geonames.org and make the required models
24
49
  email: marius.andra@gmail.com
25
50
  executables: []