zip-code-info 0.1.1 → 0.2.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4584059d06a9ffd5a033b335cd2763111fc6df91
4
+ data.tar.gz: c78f58062045e3bce11c79b9ef35f53afe6fa3d7
5
+ SHA512:
6
+ metadata.gz: 58d9cf5b41b39f8e8b46c07c37fefdc83ff9c73e09a8c86cda099bf4f8165418ad846c363f65b585a874622327c06d5bad952eda502b411c7437e502f069a890
7
+ data.tar.gz: 138584d7f2a72108f702e89529b25d3222e0263842a5d91e317c1050e33a87b82c3cc8022fd1e79eb37f981b6f992ba1ccf2540f2874d9014b0bf3ddf996d710
data/Gemfile CHANGED
@@ -1,14 +1,8 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
3
  group :development do
9
- gem "bundler", "~> 1.0.0"
10
- gem "jeweler", "~> 1.5.2"
11
- gem "rspec", "~> 2.3.0"
12
- gem "rcov", ">= 0"
4
+ gem "bundler"
5
+ gem "jeweler", "~> 2.0.1"
6
+ gem "rspec", "~> 3.2.0"
13
7
  gem "nokogiri"
14
8
  end
@@ -1,30 +1,71 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
4
+ addressable (2.3.8)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.2.5)
9
+ faraday (0.9.1)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.2.9.1)
12
+ github_api (0.12.3)
13
+ addressable (~> 2.3)
14
+ descendants_tracker (~> 0.0.4)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 3.3)
17
+ multi_json (>= 1.7.5, < 2.0)
18
+ nokogiri (~> 1.6.3)
19
+ oauth2
20
+ hashie (3.4.1)
21
+ highline (1.7.2)
22
+ jeweler (2.0.1)
23
+ builder
24
+ bundler (>= 1.0)
8
25
  git (>= 1.2.5)
26
+ github_api
27
+ highline (>= 1.6.15)
28
+ nokogiri (>= 1.5.10)
9
29
  rake
10
- nokogiri (1.4.4)
11
- rake (0.8.7)
12
- rcov (0.9.9)
13
- rspec (2.3.0)
14
- rspec-core (~> 2.3.0)
15
- rspec-expectations (~> 2.3.0)
16
- rspec-mocks (~> 2.3.0)
17
- rspec-core (2.3.1)
18
- rspec-expectations (2.3.0)
19
- diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.3.0)
30
+ rdoc
31
+ json (1.8.2)
32
+ jwt (1.4.1)
33
+ mini_portile (0.6.2)
34
+ multi_json (1.11.0)
35
+ multi_xml (0.5.5)
36
+ multipart-post (2.0.0)
37
+ nokogiri (1.6.6.2)
38
+ mini_portile (~> 0.6.0)
39
+ oauth2 (1.0.0)
40
+ faraday (>= 0.8, < 0.10)
41
+ jwt (~> 1.0)
42
+ multi_json (~> 1.3)
43
+ multi_xml (~> 0.5)
44
+ rack (~> 1.2)
45
+ rack (1.6.0)
46
+ rake (10.4.2)
47
+ rdoc (4.2.0)
48
+ json (~> 1.4)
49
+ rspec (3.2.0)
50
+ rspec-core (~> 3.2.0)
51
+ rspec-expectations (~> 3.2.0)
52
+ rspec-mocks (~> 3.2.0)
53
+ rspec-core (3.2.3)
54
+ rspec-support (~> 3.2.0)
55
+ rspec-expectations (3.2.1)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.2.0)
58
+ rspec-mocks (3.2.1)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.2.0)
61
+ rspec-support (3.2.2)
62
+ thread_safe (0.3.5)
21
63
 
22
64
  PLATFORMS
23
65
  ruby
24
66
 
25
67
  DEPENDENCIES
26
- bundler (~> 1.0.0)
27
- jeweler (~> 1.5.2)
68
+ bundler
69
+ jeweler (~> 2.0.1)
28
70
  nokogiri
29
- rcov
30
- rspec (~> 2.3.0)
71
+ rspec (~> 3.2.0)
data/README.md CHANGED
@@ -12,16 +12,18 @@ In your Gemfile
12
12
 
13
13
  The code runs out of a Singleton class. Right now you can call these two methods.
14
14
 
15
- ZipCodeInfo.instance.state_for "99163"
16
- #=> WA
15
+ ```ruby
16
+ ZipCodeInfo.instance.state_for '99163'
17
+ #=> WA
18
+ ```
17
19
 
18
- ZipCodeInfo.instance.scf_city_for "99163"
19
- #=> Spokane
20
+ ```ruby
21
+ ZipCodeInfo.instance.scf_city_for '99163'
22
+ #=> Spokane
23
+ ```
20
24
 
21
25
  ### Limitations
22
26
 
23
27
  * The city returned is the city where the USPS Sectional Center Facility (SCF) is located.
24
28
  * Sometimes the state that a zip code is bound to for USPS is different from the actual state the zip code is in. There are plans to provide both states.
25
29
 
26
-
27
-
data/Rakefile CHANGED
@@ -39,7 +39,7 @@ end
39
39
 
40
40
  task :default => :spec
41
41
 
42
- require 'rake/rdoctask'
42
+ require 'rdoc/task'
43
43
  Rake::RDocTask.new do |rdoc|
44
44
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -2,37 +2,35 @@ require 'yaml'
2
2
  require 'singleton'
3
3
 
4
4
  class ZipCodeInfo
5
- include Singleton
6
-
5
+ include Singleton
6
+
7
7
  attr_reader :code
8
-
8
+
9
9
  def initialize
10
10
  @data = YAML.load(File.open(File.join(File.dirname(__FILE__), '..', 'data', 'data.yml')))
11
- end
12
-
13
- def scf_city_for(code = "")
11
+ end
12
+
13
+ def scf_city_for(code = '')
14
14
  return false unless assign_and_validate_code(code)
15
15
  @data[code_to_key][:city]
16
16
  end
17
-
18
- def state_for(code = "")
17
+
18
+ def state_for(code = '')
19
19
  return false unless assign_and_validate_code(code)
20
20
  @data[code_to_key][:state]
21
21
  end
22
22
 
23
-
23
+
24
24
  private
25
-
25
+
26
26
  def assign_and_validate_code(code)
27
27
  @code = code.to_s
28
- return @code.match(/^[0-9]{5}$/i) && @data.has_key?(code_to_key)
28
+ return @code.match(/^\d{5}(-\d{4})?$/i) && @data.has_key?(code_to_key)
29
29
  end
30
-
30
+
31
31
  # To look up information we only need the first three digits of the zip code
32
32
  def code_to_key
33
33
  @code[0..2]
34
34
  end
35
-
35
+ end
36
36
 
37
-
38
- end
@@ -1,65 +1,58 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require_relative 'spec_helper'
2
2
 
3
- describe "ZipCodeInfo" do
4
-
5
- describe "Positive Test Cases: " do
6
-
7
- it "should find the right city" do
8
- zip = ZipCodeInfo.instance.scf_city_for "99100"
9
- zip.should eql "Spokane"
10
- end
11
-
12
- it "should find the right state" do
13
- zip = ZipCodeInfo.instance.state_for "99100"
14
- zip.should eql "WA"
15
- end
16
-
17
- it "should find the right city when the zip is an integer" do
18
- zip = ZipCodeInfo.instance.scf_city_for 60699
19
- ZipCodeInfo.instance.code.should eql "60699"
20
- zip.should eql "Chicago"
3
+ describe 'ZipCodeInfo' do
4
+
5
+ describe '#scf_city_for' do
6
+
7
+ it 'allows zip code as string' do
8
+ city = ZipCodeInfo.instance.scf_city_for '99100'
9
+ expect(city).to eql 'Spokane'
21
10
  end
22
-
23
- it "should find the right state when the zip is an integer" do
24
- zip = ZipCodeInfo.instance.state_for 60699
25
- ZipCodeInfo.instance.code.should eql "60699"
26
- zip.should eql "IL"
11
+
12
+ it 'allows zip code as integer' do
13
+ city = ZipCodeInfo.instance.scf_city_for 99100
14
+ expect(city).to eql 'Spokane'
27
15
  end
28
-
29
- it "should find the right city name when the city name contains an &" do
30
- zip = ZipCodeInfo.instance.scf_city_for "11099"
31
- zip.should eql "Queens &West Nassau"
16
+
17
+
18
+ it 'handles city names with &' do
19
+ city = ZipCodeInfo.instance.scf_city_for '11099'
20
+ expect(city).to eql 'Queens &West Nassau'
32
21
  end
33
-
34
- end
35
-
36
- describe "Negative Test Cases: " do
37
-
38
- it "should handle no zip code" do
39
- zip = ZipCodeInfo.instance.scf_city_for
40
- zip.should be_false
22
+
23
+ it 'handles extended zip codes' do
24
+ city = ZipCodeInfo.instance.scf_city_for '99100-1234'
25
+ expect(city).to eql 'Spokane'
41
26
  end
42
27
 
43
- it "should handle an invalid zip code that has a valid format - 00000" do
44
- zip = ZipCodeInfo.instance.scf_city_for("00000")
45
- zip.should be_false
28
+ it 'returns false if zip code is missing' do
29
+ city = ZipCodeInfo.instance.scf_city_for
30
+ expect(city).to be false
46
31
  end
47
-
48
- it "should handle an invalid zip code - too long" do
49
- zip = ZipCodeInfo.instance.scf_city_for("123456")
50
- zip.should be_false
32
+
33
+ it 'returns false if zip code not found' do
34
+ city = ZipCodeInfo.instance.scf_city_for '00000'
35
+ expect(city).to be false
51
36
  end
52
-
53
- it "should handle an invalid zip code - too short" do
54
- zip = ZipCodeInfo.instance.scf_city_for "1234"
55
- zip.should be_false
37
+
38
+ it 'returns false if zip code is invalid' do
39
+ city = ZipCodeInfo.instance.scf_city_for('123456')
40
+ expect(city).to be false
56
41
  end
57
-
58
- it "should handle an invalid zip code - alphanum" do
59
- zip = ZipCodeInfo.instance.scf_city_for "1a23g"
60
- zip.should be_false
42
+ end
43
+
44
+ describe '#state_for' do
45
+
46
+ it 'allows zip code as string' do
47
+ state = ZipCodeInfo.instance.state_for '60699'
48
+ expect(state).to eql 'IL'
61
49
  end
62
50
 
51
+ it 'allows zip code as integer' do
52
+ state = ZipCodeInfo.instance.state_for 60699
53
+ expect(state).to eql 'IL'
54
+ end
63
55
  end
64
-
56
+
65
57
  end
58
+
@@ -2,16 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: zip-code-info 0.2.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{zip-code-info}
8
- s.version = "0.1.1"
8
+ s.name = "zip-code-info"
9
+ s.version = "0.2.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Monica Olinescu"]
12
- s.date = %q{2012-10-10}
13
- s.description = %q{The data has been collected from wikipedia and stored in a yml file. This gem does not use an external service.}
14
- s.email = %q{monica.olinescu@gmail.com}
14
+ s.date = "2015-05-05"
15
+ s.description = "The data has been collected from wikipedia and stored in a yml file. This gem does not use an external service."
16
+ s.email = "monica.olinescu@gmail.com"
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE.txt",
17
19
  "README.md"
@@ -32,37 +34,29 @@ Gem::Specification.new do |s|
32
34
  "spec/zip-code-info_spec.rb",
33
35
  "zip-code-info.gemspec"
34
36
  ]
35
- s.homepage = %q{http://github.com/monicao/zip-code-info}
37
+ s.homepage = "http://github.com/monicao/zip-code-info"
36
38
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.6.2}
39
- s.summary = %q{Looks up the state and city of the Sectional Center Facility for a given zip code.}
40
- s.test_files = [
41
- "spec/spec_helper.rb",
42
- "spec/zip-code-info_spec.rb"
43
- ]
39
+ s.rubygems_version = "2.2.2"
40
+ s.summary = "Looks up the state and city of the Sectional Center Facility for a given zip code."
44
41
 
45
42
  if s.respond_to? :specification_version then
46
- s.specification_version = 3
43
+ s.specification_version = 4
47
44
 
48
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
51
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
52
- s.add_development_dependency(%q<rcov>, [">= 0"])
46
+ s.add_development_dependency(%q<bundler>, [">= 0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
48
+ s.add_development_dependency(%q<rspec>, ["~> 3.2.0"])
53
49
  s.add_development_dependency(%q<nokogiri>, [">= 0"])
54
50
  else
55
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
57
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
58
- s.add_dependency(%q<rcov>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, [">= 0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
53
+ s.add_dependency(%q<rspec>, ["~> 3.2.0"])
59
54
  s.add_dependency(%q<nokogiri>, [">= 0"])
60
55
  end
61
56
  else
62
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
65
- s.add_dependency(%q<rcov>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, [">= 0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
59
+ s.add_dependency(%q<rspec>, ["~> 3.2.0"])
66
60
  s.add_dependency(%q<nokogiri>, [">= 0"])
67
61
  end
68
62
  end
metadata CHANGED
@@ -1,111 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: zip-code-info
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Monica Olinescu
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-10-10 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :development
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
34
- version: 1.0.0
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
35
14
  name: bundler
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- prerelease: false
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
39
20
  type: :development
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 1
48
- - 5
49
- - 2
50
- version: 1.5.2
51
- name: jeweler
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
55
34
  type: :development
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 2
64
- - 3
65
- - 0
66
- version: 2.3.0
67
- name: rspec
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.0
71
48
  type: :development
72
- requirement: &id004 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- name: rcov
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
49
  prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
85
62
  type: :development
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
89
66
  - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
95
- name: nokogiri
96
- version_requirements: *id005
97
- description: The data has been collected from wikipedia and stored in a yml file. This gem does not use an external service.
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: The data has been collected from wikipedia and stored in a yml file.
70
+ This gem does not use an external service.
98
71
  email: monica.olinescu@gmail.com
99
72
  executables: []
100
-
101
73
  extensions: []
102
-
103
- extra_rdoc_files:
74
+ extra_rdoc_files:
104
75
  - LICENSE.txt
105
76
  - README.md
106
- files:
107
- - .document
108
- - .rspec
77
+ files:
78
+ - ".document"
79
+ - ".rspec"
109
80
  - Gemfile
110
81
  - Gemfile.lock
111
82
  - LICENSE.txt
@@ -118,40 +89,29 @@ files:
118
89
  - spec/spec_helper.rb
119
90
  - spec/zip-code-info_spec.rb
120
91
  - zip-code-info.gemspec
121
- has_rdoc: true
122
92
  homepage: http://github.com/monicao/zip-code-info
123
- licenses:
93
+ licenses:
124
94
  - MIT
95
+ metadata: {}
125
96
  post_install_message:
126
97
  rdoc_options: []
127
-
128
- require_paths:
98
+ require_paths:
129
99
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
133
102
  - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: 3
136
- segments:
137
- - 0
138
- version: "0"
139
- required_rubygems_version: !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
142
107
  - - ">="
143
- - !ruby/object:Gem::Version
144
- hash: 3
145
- segments:
146
- - 0
147
- version: "0"
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
148
110
  requirements: []
149
-
150
111
  rubyforge_project:
151
- rubygems_version: 1.6.2
112
+ rubygems_version: 2.2.2
152
113
  signing_key:
153
- specification_version: 3
154
- summary: Looks up the state and city of the Sectional Center Facility for a given zip code.
155
- test_files:
156
- - spec/spec_helper.rb
157
- - spec/zip-code-info_spec.rb
114
+ specification_version: 4
115
+ summary: Looks up the state and city of the Sectional Center Facility for a given
116
+ zip code.
117
+ test_files: []