policymap_wrap 0.5.0 → 0.6.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.
- data/VERSION +1 -1
- data/lib/policymap_wrap/client.rb +43 -43
- metadata +8 -40
- data/spec/policymap_wrap_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -1,24 +1,24 @@
|
|
1
1
|
module PolicyMap
|
2
2
|
|
3
3
|
class Client
|
4
|
-
|
5
|
-
BOUNDARY_TYPES = { :state => 2, :county => 4, :city => 16, :zip => 8, :census_tract => 6,
|
6
|
-
:block_group => 15, :congressional_district => 23, :assembly_district => 48,
|
4
|
+
|
5
|
+
BOUNDARY_TYPES = { :state => 2, :county => 4, :city => 16, :zip => 8, :census_tract => 6,
|
6
|
+
:block_group => 15, :congressional_district => 23, :assembly_district => 48,
|
7
7
|
:senate_district => 49, :all => 'all' }
|
8
|
-
|
9
|
-
INDICATORS = { :total_population =>
|
10
|
-
:percent_pacific_islander =>
|
11
|
-
:percent_mixed_race =>
|
12
|
-
:percent_foreign_born => 9869060, :percent_disabled => 9869050, :percent_high_school_or_less =>
|
13
|
-
:percent_college_degree =>
|
14
|
-
:median_rent =>
|
15
|
-
:vacancy_rate =>
|
16
|
-
:percent_white =>
|
17
|
-
:percent_who_commute_to_work_using_public_transit =>
|
18
|
-
:independent_artists => 9618303, :performing_arts_and_spectator_sports => 9584608,
|
8
|
+
|
9
|
+
INDICATORS = { :total_population => 9876598, :percent_african_american => 9876222, :percent_asian => 9876202,
|
10
|
+
:percent_pacific_islander => 9876468, :percent_hispanic => 9876280, :percent_native_american => 9876623,
|
11
|
+
:percent_mixed_race => 9876437, :percent_under_18 => 9869063, :percent_65_or_older => 9869059,
|
12
|
+
:percent_foreign_born => 9869060, :percent_disabled => 9869050, :percent_high_school_or_less => 9873913,
|
13
|
+
:percent_college_degree => 9873916, :percent_graduate_degree => 9873904, :median_home_value => 9873606,
|
14
|
+
:median_rent => 9873661, :percent_moved_in_since_1990 => 9873776, :percent_homeowners => 9873049,
|
15
|
+
:vacancy_rate => 9876608, :median_household_income => 9871831, :poverty_rate => 9871807,
|
16
|
+
:percent_white => 9876415, :percent_households_wo_car => 0, :average_vehicles_per_household => 9873779,
|
17
|
+
:percent_who_commute_to_work_using_public_transit => 9873811, :unemployment_rate => 9841103,
|
18
|
+
:independent_artists => 9618303, :performing_arts_and_spectator_sports => 9584608,
|
19
19
|
:movie_and_sound_industries => 9584731, :mueseums_and_historical_sites => 9584676,
|
20
20
|
:publishing_industries => 9584638, :broadcasting => 9584691, :other_info_services => 9584624, :all => 'all' }
|
21
|
-
|
21
|
+
|
22
22
|
@@connection = nil
|
23
23
|
@@debug = false
|
24
24
|
@@default_options = nil
|
@@ -40,11 +40,11 @@ module PolicyMap
|
|
40
40
|
def debug
|
41
41
|
@@debug
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def boundary_types
|
45
45
|
BOUNDARY_TYPES
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def indicators
|
49
49
|
INDICATORS
|
50
50
|
end
|
@@ -52,52 +52,52 @@ module PolicyMap
|
|
52
52
|
def query_search(*args)
|
53
53
|
default_options = @@default_options
|
54
54
|
default_options[:t] = "sch"
|
55
|
-
|
55
|
+
|
56
56
|
options = extract_options!(args)
|
57
|
-
|
57
|
+
|
58
58
|
raise InsufficientArgsForSearch unless options.has_key?(:boundary_types) && options.has_key?(:query)
|
59
|
-
|
59
|
+
|
60
60
|
options[:boundary_types] = Array(options[:boundary_types]).collect {|bt| BOUNDARY_TYPES[bt] }.join(',')
|
61
61
|
HashUtils.rename_key!(options, :boundary_types, :bt)
|
62
62
|
HashUtils.rename_key!(options, :query, :s)
|
63
63
|
HashUtils.rename_key!(options, :state, :st) if options.has_key?(:state)
|
64
64
|
HashUtils.rename_key!(options, :county, :co) if options.has_key?(:county)
|
65
65
|
HashUtils.rename_key!(options, :census_tract, :ct) if options.has_key?(:census_tract)
|
66
|
-
|
66
|
+
|
67
67
|
options = default_options.merge(options)
|
68
|
-
|
68
|
+
|
69
69
|
result = get(Endpoint.endpoint_url, options)
|
70
70
|
result['sch'].collect {|hsh| HashUtils.symbolize_keys(hsh) }
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def boundary_search(*args)
|
74
74
|
default_options = @@default_options
|
75
75
|
default_options[:t] = "bnd"
|
76
|
-
|
76
|
+
|
77
77
|
options = extract_options!(args)
|
78
|
-
|
78
|
+
|
79
79
|
raise InsufficientArgsForSearch unless options.has_key?(:boundary_types) || options.has_key?(:boundary_ids)
|
80
|
-
|
80
|
+
|
81
81
|
options[:boundary_types] = Array(options[:boundary_types]).collect {|bt| BOUNDARY_TYPES[bt] }.join(',') if options.has_key?(:boundary_types)
|
82
82
|
options[:boundary_ids] = Array(options[:boundary_ids]).join(',') if options.has_key?(:boundary_ids)
|
83
83
|
HashUtils.rename_key!(options, :boundary_types, :bt) if options.has_key?(:boundary_types)
|
84
84
|
HashUtils.rename_key!(options, :boundary_ids, :bi) if options.has_key?(:boundary_ids)
|
85
85
|
HashUtils.rename_key!(options, :lng, :lon) if options.has_key?(:lng)
|
86
|
-
|
86
|
+
|
87
87
|
options = default_options.merge(options)
|
88
|
-
|
88
|
+
|
89
89
|
result = get(Endpoint.endpoint_url, options)
|
90
90
|
HashUtils.recursively_symbolize_keys(result["bnd"])
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def indicator_search(*args)
|
94
94
|
default_options = @@default_options
|
95
95
|
default_options[:t] = "ind"
|
96
|
-
|
96
|
+
|
97
97
|
options = extract_options!(args)
|
98
|
-
|
98
|
+
|
99
99
|
raise InsufficientArgsForSearch unless options.has_key?(:indicators) && (options.has_key?(:boundary_types) || options.has_key?(:boundary_ids))
|
100
|
-
|
100
|
+
|
101
101
|
options[:indicators] = Array(options[:indicators]).collect {|i| INDICATORS[i] }.join(',')
|
102
102
|
options[:boundary_types] = Array(options[:boundary_types]).collect {|bt| BOUNDARY_TYPES[bt] }.join(',') if options.has_key?(:boundary_types)
|
103
103
|
options[:boundary_ids] = Array(options[:boundary_ids]).join(',') if options.has_key?(:boundary_ids)
|
@@ -105,28 +105,28 @@ module PolicyMap
|
|
105
105
|
HashUtils.rename_key!(options, :boundary_types, :bt) if options.has_key?(:boundary_types)
|
106
106
|
HashUtils.rename_key!(options, :boundary_ids, :bi) if options.has_key?(:boundary_ids)
|
107
107
|
HashUtils.rename_key!(options, :lng, :lon) if options.has_key?(:lng)
|
108
|
-
|
108
|
+
|
109
109
|
options = default_options.merge(options)
|
110
|
-
|
110
|
+
|
111
111
|
result = get(Endpoint.endpoint_url, options)
|
112
112
|
HashUtils.recursively_symbolize_keys(result["ind"])
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def containment_search(*args)
|
116
116
|
default_options = @@default_options
|
117
117
|
default_options[:t] = "cnt"
|
118
|
-
|
118
|
+
|
119
119
|
options = extract_options!(args)
|
120
|
-
|
120
|
+
|
121
121
|
raise InsufficientArgsForSearch unless options.has_key?(:boundary_types) && options.has_key?(:boundary_id)
|
122
|
-
|
122
|
+
|
123
123
|
options[:boundary_types] = Array(options[:boundary_types]).collect {|bt| BOUNDARY_TYPES[bt] }.join(',')
|
124
124
|
HashUtils.rename_key!(options, :boundary_types, :cbt)
|
125
125
|
HashUtils.rename_key!(options, :boundary_id, :bi)
|
126
|
-
|
127
|
-
|
126
|
+
|
127
|
+
|
128
128
|
options = default_options.merge(options)
|
129
|
-
|
129
|
+
|
130
130
|
result = get(Endpoint.endpoint_url, options)
|
131
131
|
result['cnt'].first
|
132
132
|
end
|
@@ -135,9 +135,9 @@ module PolicyMap
|
|
135
135
|
raise NoConnectionEstablished if @@connection.nil?
|
136
136
|
@@connection.get endpoint, data
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
private
|
140
|
-
|
140
|
+
|
141
141
|
def extract_options!(args)
|
142
142
|
if args.last.is_a?(Hash)
|
143
143
|
return args.pop
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: policymap_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 0
|
10
|
-
version: 0.5.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.6.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Mauricio Gomes
|
@@ -15,8 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
13
|
+
date: 2011-12-14 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
16
|
name: yajl-ruby
|
@@ -26,11 +20,6 @@ dependencies:
|
|
26
20
|
requirements:
|
27
21
|
- - ">="
|
28
22
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 7
|
33
|
-
- 7
|
34
23
|
version: 0.7.7
|
35
24
|
type: :runtime
|
36
25
|
version_requirements: *id001
|
@@ -42,12 +31,6 @@ dependencies:
|
|
42
31
|
requirements:
|
43
32
|
- - ">="
|
44
33
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 105
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 7
|
49
|
-
- 7
|
50
|
-
- 1
|
51
34
|
version: 0.7.7.1
|
52
35
|
type: :runtime
|
53
36
|
version_requirements: *id002
|
@@ -59,11 +42,6 @@ dependencies:
|
|
59
42
|
requirements:
|
60
43
|
- - ">="
|
61
44
|
- !ruby/object:Gem::Version
|
62
|
-
hash: 13
|
63
|
-
segments:
|
64
|
-
- 1
|
65
|
-
- 2
|
66
|
-
- 9
|
67
45
|
version: 1.2.9
|
68
46
|
type: :development
|
69
47
|
version_requirements: *id003
|
@@ -86,15 +64,12 @@ files:
|
|
86
64
|
- lib/policymap_wrap/connection.rb
|
87
65
|
- lib/policymap_wrap/endpoint.rb
|
88
66
|
- lib/policymap_wrap/hash_utils.rb
|
89
|
-
- spec/policymap_wrap_spec.rb
|
90
|
-
- spec/spec_helper.rb
|
91
|
-
has_rdoc: true
|
92
67
|
homepage: http://github.com/geminisbs/policymap_wrap
|
93
68
|
licenses: []
|
94
69
|
|
95
70
|
post_install_message:
|
96
|
-
rdoc_options:
|
97
|
-
|
71
|
+
rdoc_options: []
|
72
|
+
|
98
73
|
require_paths:
|
99
74
|
- lib
|
100
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -102,26 +77,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
77
|
requirements:
|
103
78
|
- - ">="
|
104
79
|
- !ruby/object:Gem::Version
|
105
|
-
hash: 3
|
106
|
-
segments:
|
107
|
-
- 0
|
108
80
|
version: "0"
|
109
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
82
|
none: false
|
111
83
|
requirements:
|
112
84
|
- - ">="
|
113
85
|
- !ruby/object:Gem::Version
|
114
|
-
hash: 3
|
115
|
-
segments:
|
116
|
-
- 0
|
117
86
|
version: "0"
|
118
87
|
requirements: []
|
119
88
|
|
120
89
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.
|
90
|
+
rubygems_version: 1.8.11
|
122
91
|
signing_key:
|
123
92
|
specification_version: 3
|
124
93
|
summary: Ruby wrapper around the PolicyMap API
|
125
|
-
test_files:
|
126
|
-
|
127
|
-
- spec/spec_helper.rb
|
94
|
+
test_files: []
|
95
|
+
|
data/spec/policymap_wrap_spec.rb
DELETED