census_api 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -0
- data/README.md +64 -61
- data/Rakefile +9 -1
- data/census_api.gemspec +5 -2
- data/lib/census_api/client.rb +1 -1
- data/lib/census_api/request.rb +24 -14
- data/lib/census_api/version.rb +1 -1
- data/lib/{yml → data}/census_shapes.yml +95 -4
- data/lib/data/geography.json +1569 -0
- data/spec/census_api/client_spec.rb +2 -0
- data/spec/census_api/examples_spec.rb +26 -0
- data/spec/census_api/request_spec.rb +7 -17
- data/spec/spec_helper.rb +33 -4
- data/spec/support/data/census_2010_dec_sf1.rb +351 -0
- data/spec/support/data/census_2012_acs_acs1.rb +61 -0
- data/spec/support/data/census_2015_acs_acs5.rb +191 -0
- data/spec/support/examples.rb +65 -0
- data/spec/vcr_setup.rb +1 -0
- metadata +63 -15
- data/spec/api_key.sample.rb +0 -1
- data/spec/census_api/example_spec.rb +0 -37
- data/spec/support/census_examples.rb +0 -84
data/spec/api_key.sample.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
RSPEC_API_KEY = 'abc123'
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'CensusApi::Examples', :vcr do
|
4
|
-
let(:client) { CensusApi::Client.new(api_key) }
|
5
|
-
|
6
|
-
describe 'sf1' do
|
7
|
-
before(:each) do
|
8
|
-
client.dataset = 'sf1'
|
9
|
-
end
|
10
|
-
describe '#where' do
|
11
|
-
CensusExamples::SF1.each do |query|
|
12
|
-
it "should retrieve #{query.join(",")}" do
|
13
|
-
response = client.send(:where, {fields: query[0], level: query[1], within: query[2]})
|
14
|
-
expect{ response }.not_to raise_error
|
15
|
-
expect(response).to be_a(Array)
|
16
|
-
expect(response.first).to include('name')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'acs5' do
|
23
|
-
before(:each) do
|
24
|
-
client.dataset = 'acs5'
|
25
|
-
end
|
26
|
-
describe '#where' do
|
27
|
-
CensusExamples::ACS5.each do |query|
|
28
|
-
it "should retrieve #{query.join(",")}" do
|
29
|
-
response = client.send(:where, {fields: query[0], level: query[1], within: query[2]})
|
30
|
-
expect{ response }.not_to raise_error
|
31
|
-
expect(response).to be_a(Array)
|
32
|
-
expect(response.first).to include('name')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
module CensusExamples
|
2
|
-
SF1 = [
|
3
|
-
['P0010001', 'STATE'],
|
4
|
-
['P0010001', 'STATE:06'],
|
5
|
-
['P0010001', 'STATE:02,06'],
|
6
|
-
['P0010001', 'COUNTY'],
|
7
|
-
['P0010001', 'COUNTY', 'STATE:06'],
|
8
|
-
['P0010001', 'COUNTY:001', 'STATE:06'],
|
9
|
-
['P0010001', 'COUSUB', 'STATE:02+COUNTY:290'],
|
10
|
-
['P0010001', 'COUSUB:86690', 'STATE:02+COUNTY:290'],
|
11
|
-
['P0010001', 'SUBMCD', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
12
|
-
['P0010001', 'SUBMCD:02350', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
13
|
-
['P0010001', 'TABBLOCK', 'STATE:02+COUNTY:290+TRACT:00100'],
|
14
|
-
['P0010001', 'SUBMCD:02350', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
15
|
-
['P0010001', 'TRACT', 'STATE:02+COUNTY:170'],
|
16
|
-
['P0010001', 'TRACT:000101', 'STATE:02+COUNTY:170'],
|
17
|
-
['P0010001', 'BG', 'STATE:02+COUNTY:170+TRACT:000101'],
|
18
|
-
['P0010001', 'BG:1', 'STATE:02+COUNTY:170+TRACT:000101'],
|
19
|
-
['P0010001', 'PLACE'],
|
20
|
-
['P0010001', 'PLACE', 'STATE:06'],
|
21
|
-
['P0010001', 'PLACE:00135', 'STATE:06'],
|
22
|
-
['P0010001', 'ANRC'],
|
23
|
-
['P0010001', 'ANRC', 'STATE:02'],
|
24
|
-
['P0010001', 'ANRC:00590', 'STATE:02'],
|
25
|
-
['P0010001', 'AIANNH'],
|
26
|
-
['P0010001', 'AIANNH', 'STATE:02'],
|
27
|
-
['P0010001', 'AIANNH:03800', 'STATE:02'],
|
28
|
-
['P0010001', 'AITS', 'STATE:40+AIANNH:13735'],
|
29
|
-
['P0010001', 'AITS:83127', 'STATE:40+AIANNH:13735'],
|
30
|
-
['P0010001', 'CBSA', 'STATE:02'],
|
31
|
-
['P0010001', 'CBSA:11260', 'STATE:02'],
|
32
|
-
['P0010001', 'METDIV', 'STATE:06+CBSA:31100'],
|
33
|
-
['P0010001', 'METDIV', 'STATE:06+CBSA:31100'],
|
34
|
-
['P0010001', 'METDIV:31084', 'STATE:06+CBSA:31100'],
|
35
|
-
['P0010001', 'CSA', 'STATE:24'],
|
36
|
-
['P0010001', 'CSA:428', 'STATE:24'],
|
37
|
-
['P0010001', 'CD', 'STATE:24'],
|
38
|
-
['P0010001', 'CD:01', 'STATE:24'],
|
39
|
-
['P0010001', 'COUNTY', 'STATE:24+CD:01'],
|
40
|
-
['P0010001', 'COUNTY:003', 'STATE:24+CD:01'],
|
41
|
-
['P0010001', 'TRACT', 'STATE:24+CD:01+COUNTY:003'],
|
42
|
-
['P0010001', 'TRACT:702100', 'STATE:24+CD:01+COUNTY:003'],
|
43
|
-
['P0010001', 'COUSUB', 'STATE:24+CD:01+COUNTY:003'],
|
44
|
-
['P0010001', 'COUSUB:90100', 'STATE:24+CD:01+COUNTY:003'],
|
45
|
-
['P0010001', 'PLACE', 'STATE:24+CD:01'],
|
46
|
-
['P0010001', 'PLACE:00125', 'STATE:24+CD:01'],
|
47
|
-
['P0010001', 'AIANNH', 'STATE:02+CD:00'],
|
48
|
-
['P0010001', 'AIANNH:03800', 'STATE:02+CD:00'],
|
49
|
-
['P0010001', 'AIANNH', 'STATE:02+CD:00'],
|
50
|
-
['P0010001', 'SLDU', 'STATE:02'],
|
51
|
-
['P0010001', 'SLDU:00A', 'STATE:02'],
|
52
|
-
['P0010001', 'SLDL', 'STATE:02'],
|
53
|
-
['P0010001', 'SLDL:001', 'STATE:02'],
|
54
|
-
['P0010001', 'ZCTA5', 'STATE:02'],
|
55
|
-
['P0010001', 'ZCTA5:99501', 'STATE:02']
|
56
|
-
]
|
57
|
-
ACS5 = [
|
58
|
-
['B00001_001E', 'STATE'],
|
59
|
-
['B00001_001E', 'STATE:06'],
|
60
|
-
['B00001_001E', 'STATE:06,02'],
|
61
|
-
['B00001_001E', 'COUNTY'],
|
62
|
-
['B00001_001E', 'COUNTY', 'STATE:06'],
|
63
|
-
['B00001_001E', 'COUNTY:001', 'STATE:06'],
|
64
|
-
['B00001_001E', 'COUSUB', 'STATE:02+COUNTY:290'],
|
65
|
-
['B00001_001E', 'COUSUB:86690', 'STATE:02+COUNTY:290'],
|
66
|
-
['B00001_001E', 'SUBMCD', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
67
|
-
['B00001_001E', 'SUBMCD:02350', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
68
|
-
['B00001_001E', 'PLACE', 'STATE:02+COUNTY:290+COUSUB:86690'],
|
69
|
-
['B00001_001E', 'PLACE:05750', 'STATE:02+COUNTY:290+COUSUB:86690'],
|
70
|
-
['B00001_001E', 'TRACT', 'STATE:02+COUNTY:290+COUSUB:86690+PLACE:05750'],
|
71
|
-
['B00001_001E', 'TRACT:000100', 'STATE:02+COUNTY:290+COUSUB:86690+PLACE:05750'],
|
72
|
-
['B00001_001E', 'TRACT', 'STATE:02+COUNTY:170'],
|
73
|
-
['B00001_001E', 'TRACT:000101', 'STATE:02+COUNTY:170'],
|
74
|
-
['B00001_001E', 'BG', 'STATE:02+COUNTY:170+TRACT:000101'],
|
75
|
-
['B00001_001E', 'BG:1', 'STATE:02+COUNTY:170+TRACT:000101'],
|
76
|
-
['B00001_001E', 'PLACE'],
|
77
|
-
['B00001_001E', 'PLACE', 'STATE:06'],
|
78
|
-
['B00001_001E', 'PLACE:00135', 'STATE:06'],
|
79
|
-
['B00001_001E', 'AIANNH'],
|
80
|
-
['B00001_001E', 'AIANNH', 'STATE:02'],
|
81
|
-
['B00001_001E', 'CD', 'STATE:24'],
|
82
|
-
['B00001_001E', 'CD:01', 'STATE:24']
|
83
|
-
]
|
84
|
-
end
|