census_api 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/census_api/request.rb +5 -4
- data/lib/census_api/version.rb +1 -1
- data/lib/yml/census_shapes.yml +1 -0
- data/spec/support/census_examples.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c6080f79695746c9da16b9a6a39eaaeb8f8932d
|
4
|
+
data.tar.gz: bb8d0ce3088e0c78fc36beba6b8bed9b1b95a604
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde1d5a14e91651c1b29156fa4ddb23a9fc05c5206a2a42d9f28b7e2e968d38e0a7ec11bb696f619d6c6f3253f5956738d033e85fdae9103ce657d49f9b32889
|
7
|
+
data.tar.gz: 88a0931b9c90edde163cf67c6711e2b483ae0f5b951a9585e49912007c0a9ae002843f62e1aa9ac4c2c0b63f39a35a79a32b70f3cb9c58beba612b3197914d7f
|
data/lib/census_api/request.rb
CHANGED
@@ -20,10 +20,10 @@ module CensusApi
|
|
20
20
|
fields = options[:fields]
|
21
21
|
fields = fields.split(',').push('NAME').join(',') if fields.is_a? String
|
22
22
|
fields = fields.push('NAME').join(',') if fields.is_a? Array
|
23
|
-
level = format(options[:level], false)
|
23
|
+
level = format(options[:level], false, source)
|
24
24
|
params = { key: options[:key], get: fields, for: level }
|
25
25
|
unless (options[:within].nil? || (options[:within].is_a?(Array) && options[:within].compact.empty?))
|
26
|
-
params.merge!(in: format(options[:within][0], true))
|
26
|
+
params.merge!(in: format(options[:within][0], true, source))
|
27
27
|
end
|
28
28
|
options.merge!(vintage: 2010) unless options[:vintage]
|
29
29
|
request = new(options[:vintage], source, params)
|
@@ -61,11 +61,12 @@ module CensusApi
|
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
64
|
-
def self.format(str, truncate)
|
64
|
+
def self.format(str, truncate, source=nil)
|
65
65
|
result = str.split('+').map do |s|
|
66
66
|
s = s.match(':') ? s.split(':') : [s, '*']
|
67
67
|
shp = shapes[s[0].upcase]
|
68
|
-
|
68
|
+
name = shp[[source,'name'].compact.join("_")]||shp['name']
|
69
|
+
s.shift && s.unshift(name.downcase.gsub(' ', '+')) unless shp.nil?
|
69
70
|
s.unshift(s.shift.split('/')[0]) if !s[0].scan('home+land').empty? && truncate
|
70
71
|
s.join(':')
|
71
72
|
end
|
data/lib/census_api/version.rb
CHANGED
data/lib/yml/census_shapes.yml
CHANGED
@@ -63,8 +63,8 @@ module CensusExamples
|
|
63
63
|
['B00001_001E', 'COUNTY:001', 'STATE:06'],
|
64
64
|
['B00001_001E', 'COUSUB', 'STATE:02+COUNTY:290'],
|
65
65
|
['B00001_001E', 'COUSUB:86690', 'STATE:02+COUNTY:290'],
|
66
|
-
|
67
|
-
|
66
|
+
['B00001_001E', 'SUBMCD', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
67
|
+
['B00001_001E', 'SUBMCD:02350', 'STATE:72+COUNTY:127+COUSUB:79693'],
|
68
68
|
['B00001_001E', 'PLACE', 'STATE:02+COUNTY:290+COUSUB:86690'],
|
69
69
|
['B00001_001E', 'PLACE:05750', 'STATE:02+COUNTY:290+COUSUB:86690'],
|
70
70
|
['B00001_001E', 'TRACT', 'STATE:02+COUNTY:290+COUSUB:86690+PLACE:05750'],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: census_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Rauber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|