my_zipcode_gem 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,6 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- tmp/*
5
+ tmp/*
6
+ vendor/bundle
7
+ lib/generators/generators
data/README.textile CHANGED
@@ -7,17 +7,17 @@ h2. Installation
7
7
  Add the following line to your Gemfile:
8
8
 
9
9
  bc. gem 'my_zipcode_gem'
10
-
10
+
11
11
  Run:
12
12
 
13
13
  bc. rake bundle install
14
-
14
+
15
15
  Generate the models and populate the data:
16
16
 
17
17
  bc. rails g my_zipcode_gem:models
18
18
  rake db:migrate
19
19
  rake zipcodes:update
20
-
20
+
21
21
  You should now have three new tables and three new models, Zipcode, State, County.
22
22
 
23
23
  h2. Usage
@@ -29,7 +29,7 @@ zipcode.county.name # => 'Johnson'
29
29
  zipcode.lat.to_s # => '38.959356', it is actually a BigDecimal object converted to_s for documentation.
30
30
  zipcode.lon.to_s # => '-94.716155', ditto
31
31
  zipcode.is_geocoded? # => true, most if not all should be pre-geocoded.
32
-
32
+
33
33
  You can also look for a zipcode from a city and state:
34
34
 
35
35
  bc. Zipcode.find_by_city_state "Shawnee Mission", "KS"
@@ -45,7 +45,7 @@ county = state.counties.first
45
45
  county.cities.count # => 5
46
46
  county.cities # gives you a sorted array of all cities for the county
47
47
  county.zipcodes.count # => 5
48
-
48
+
49
49
  h3. Automatic JQuery/AJAX lookup
50
50
 
51
51
  You can have a user enter a zipcode and automatically lookup their city, state and county.
@@ -115,7 +115,7 @@ And define a route for the AJAX function in routes.rb:
115
115
 
116
116
  bc. get 'mycontrollername/get_zip_data/:code', :controller => 'mycontrollername', :action => 'get_zip_data'
117
117
 
118
- That's about it.
118
+ That's about it.
119
119
 
120
120
  Let me know if there are any errors. I cut and pasted the code above from a working application, but there may be some gotchas that I missed.
121
121
 
@@ -123,4 +123,4 @@ h2. LOG
123
123
 
124
124
  h3. 05/03/2011:
125
125
 
126
- Initial Release
126
+ Initial Release
@@ -9,8 +9,8 @@ end
9
9
  Given %{a new migrated Rails app} do
10
10
  # Don't delete the rails app
11
11
  FileUtils.mkdir_p("tmp")
12
- system("rails new tmp/rails_app").should be_true
13
- system("ln -s ../../../lib/generators tmp/rails_app/lib/generators").should be_true
12
+ system("rails new tmp/rails_app -f").should be_true
13
+ system("ln -sf ../../../lib/generators tmp/rails_app/lib/generators").should be_true
14
14
  @current_directory = File.expand_path("tmp/rails_app")
15
15
  When %{I run "rails g my_zipcode_gem:models"}
16
16
  Then %{I should successfully run "rake db:migrate"}
@@ -1,5 +1,5 @@
1
1
  require 'open-uri'
2
- require 'fastercsv'
2
+ require 'csv'
3
3
  namespace :zipcodes do
4
4
 
5
5
  desc "Update states table"
@@ -16,7 +16,7 @@ namespace :zipcodes do
16
16
  else
17
17
  file = data
18
18
  end
19
- FasterCSV.foreach(file.path, :headers => true) do |row|
19
+ CSV.foreach(file.path, :headers => true) do |row|
20
20
  puts "Updating state: [#{row['name']}]"
21
21
  state = State.find_or_initialize_by_abbr(row['abbr'])
22
22
  state.update_attribute(:name, row['name'])
@@ -39,7 +39,7 @@ namespace :zipcodes do
39
39
  else
40
40
  file = data
41
41
  end
42
- FasterCSV.foreach(file.path, :headers => true) do |row|
42
+ CSV.foreach(file.path, :headers => true) do |row|
43
43
  puts "Updating county: [#{row['name']}]"
44
44
  # lookup state
45
45
  state = State.find_by_abbr!(row['state'])
@@ -64,7 +64,7 @@ namespace :zipcodes do
64
64
  else
65
65
  file = data
66
66
  end
67
- FasterCSV.foreach(file.path, :headers => true) do |row|
67
+ CSV.foreach(file.path, :headers => true) do |row|
68
68
  puts "Updating zipcode: [#{row['code']}], '#{row['city']}, #{row['state']}, #{row['county']}"
69
69
  # lookup state
70
70
  state = State.find_by_abbr!(row['state'])
@@ -96,7 +96,7 @@ namespace :zipcodes do
96
96
  desc "Export US States to a .csv file"
97
97
  task :export_states => :environment do
98
98
  @states = State.order("name ASC")
99
- csv_string = FasterCSV.generate do |csv|
99
+ csv_string = CSV.generate do |csv|
100
100
  csv << ["abbr", "name"]
101
101
  @states.each do |state|
102
102
  csv << [
@@ -114,7 +114,7 @@ namespace :zipcodes do
114
114
  desc "Export all US Counties to a .csv file"
115
115
  task :export_counties => :environment do
116
116
  @counties = County.order("name ASC")
117
- csv_string = FasterCSV.generate do |csv|
117
+ csv_string = CSV.generate do |csv|
118
118
  csv << ["name", "state", "county_seat"]
119
119
  @counties.each do |county|
120
120
  csv << [
@@ -133,7 +133,7 @@ namespace :zipcodes do
133
133
  desc "Export the zipcodes with county and state data"
134
134
  task :export_zipcodes => :environment do
135
135
  @zipcodes = Zipcode.order("code ASC")
136
- csv_string = FasterCSV.generate do |csv|
136
+ csv_string = CSV.generate do |csv|
137
137
  csv << ["code", "city", "state", "county", "area_code", "lat", "lon"]
138
138
  @zipcodes.each do |zip|
139
139
  csv << [
@@ -1,3 +1,3 @@
1
1
  module MyZipcodeGem
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency('rails', '>= 3.0.0')
23
23
  s.add_dependency('rubigen', '1.5.6')
24
- s.add_dependency('fastercsv')
25
24
 
26
25
  s.add_development_dependency('sqlite3-ruby')
27
26
  s.add_development_dependency('shoulda', '2.11.3')
metadata CHANGED
@@ -1,165 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: my_zipcode_gem
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Blackburn
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-29 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 3.0.0
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rubigen
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
45
- hash: 15
46
- segments:
47
- - 1
48
- - 5
49
- - 6
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rubigen
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
50
37
  version: 1.5.6
51
38
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: fastercsv
55
39
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
65
- type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.6
46
+ - !ruby/object:Gem::Dependency
68
47
  name: sqlite3-ruby
69
- prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
79
54
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: shoulda
83
55
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - "="
88
- - !ruby/object:Gem::Version
89
- hash: 37
90
- segments:
91
- - 2
92
- - 11
93
- - 3
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: shoulda
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
94
69
  version: 2.11.3
95
70
  type: :development
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
71
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
101
- none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.11.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
109
86
  type: :development
110
- version_requirements: *id006
111
- - !ruby/object:Gem::Dependency
112
- name: rspec-rails
113
87
  prerelease: false
114
- requirement: &id007 !ruby/object:Gem::Requirement
115
- none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec-rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
123
102
  type: :development
124
- version_requirements: *id007
125
- - !ruby/object:Gem::Dependency
126
- name: cucumber
127
103
  prerelease: false
128
- requirement: &id008 !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: cucumber
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
137
118
  type: :development
138
- version_requirements: *id008
139
- - !ruby/object:Gem::Dependency
140
- name: cucumber-rails
141
119
  prerelease: false
142
- requirement: &id009 !ruby/object:Gem::Requirement
143
- none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: cucumber-rails
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
151
134
  type: :development
152
- version_requirements: *id009
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
153
142
  description: A Ruby gem for looking up and manipulating US postal codes and geocodes.
154
- email:
143
+ email:
155
144
  - chris [at] midwiretech [dot] com
156
145
  executables: []
157
-
158
146
  extensions: []
159
-
160
147
  extra_rdoc_files: []
161
-
162
- files:
148
+ files:
163
149
  - .gitignore
164
150
  - Gemfile
165
151
  - README.textile
@@ -178,41 +164,37 @@ files:
178
164
  - lib/generators/my_zipcode_gem/version.rb
179
165
  - lib/my_zipcode_gem.rb
180
166
  - my_zipcode_gem.gemspec
181
- has_rdoc: true
182
167
  homepage: https://github.com/midwire/my_zipcode_gem
183
168
  licenses: []
184
-
185
169
  post_install_message:
186
170
  rdoc_options: []
187
-
188
- require_paths:
171
+ require_paths:
189
172
  - lib
190
- required_ruby_version: !ruby/object:Gem::Requirement
173
+ required_ruby_version: !ruby/object:Gem::Requirement
191
174
  none: false
192
- requirements:
193
- - - ">="
194
- - !ruby/object:Gem::Version
195
- hash: 3
196
- segments:
175
+ requirements:
176
+ - - ! '>='
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ segments:
197
180
  - 0
198
- version: "0"
199
- required_rubygems_version: !ruby/object:Gem::Requirement
181
+ hash: 2335148937812189379
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
183
  none: false
201
- requirements:
202
- - - ">="
203
- - !ruby/object:Gem::Version
204
- hash: 3
205
- segments:
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ segments:
206
189
  - 0
207
- version: "0"
190
+ hash: 2335148937812189379
208
191
  requirements: []
209
-
210
192
  rubyforge_project: my_zipcode_gem
211
- rubygems_version: 1.5.3
193
+ rubygems_version: 1.8.24
212
194
  signing_key:
213
195
  specification_version: 3
214
196
  summary: A Ruby gem to handle all things zipcode.
215
- test_files:
197
+ test_files:
216
198
  - features/step_definitions/common_steps.rb
217
199
  - features/step_definitions/rails_setup_steps.rb
218
200
  - features/support/env.rb