us_zipcode 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/MIT-LICENSE +0 -0
- data/README.textile +11 -11
- data/README.textile~ +10 -15
- data/Rakefile +0 -0
- data/features/step_definitions/common_steps.rb +0 -0
- data/features/step_definitions/rails_setup_steps.rb +0 -0
- data/features/step_definitions/rails_setup_steps.rb~ +0 -0
- data/features/support/env.rb +0 -0
- data/features/support/string.rb +0 -0
- data/features/zipcodes.feature +0 -0
- data/features/zipcodes.feature~ +0 -0
- data/lib/generators/us_zipcode/models_generator.rb +0 -0
- data/lib/generators/us_zipcode/models_generator.rb~ +0 -0
- data/lib/generators/us_zipcode/templates/county_model.rb +0 -0
- data/lib/generators/us_zipcode/templates/county_model.rb~ +0 -0
- data/lib/generators/us_zipcode/templates/migration.rb +0 -0
- data/lib/generators/us_zipcode/templates/migration.rb~ +0 -0
- data/lib/generators/us_zipcode/templates/state_model.rb +0 -0
- data/lib/generators/us_zipcode/templates/state_model.rb~ +0 -0
- data/lib/generators/us_zipcode/templates/zipcode_model.rb +0 -0
- data/lib/generators/us_zipcode/templates/zipcode_model.rb~ +0 -0
- data/lib/generators/us_zipcode/templates/zipcodes.rake +3 -3
- data/lib/generators/us_zipcode/templates/zipcodes.rake~ +0 -0
- data/lib/generators/us_zipcode/version.rb +1 -1
- data/lib/generators/us_zipcode/version.rb~ +1 -1
- data/lib/my_zipcode_gem.rb~ +0 -0
- data/lib/us_zipcode.rb +0 -0
- data/lib/us_zipcode.rb~ +0 -0
- data/rails3_2.gemfile +0 -0
- data/rails4_0.gemfile +0 -0
- data/rails4_1.gemfile +0 -0
- data/us_zipcode.gemspec +1 -0
- data/us_zipcode.gemspec~ +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d5b3db9d3124a738bceec1ff186d5655ba40d4a
|
4
|
+
data.tar.gz: 5ad8ef0c55e232e85dc906d24c7dda7ffca3dddc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36239e14e6966dfb3d9c366972cb702391ffb3f503953c770fd3590fa26ce36a7b785c350637131bdb4e4514777ae445575b061829dc5578f9fb21cfc235e58b
|
7
|
+
data.tar.gz: 0cc64e5c975e57ba05d69096b10882984797dea0af6d63310d55791ff350b8f580dce8f3ecc1a46fdd2bc6f88e7deaf7762962ee58664d4d627e1e667ee925db
|
data/.gitignore
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/MIT-LICENSE
CHANGED
File without changes
|
data/README.textile
CHANGED
@@ -11,7 +11,7 @@ bc. gem 'us_zipcode'
|
|
11
11
|
|
12
12
|
Run:
|
13
13
|
|
14
|
-
bc.
|
14
|
+
bc. bundle install
|
15
15
|
|
16
16
|
Generate the models and populate the data:
|
17
17
|
|
@@ -52,7 +52,7 @@ On city selection, you can see the corresponding county with its zip code.
|
|
52
52
|
|
53
53
|
Write the following code in your view:
|
54
54
|
|
55
|
-
<%= select_tag "state",options_from_collection_for_select(State.all, "id", "name") %>
|
55
|
+
bc. <%= select_tag "state",options_from_collection_for_select(State.all, "id", "name") %>
|
56
56
|
<div id ="city"></div>
|
57
57
|
<div id ="county"></div>
|
58
58
|
<script>
|
@@ -69,11 +69,11 @@ Write the following code in your view:
|
|
69
69
|
|
70
70
|
Create mycontroller & paste the following code:
|
71
71
|
|
72
|
-
|
72
|
+
bc. def get_cities_by_state
|
73
73
|
@cities = Zipcode.group(:city).where(state_id: params[:state_id])
|
74
74
|
end
|
75
75
|
|
76
|
-
def get_county_and_zip_by_city
|
76
|
+
bc. def get_county_and_zip_by_city
|
77
77
|
@zipcodes = Zipcode.find_by_city(params[:city])
|
78
78
|
end
|
79
79
|
|
@@ -81,10 +81,10 @@ Create the following two js.erb files in app/views/mycontroller/
|
|
81
81
|
|
82
82
|
1.get_cities_by_state.js.erb & paste the following code:
|
83
83
|
|
84
|
-
$("#city").html('<%= escape_javascript(select_tag "city", options_from_collection_for_select(@cities, :id, :city)) %>');
|
84
|
+
bc. $("#city").html('<%= escape_javascript(select_tag "city", options_from_collection_for_select(@cities, :id, :city)) %>');
|
85
85
|
$("#city").on("change", function(){
|
86
86
|
$.ajax({
|
87
|
-
url: "/
|
87
|
+
url: "/mycontroller/get_county_and_zip_by_city",
|
88
88
|
dataType: "script",
|
89
89
|
method: "get",
|
90
90
|
data: {city: $("#city select option:selected"). text()}
|
@@ -93,14 +93,14 @@ $("#city").on("change", function(){
|
|
93
93
|
|
94
94
|
2.get_county_and_zip_by_city.js.erb
|
95
95
|
|
96
|
-
$("#county").html('<%= escape_javascript(select_tag "county", options_from_collection_for_select(@zipcodes, :id, :county_and_zip)) %>');
|
96
|
+
bc. $("#county").html('<%= escape_javascript(select_tag "county", options_from_collection_for_select(@zipcodes, :id, :county_and_zip)) %>');
|
97
97
|
|
98
98
|
In the last update your routes:
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
bc. scope '/mycontroller' do
|
101
|
+
get 'get_cities_by_state' => 'mycontroller#get_cities_by_state'
|
102
|
+
get 'get_county_and_zip_by_city' => 'mycontroller#get_county_and_zip_by_city'
|
103
|
+
end
|
104
104
|
|
105
105
|
|
106
106
|
|
data/README.textile~
CHANGED
@@ -52,7 +52,7 @@ On city selection, you can see the corresponding county with its zip code.
|
|
52
52
|
|
53
53
|
Write the following code in your view:
|
54
54
|
|
55
|
-
<%= select_tag "state",options_from_collection_for_select(State.all, "id", "name") %>
|
55
|
+
bc. <%= select_tag "state",options_from_collection_for_select(State.all, "id", "name") %>
|
56
56
|
<div id ="city"></div>
|
57
57
|
<div id ="county"></div>
|
58
58
|
<script>
|
@@ -69,11 +69,11 @@ Write the following code in your view:
|
|
69
69
|
|
70
70
|
Create mycontroller & paste the following code:
|
71
71
|
|
72
|
-
|
72
|
+
bc. def get_cities_by_state
|
73
73
|
@cities = Zipcode.group(:city).where(state_id: params[:state_id])
|
74
74
|
end
|
75
75
|
|
76
|
-
def get_county_and_zip_by_city
|
76
|
+
bc. def get_county_and_zip_by_city
|
77
77
|
@zipcodes = Zipcode.find_by_city(params[:city])
|
78
78
|
end
|
79
79
|
|
@@ -81,10 +81,10 @@ Create the following two js.erb files in app/views/mycontroller/
|
|
81
81
|
|
82
82
|
1.get_cities_by_state.js.erb & paste the following code:
|
83
83
|
|
84
|
-
$("#city").html('<%= escape_javascript(select_tag "city", options_from_collection_for_select(@cities, :id, :city)) %>');
|
84
|
+
bc. $("#city").html('<%= escape_javascript(select_tag "city", options_from_collection_for_select(@cities, :id, :city)) %>');
|
85
85
|
$("#city").on("change", function(){
|
86
86
|
$.ajax({
|
87
|
-
url: "/
|
87
|
+
url: "/mycontroller/get_county_and_zip_by_city",
|
88
88
|
dataType: "script",
|
89
89
|
method: "get",
|
90
90
|
data: {city: $("#city select option:selected"). text()}
|
@@ -93,14 +93,14 @@ $("#city").on("change", function(){
|
|
93
93
|
|
94
94
|
2.get_county_and_zip_by_city.js.erb
|
95
95
|
|
96
|
-
$("#county").html('<%= escape_javascript(select_tag "county", options_from_collection_for_select(@zipcodes, :id, :county_and_zip)) %>');
|
96
|
+
bc. $("#county").html('<%= escape_javascript(select_tag "county", options_from_collection_for_select(@zipcodes, :id, :county_and_zip)) %>');
|
97
97
|
|
98
98
|
In the last update your routes:
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
bc. scope '/mycontroller' do
|
101
|
+
get 'get_cities_by_state' => 'mycontroller#get_cities_by_state'
|
102
|
+
get 'get_county_and_zip_by_city' => 'mycontroller#get_county_and_zip_by_city'
|
103
|
+
end
|
104
104
|
|
105
105
|
|
106
106
|
|
@@ -177,8 +177,3 @@ That's about it.
|
|
177
177
|
|
178
178
|
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.
|
179
179
|
|
180
|
-
h2. LOG
|
181
|
-
|
182
|
-
h3. 05/03/2011:
|
183
|
-
|
184
|
-
Initial Release
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/features/support/env.rb
CHANGED
File without changes
|
data/features/support/string.rb
CHANGED
File without changes
|
data/features/zipcodes.feature
CHANGED
File without changes
|
data/features/zipcodes.feature~
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,7 +5,7 @@ namespace :zipcodes do
|
|
5
5
|
desc "Update states table"
|
6
6
|
task :update_states => :environment do
|
7
7
|
puts ">>> Begin update of states table..."
|
8
|
-
url = "https://github.com/
|
8
|
+
url = "https://github.com/ChakreshwarSharma/us_zipcode_data/raw/master/all_us_states.csv"
|
9
9
|
data = open(url)
|
10
10
|
file = nil
|
11
11
|
if data.is_a? StringIO
|
@@ -28,7 +28,7 @@ namespace :zipcodes do
|
|
28
28
|
desc "Update counties table"
|
29
29
|
task :update_counties => :update_states do
|
30
30
|
puts ">>> Begin update of counties table..."
|
31
|
-
url = "https://github.com/
|
31
|
+
url = "https://github.com/ChakreshwarSharma/us_zipcode_data/raw/master/all_us_counties.csv"
|
32
32
|
data = open(url)
|
33
33
|
file = nil
|
34
34
|
if data.is_a? StringIO
|
@@ -53,7 +53,7 @@ namespace :zipcodes do
|
|
53
53
|
desc "Update zipcodes table"
|
54
54
|
task :update_zipcodes => :update_counties do
|
55
55
|
puts ">>> Begin update of zipcodes table..."
|
56
|
-
url = "https://github.com/
|
56
|
+
url = "https://github.com/ChakreshwarSharma/us_zipcode_data/raw/master/all_us_zipcodes.csv"
|
57
57
|
data = open(url)
|
58
58
|
file = nil
|
59
59
|
if data.is_a? StringIO
|
File without changes
|
data/lib/my_zipcode_gem.rb~
CHANGED
File without changes
|
data/lib/us_zipcode.rb
CHANGED
File without changes
|
data/lib/us_zipcode.rb~
CHANGED
File without changes
|
data/rails3_2.gemfile
CHANGED
File without changes
|
data/rails4_0.gemfile
CHANGED
File without changes
|
data/rails4_1.gemfile
CHANGED
File without changes
|
data/us_zipcode.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Chakreshwar"]
|
10
10
|
s.email = ["chakreshwar.sharma@yahoo.com"]
|
11
|
+
s.homepage = "https://github.com/ChakreshwarSharma/us_zipcode"
|
11
12
|
s.summary = %q{A Ruby gem to handle all things zipcode.}
|
12
13
|
s.description = %q{A Ruby gem for looking up and manipulating US postal codes and geocodes.}
|
13
14
|
s.licenses = ['MIT']
|
data/us_zipcode.gemspec~
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: us_zipcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chakreshwar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- rails4_1.gemfile
|
82
82
|
- us_zipcode.gemspec
|
83
83
|
- us_zipcode.gemspec~
|
84
|
-
homepage:
|
84
|
+
homepage: https://github.com/ChakreshwarSharma/us_zipcode
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata: {}
|