Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Move JSON out of project
Browse files Browse the repository at this point in the history
Massaged Maxmind data is available at the below path. Users must set the data
path before use.

`City.data_path = '/path/to/dir'`

https://s3-us-west-2.amazonaws.com/cities-gem/cities.tar.gz
  • Loading branch information
joecorcoran committed Oct 29, 2013
1 parent 103706d commit 3b67f82
Show file tree
Hide file tree
Showing 239 changed files with 22 additions and 240 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ pkg
#*.rbc
.ruby-gemset
.ruby-version
data/
2 changes: 1 addition & 1 deletion cities.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ txt
s.add_development_dependency 'countries', '~> 0.9.3'
s.add_development_dependency 'rake'

s.files = Dir['lib/**/*.{rb,json}'] + ['README.md', 'LICENSE.txt']
s.files = Dir['lib/**/*.rb'] + ['README.md', 'LICENSE.txt']
s.require_path = 'lib'
end
3 changes: 3 additions & 0 deletions lib/cities.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
require 'cities/city'
require 'cities/country'

module Cities
end
19 changes: 14 additions & 5 deletions lib/cities/city.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ def region

class << self

def path_for_country(code)
File.join(File.dirname(__FILE__), '..', 'data', 'cities', "#{code}.json")
end
attr_accessor :data_path

def cities_in_country?(code)
File.exist?(self.path_for_country(code))
File.exist?(path_for_country(code))
end

def cities_in_country(code)
Expand All @@ -60,6 +58,17 @@ def cities_in_country(code)
end
end

private

def has_data?
data_path && Dir.exists?(data_path)
end

def path_for_country(code)
raise unless has_data?
File.join(data_path, "#{code}.json")
end

end

end
1 change: 0 additions & 1 deletion lib/data/cities/AD.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AE.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AF.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AG.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AI.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AL.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AM.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AN.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AO.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AR.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AT.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/data/cities/AU.json

This file was deleted.

Loading

0 comments on commit 3b67f82

Please sign in to comment.