census_data 0.1.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,5 @@
1
+ require File.dirname(__FILE__) + "/lib/census_data.rb"
2
+ require 'csv'
3
+
4
+ CensusData.per_capita_income_by_zipcode(89506)
5
+
@@ -0,0 +1,37 @@
1
+ class CensusData
2
+
3
+ def self.per_capita_income_by_zipcode(zip_code)
4
+ county_name = ''
5
+ county_code = ''
6
+ median_income = ''
7
+
8
+ path = File.dirname(__FILE__) + '/data/county_names_by_zip.txt'
9
+ CSV.foreach(path, {:headers => true}) do |row|
10
+ if row[0] == zip_code.to_s
11
+ county_name = row[12].capitalize
12
+ break
13
+ end
14
+ end
15
+
16
+ path = File.dirname(__FILE__) + '/data/FipsCountyCodes.csv'
17
+ CSV.foreach(path, {:headers => true}) do |row|
18
+ county_to_match = row[1].split(", ")[1]
19
+ if county_name == county_to_match
20
+ county_code = row[0]
21
+ break
22
+ end
23
+ end
24
+
25
+ path = File.dirname(__FILE__) + '/data/IncomeDataSet.txt'
26
+ CSV.foreach(path, {:headers => true}) do |row|
27
+ if row[0] == county_code
28
+ median_income = row[32]
29
+ break
30
+ end
31
+ end
32
+
33
+ print "#{county_name} County, County Code #{county_code}, Median Income: #{median_income}"
34
+
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: census_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Flores
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: typhoeus
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.0
30
+ description: Ruby gem/plugin to pull census data based on zip code and dislpay the
31
+ median income for that area. Checkout the project on github for more detail.
32
+ email: mark@gbdev.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - Rakefile
40
+ - census_data.gemspec
41
+ - data/.DS_Store
42
+ - data/DataDict.txt
43
+ - data/FipsCountyCodes.csv
44
+ - data/IncomeDataSet.txt
45
+ - data/ZBP_YR_TOTALS.txt
46
+ - data/assignment.txt
47
+ - data/county_names_by_zip.txt
48
+ - examples/pull_data_by_zipcode.rb
49
+ - lib/census_data.rb
50
+ homepage: https://github.com/markjflores/census_data
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project: Project on www.github.com
70
+ rubygems_version: 1.8.24
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Ruby gem/plugin to pull census data based on zip code and dislpay the median
74
+ income for that area.
75
+ test_files: []