geoinfo 0.0.3a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'geoinfo/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "geoinfo"
8
+ gem.version = Geoinfo::VERSION
9
+ gem.authors = ["Pravin Mishra"]
10
+ gem.email = ["diatm.pravin.it.07.27@gmail.com"]
11
+ gem.description = %q{find geo info}
12
+ gem.summary = %q{find geo info}
13
+ gem.homepage = "https://github.com/diatmpravin/geoinfo.git"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ end
@@ -0,0 +1,19 @@
1
+ if RUBY_VERSION.to_f >= 1.9 # ;_;
2
+ require 'csv'
3
+ else
4
+ require 'rubygems'
5
+ require 'faster_csv'
6
+ end
7
+
8
+ require 'geoinfo/string'
9
+ require "geoinfo/version"
10
+
11
+ module Geoinfo
12
+ zip_path = File.open(File.join(File.dirname(__FILE__), '..', 'data', 'india_zip_v.01.csv'))
13
+
14
+ if RUBY_VERSION.to_f >= 1.9
15
+ ZIP_CODES = CSV.read(zip_path)
16
+ else
17
+ ZIP_CODES = FasterCSV.parse(zip_path)
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ class String
2
+
3
+ def to_region(options = {})
4
+ Geoinfo::ZIP_CODES.each do |row|
5
+ if row.second == self.to_s
6
+ if options[:district]
7
+ @region = row[5]
8
+ elsif options[:state]
9
+ @region = row[3]
10
+ elsif options[:country]
11
+ @region = row[0]
12
+ elsif options[:lat]
13
+ @region = row[9]
14
+ elsif options[:log]
15
+ @region = row[10]
16
+ elsif options[:state_code]
17
+ @region = row[4]
18
+ else
19
+ @region = row[2]
20
+ end
21
+ end
22
+ end
23
+ @region || nil
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ module Geoinfo
2
+ VERSION = "0.0.3a"
3
+ end
@@ -0,0 +1 @@
1
+ require 'geoinfo'
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geoinfo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3a
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Pravin Mishra
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: find geo info
31
+ email:
32
+ - diatm.pravin.it.07.27@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - data/india_zip_v.01.csv
43
+ - geoinfo.gemspec
44
+ - lib/geoinfo.rb
45
+ - lib/geoinfo/string.rb
46
+ - lib/geoinfo/version.rb
47
+ - spec/spec_helper.rb
48
+ homepage: https://github.com/diatmpravin/geoinfo.git
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>'
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.1
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: find geo info
72
+ test_files:
73
+ - spec/spec_helper.rb