area 0.4.2 → 0.5.0

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.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  Rake::TestTask.new do |t|
7
7
  t.libs.push "lib"
8
8
  t.test_files = FileList['test/unit/*_test.rb']
9
- t.verbose = true
9
+ # t.verbose = true
10
10
  end
11
11
 
12
12
  task :default => :test
data/lib/area/array.rb CHANGED
@@ -15,8 +15,14 @@ class Array
15
15
  end
16
16
 
17
17
  def to_zip
18
+ lat = '%.3f' % self[0]
19
+ lon = '%.3f' % self[1]
20
+
18
21
  Area::ZIP_CODES.each do |row|
19
- if row[3] == self[0].to_s and row[4] == self[1].to_s
22
+ db_lat = '%.3f' % row[3].to_f
23
+ db_lon = '%.3f' % row[4].to_f
24
+
25
+ if db_lat.to_s == lat.to_s and db_lon.to_s == lon.to_s
20
26
  return row[0]
21
27
  end
22
28
  end
data/lib/area/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Area
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
data/readme.md CHANGED
@@ -22,7 +22,7 @@ Area uses public domain data and does not rely on any external services (the int
22
22
 
23
23
  In your gemfile: `gem 'area'`
24
24
 
25
- ## Usaage
25
+ ## Usage
26
26
 
27
27
  #### Convert an area code to a state/region
28
28
  ``` ruby
@@ -48,7 +48,6 @@ class TestString < MiniTest::Unit::TestCase
48
48
 
49
49
  def test_that_it_converts_city_state_to_zip_code
50
50
  assert_equal ["11101", "11109", "11120"], "long Island city, ny".to_zip
51
- assert_equal ["11101", "11109", "11120"], "san jose, ca".to_zip
52
51
  end
53
52
 
54
53
  def test_that_it_converts_to_offset
@@ -75,4 +74,8 @@ class TestArray < MiniTest::Unit::TestCase
75
74
  assert_equal "-5", [40.71209, -73.95427].to_gmt_offset
76
75
  end
77
76
 
77
+ def test_that_it_handles_latlon_precision
78
+ assert_equal "11211", [40.7120912345, -73.9542712345].to_zip
79
+ end
80
+
78
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: area
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastercsv