free_zipcode_data 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dfe97e5c2963d4c40da211303f3f3c31ad9b29253c70c3d3f2ff303d92d51c9a
4
+ data.tar.gz: 38744e59531dcaf6dbc710a8343c7b97f72b3e35f4c48d73f499eacdfee6ea2b
5
+ SHA512:
6
+ metadata.gz: a65a8d0bfcece72ef8e8a93bb654f0c50436de7d3639f1fefca845f8e3a1082aba1ae0597be269967715eb2ebcc01090a5f714cb7ec10b141c9c041bdde9349a
7
+ data.tar.gz: 0611b47e763d063e84029de8022fda6f2ffd2bceeb6f2ff8a6f04499a5d8814a700bd8b6b14520a627338947ff5aa171b20703d59a9afc7ab5d673b7949d2588
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ /.bundle
2
+ /free_zipcode_data.sqlite3
3
+ /data
4
+ /build
5
+ /stubs
6
+ /vendor/bundle/
7
+ /pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,88 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
4
+ # Include gemspec and Rakefile
5
+ Include:
6
+ - '**/*.gemspec'
7
+ - '**/*.podspec'
8
+ - '**/*.jbuilder'
9
+ - '**/*.rake'
10
+ - '**/Gemfile'
11
+ - '**/Rakefile'
12
+ - '**/Capfile'
13
+ - '**/Guardfile'
14
+ - '**/Podfile'
15
+ - '**/Thorfile'
16
+ - '**/Vagrantfile'
17
+ Exclude:
18
+ - 'vendor/**/*'
19
+ - 'stubs/**/*'
20
+ - 'spec/support/shared_contexts/*'
21
+
22
+ # Checks formatting of special comments
23
+ CommentAnnotation:
24
+ Keywords:
25
+ - TODO
26
+ - FIXME
27
+ - OPTIMIZE
28
+ - HACK
29
+ - REVIEW
30
+
31
+ ########################################
32
+ # Style Cops
33
+
34
+ Style/ClassVars:
35
+ Enabled: false
36
+
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ Style/FileName:
41
+ Enabled: false
42
+
43
+ Style/AlignParameters:
44
+ EnforcedStyle: with_fixed_indentation
45
+
46
+ Style/RegexpLiteral:
47
+ Enabled: false
48
+
49
+ Style/EmptyLinesAroundBlockBody:
50
+ Enabled: false
51
+
52
+ Style/RaiseArgs:
53
+ Enabled: false
54
+
55
+ Style/DoubleNegation:
56
+ Enabled: false
57
+
58
+ Style/PerlBackrefs:
59
+ Enabled: false
60
+
61
+ ########################################
62
+ # Lint Cops
63
+
64
+ Lint/Eval:
65
+ Enabled: false
66
+
67
+ Lint/HandleExceptions:
68
+ Enabled: false
69
+
70
+ ########################################
71
+ # Metrics Cops
72
+
73
+ Metrics/LineLength:
74
+ Max: 110
75
+
76
+ Metrics/MethodLength:
77
+ CountComments: false # count full line comments?
78
+ Max: 30
79
+
80
+ Metrics/ClassLength:
81
+ Max: 120
82
+
83
+ Metrics/AbcSize:
84
+ Enabled: false
85
+
86
+ # rubocop:disable Metrics/AbcSize
87
+ # rubocop:disable Metrics/MethodLength
88
+ # rubocop:disable Metrics/BlockLength
data/CHANGELOG ADDED
@@ -0,0 +1,42 @@
1
+ *1.0.1* (April 23, 2018)
2
+
3
+ * Made it a gem with a command line executable bin/free_zipcode_data
4
+ * Use Kiba for ETL
5
+ * Support user switches for various options including custom table names and generating .csv files
6
+ * Use in-memory SQLite database to create the tables, then save it as a file on disk
7
+ * Separate concerns for each table
8
+ * Add a progressbar with ETA
9
+ * Fix a bug when looking up state_id
10
+ * Add a ‘name’ index on states table
11
+ * Add a switch to generate individual .csv files [--generate-files]
12
+ * Add a switch to overwrite [--clobber] downloaded and generated .csv files
13
+
14
+ ### Previous History
15
+
16
+ ### 10/28/2017:
17
+
18
+ * Removed old .csv files
19
+ * Add template files (CODE_OF_CONDUCT.md, CONTRIBUTING.md, ISSUE_TEMPLATE.md, LICENSE.md, PULL_REQUEST_TEMPLATE.md)
20
+ * Use new data provider - [GeoNames](http://www.geonames.org)
21
+ * Test USA
22
+ * Started to test `allCountries.zip` but it takes too long. Let me know if there are any bugs.
23
+ * Create `country_lookup_table.yml` for country code lookups
24
+
25
+ ### 05/04/2011:
26
+
27
+ * Removed un-assigned zipcodes, which were not valid for today
28
+ * Added a Rakefile and some rake tasks to facilitate building a SQLite relational database for the three tables (states, counties, zipcodes)
29
+ * Zipcodes without an associated county == 0
30
+ * Counties without a zipcode == 1 (PISCATAGUIS, Maine)
31
+
32
+ ### 01/24/2011:
33
+
34
+ * 670 orphaned zipcodes without an associated county
35
+ * 1 county without any zipcodes (PISCATAGUIS, Maine)
36
+
37
+ ### 01/13/2011:
38
+
39
+ At last check there were ...
40
+
41
+ * 897 orphaned zipcodes without an associated county
42
+ * 1 county without any zipcodes (PISCATAGUIS, Maine)
@@ -0,0 +1,42 @@
1
+ # Free Zipcode Data Code of Conduct
2
+
3
+ The Free Zipcode Data project strongly values contributors from anywhere, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, age, religion, or nationality. As a result, the Free Zipcode Data team has agreed to and enforces this code of conduct in order to provide a harassment-free experience for everyone who participates in the development of Free Zipcode Data.
4
+
5
+ ### Summary
6
+
7
+ Just Be Nice!!!
8
+
9
+ Harassment in code and discussion or violation of physical boundaries is completely unacceptable anywhere in the Free Zipcode Data codebase, issue trackers, chat rooms, mailing lists, meetups, and any other events. Violators will be warned and then blocked or banned by the core team at or before the 3rd violation.
10
+
11
+ ### In Detail
12
+
13
+ Harassment includes offensive verbal comments related to level of experience, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, age, religion, nationality, the use of sexualized language or imagery, deliberate intimidation, stalking, sustained disruption, and unwelcome sexual attention.
14
+
15
+ Individuals asked to stop any harassing behavior are expected to comply immediately.
16
+
17
+ Maintainers, including the core team, are also subject to the anti-harassment policy.
18
+
19
+ If anyone engages in abusive, harassing, or otherwise unacceptable behavior, including maintainers, we may take appropriate action, up to and including warning the offender, deletion of comments, removal from the project’s codebase and communication systems, and escalation to GitHub support.
20
+
21
+ If you are being harassed, notice that someone else is being harassed, or have any other concerns, please contact [Chris Blackburn](mailto:87a1779b@opayq.com).
22
+
23
+ We expect everyone to follow these rules anywhere in the Free Zipcode Data codebase, issue trackers, IRC channel, group chat, and mailing lists.
24
+
25
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
26
+
27
+ Finally, don't forget that it is human to make mistakes! We all do. Let’s work together to help each other, resolve issues, and learn from the mistakes that we will all inevitably make from time to time.
28
+
29
+ ### Thanks
30
+
31
+ Thanks to the [JSConf Code of Conduct](http://jsconf.com/codeofconduct.html) and [Fedora Code of Conduct](http://fedoraproject.org/code-of-conduct) for inspiration and ideas.
32
+
33
+ ### License
34
+
35
+ <p class="license" xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
36
+ To the extent possible under law, <a rel="dct:publisher" href="https://github.com/midwire/free_zipcode_data">The Free Zipcode Data Team</a> has waived all copyright and related or neighboring rights to the <span property="dct:title">Free Zipcode Data Code of Conduct</span>. This work is published from the <span property="vcard:Country" datatype="dct:ISO3166" content="US" about="https://github.com/midwire/free_zipcode_data">United States.</span>
37
+ <br>
38
+ <br>
39
+ <a rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/">
40
+ <img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0">
41
+ </a>
42
+ </p>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,25 @@
1
+ ## How to contribute to free_zipcode_data
2
+
3
+ #### **Did you find a bug?**
4
+
5
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/midwire/free_zipcode_data/issues).
6
+
7
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/midwire/free_zipcode_data/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
8
+
9
+ #### **Did you write a patch that fixes a bug?**
10
+
11
+ * Open a new GitHub pull request with the patch.
12
+
13
+ * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
14
+
15
+ * Before submitting, please read run [Rubocop](http://batsov.com/rubocop/) on your code. If your PR fails our Rubocop convensions defined in `.rubocop.yml`, it will likely be rejected on those grounds.
16
+
17
+ * Ensure that you write RSpec tests that cover any new or modified code. PR's without spec coverage will likely be rejected.
18
+
19
+ #### **Did you fix whitespace, format code, or make a purely cosmetic patch?**
20
+
21
+ Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Free Zipcode Data will generally not be accepted.
22
+
23
+ Thanks for any contributions!
24
+
25
+ --Midwire
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ free_zipcode_data (1.0.1)
5
+ colored (~> 1.2)
6
+ kiba (~> 2.0)
7
+ ruby-progressbar (~> 1.9)
8
+ rubyzip (~> 1.2)
9
+ sqlite3 (~> 1.3)
10
+ trollop (~> 2.1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ ast (2.4.0)
16
+ coderay (1.1.2)
17
+ colored (1.2)
18
+ diff-lcs (1.3)
19
+ docile (1.3.0)
20
+ json (2.1.0)
21
+ kiba (2.0.0)
22
+ method_source (0.8.2)
23
+ parallel (1.12.1)
24
+ parser (2.5.1.0)
25
+ ast (~> 2.4.0)
26
+ powerpack (0.1.1)
27
+ pry (0.10.4)
28
+ coderay (~> 1.1.0)
29
+ method_source (~> 0.8.1)
30
+ slop (~> 3.4)
31
+ pry-nav (0.2.4)
32
+ pry (>= 0.9.10, < 0.11.0)
33
+ rainbow (3.0.0)
34
+ rake (12.2.1)
35
+ rspec (3.7.0)
36
+ rspec-core (~> 3.7.0)
37
+ rspec-expectations (~> 3.7.0)
38
+ rspec-mocks (~> 3.7.0)
39
+ rspec-core (3.7.1)
40
+ rspec-support (~> 3.7.0)
41
+ rspec-expectations (3.7.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.7.0)
44
+ rspec-mocks (3.7.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.7.0)
47
+ rspec-support (3.7.1)
48
+ rubocop (0.55.0)
49
+ parallel (~> 1.10)
50
+ parser (>= 2.5)
51
+ powerpack (~> 0.1)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ ruby-progressbar (~> 1.7)
54
+ unicode-display_width (~> 1.0, >= 1.0.1)
55
+ ruby-prof (0.17.0)
56
+ ruby-progressbar (1.9.0)
57
+ rubyzip (1.2.1)
58
+ simplecov (0.16.1)
59
+ docile (~> 1.1)
60
+ json (>= 1.8, < 3)
61
+ simplecov-html (~> 0.10.0)
62
+ simplecov-html (0.10.2)
63
+ slop (3.6.0)
64
+ sqlite3 (1.3.13)
65
+ trollop (2.1.2)
66
+ unicode-display_width (1.3.2)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler (~> 1.16)
73
+ free_zipcode_data!
74
+ pry-nav (~> 0.2)
75
+ rake (~> 12.0)
76
+ rspec (~> 3.7)
77
+ rubocop (~> 0.55)
78
+ ruby-prof (~> 0.17)
79
+ simplecov (~> 0.16)
80
+
81
+ BUNDLED WITH
82
+ 1.16.1
data/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,9 @@
1
+ ### Expected Behavior
2
+
3
+ ### Actual Behavior
4
+
5
+ ### Steps to reproduce the problem
6
+
7
+ ---
8
+ * Current Version:
9
+ * Operating System:
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ ## The MIT License (MIT)
2
+
3
+ ##### Copyright (c) 2017 Midwire Technologies, LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ **_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE._**
@@ -0,0 +1,5 @@
1
+ - [ ] I wrote specs to cover new or modified code in this PR
2
+ - [ ] I ran `rake spec` locally and ALL specs pass
3
+
4
+ Related Issue: # <please-add-issue-number-here>
5
+ Description: <please-add-a-comprehensive-description-of-fix/feature>
data/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # Free Zipcode Data
2
+
3
+ Zipcode data is free from the various governments around the world. Yet so many organizations, reputable or not, want to charge money for it.
4
+
5
+ This project is an automated solution for retrieving and collating US and worldwide zipcode data.
6
+
7
+ ## History
8
+
9
+ In 2011, we originally pulled down all the US census data we could find, parsed it and exported it into 3 .csv files. Later, we wrote 3 rake tasks to automate this process.
10
+
11
+ In 2017 we began using [GeoNames](http://www.geonames.org) data, which is licensed under Creative Commons. We are grateful to [GeoNames](http://www.geonames.org) for sharing, and urge you to [visit their site](http://www.geonames.org) and support their work.
12
+
13
+ In 2018 we refactored the project and made it into a Ruby gem with a command-line executable for automating this process.
14
+
15
+ ## What's Included
16
+
17
+ * An executable: `free_zipcode_data` - which automates the process of downloading and process the zipcode data from GeoNames. Not all countries are accounted for. Please check [GeoNames](http://download.geonames.org/export/zip/) to see a list of supported country zip files.
18
+
19
+ Each zipcode is correlated with estimated or zip-centroid, latitude and longitude coordinates. Where applicable, country, county/province, state and community are also correlated.
20
+
21
+ See the GeoNames [readme.txt](http://download.geonames.org/export/zip/readme.txt) file for more information.
22
+
23
+ ## Usage
24
+
25
+ First, you need to install Ruby and Rubygems. Though that is not a difficult task, it is beyond the scope of this README. A search engine of your choice will help discover how to do this. Once you have done that:
26
+
27
+ ```bash
28
+ $ gem install free_zipcode_data
29
+ ```
30
+
31
+ Determine the 2-letter country codes for the countries you want to use at [GeoNames](http://download.geonames.org/export/zip/), or don't specify a country to get all zipcodes for all available countries...
32
+
33
+ ### Command Line Options
34
+
35
+ ```bash
36
+ Options:
37
+ -w, --work-dir=<s> REQUIRED: Specify your work/build directory, where the SQLite and .csv files will be built
38
+ -f, --country=<s> Specify the country code for processing, or all countries if not specified
39
+ -g, --generate-files Generate CSV files: [counties.csv, states.csv, countries.csv, zipcodes.csv]
40
+ -o, --country-tablename=<s> Specify the name for the `countries` table (default: countries)
41
+ -s, --state-tablename=<s> Specify the name for the `states` table (default: states)
42
+ -u, --county-tablename=<s> Specify the name for the `counties` table (default: counties)
43
+ -z, --zipcode-tablename=<s> Specify the name for the `zipcodes` table (default: zipcodes)
44
+ -c, --clobber Overwrite existing files
45
+ -d, --dry-run Do not actually move or copy files
46
+ -v, --verbose Be verbose with output
47
+ -h, --help Show this message
48
+ ```
49
+
50
+ ### Examples
51
+
52
+ **Download and process all US zipcodes**:
53
+
54
+ ```bash
55
+ $ free_zipcode_data --work-dir /tmp/work_dir --country US --generate-files
56
+ ```
57
+
58
+ **Download and process zipcodes for all available countries**:
59
+
60
+ ```bash
61
+ $ free_zipcode_data --work-dir /tmp/work_dir --generate-files
62
+ ```
63
+
64
+ The rake tasks cascade, from the bottom up. So if you run `rake data:populate_db`, it will automatically call `rake data:build` if the .csv files are missing, which will call `rake data:download` if the .zip files are missing.
65
+
66
+ ## SQLite3 Database
67
+
68
+ The executable will generate an SQLite3 database in the specified directory `--work-dir` but it will not generate the `.csv` files by default. Specify `--generate-files` if you want those as well.
69
+
70
+ By default the tables will be named as follows. To override the table names see the command line options above.
71
+
72
+ ```sql
73
+ create table countries (
74
+ id integer not null primary key,
75
+ alpha2 varchar(2) not null,
76
+ alpha3 varchar(3),
77
+ iso varchar(3),
78
+ name varchar(255) not null
79
+ )
80
+
81
+ create table states (
82
+ id integer not null primary key,
83
+ country_id integer not null,
84
+ abbr varchar(2) not null,
85
+ name varchar(255)
86
+ )
87
+
88
+ create table counties (
89
+ id integer not null primary key,
90
+ state_id integer,
91
+ abbr varchar(255),
92
+ name varchar(255),
93
+ county_seat varchar(255)
94
+ )
95
+
96
+ create table zipcodes (
97
+ id integer not null primary key,
98
+ code varchar(10) not null,
99
+ state_id integer,
100
+ city varchar(255),
101
+ area_code varchar(3),
102
+ lat float,
103
+ lon float,
104
+ accuracy varchar(8)
105
+ )
106
+ ```
107
+
108
+ Both `lat` and `lon`, geocodes, are populated for each zipcode record.
109
+
110
+ ## Data License
111
+
112
+ The zipcode data is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>, carried forward from [GeoNames](http://www.geonames.org).<br />
113
+ <a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/88x31.png" /></a>
114
+
115
+ See [CHANGELOG](CHANGELOG) for more history and errata.