broadband_map 0.0.1
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/.autotest +1 -0
- data/.gemtest +0 -0
- data/.gitignore +41 -0
- data/.rspec +3 -0
- data/.yardopts +3 -0
- data/Gemfile +4 -0
- data/LICENSE.md +10 -0
- data/README.md +66 -0
- data/Rakefile +18 -0
- data/broadband_map.gemspec +32 -0
- data/lib/broadband_map.rb +19 -0
- data/lib/broadband_map/client.rb +32 -0
- data/lib/broadband_map/client/almanac.rb +74 -0
- data/lib/broadband_map/client/bip.rb +50 -0
- data/lib/broadband_map/client/btop.rb +50 -0
- data/lib/broadband_map/client/cai.rb +65 -0
- data/lib/broadband_map/client/census.rb +46 -0
- data/lib/broadband_map/client/connection.rb +19 -0
- data/lib/broadband_map/client/demographics.rb +65 -0
- data/lib/broadband_map/client/geography.rb +72 -0
- data/lib/broadband_map/client/provider.rb +34 -0
- data/lib/broadband_map/client/request.rb +18 -0
- data/lib/broadband_map/client/speed_test.rb +65 -0
- data/lib/broadband_map/client/summary.rb +38 -0
- data/lib/broadband_map/client/wire.rb +33 -0
- data/lib/broadband_map/version.rb +3 -0
- data/spec/broadband_map/almanac_spec.rb +74 -0
- data/spec/broadband_map/bip_spec.rb +47 -0
- data/spec/broadband_map/btop_spec.rb +47 -0
- data/spec/broadband_map/cai_spec.rb +62 -0
- data/spec/broadband_map/census_spec.rb +48 -0
- data/spec/broadband_map/demographics_spec.rb +61 -0
- data/spec/broadband_map/geography_spec.rb +74 -0
- data/spec/broadband_map/providers_spec.rb +34 -0
- data/spec/broadband_map/speed_test_spec.rb +61 -0
- data/spec/broadband_map/summary_spec.rb +36 -0
- data/spec/broadband_map/wire_spec.rb +35 -0
- data/spec/broadband_map_spec.rb +10 -0
- data/spec/fixtures/almanac_parameters.json +1 -0
- data/spec/fixtures/almanac_rank_geo_type_nation.json +1 -0
- data/spec/fixtures/almanac_rank_geo_type_state.json +1 -0
- data/spec/fixtures/almanac_rank_geography_id_nation.json +1 -0
- data/spec/fixtures/almanac_rank_geography_id_state.json +1 -0
- data/spec/fixtures/bip_nation.json +1 -0
- data/spec/fixtures/bip_state_id.json +1 -0
- data/spec/fixtures/bip_state_name.json +1 -0
- data/spec/fixtures/btop_nation.json +1 -0
- data/spec/fixtures/btop_state_id.json +1 -0
- data/spec/fixtures/btop_state_name.json +1 -0
- data/spec/fixtures/cai_closest.json +1 -0
- data/spec/fixtures/cai_geo_id.json +1 -0
- data/spec/fixtures/cai_geo_name.json +1 -0
- data/spec/fixtures/cai_nation.json +1 -0
- data/spec/fixtures/census_coords.json +1 -0
- data/spec/fixtures/census_fips.json +1 -0
- data/spec/fixtures/census_geo_name.json +1 -0
- data/spec/fixtures/demo_coords.json +1 -0
- data/spec/fixtures/demo_geo_id.json +1 -0
- data/spec/fixtures/demo_geo_name.json +1 -0
- data/spec/fixtures/demo_nation.json +1 -0
- data/spec/fixtures/geo_id.json +1 -0
- data/spec/fixtures/geo_type.json +1 -0
- data/spec/fixtures/geo_type_name.json +1 -0
- data/spec/fixtures/geo_type_state.json +1 -0
- data/spec/fixtures/geo_type_state_name.json +1 -0
- data/spec/fixtures/providers_all.json +1 -0
- data/spec/fixtures/providers_name.json +1 -0
- data/spec/fixtures/speed_geo_type_id.json +1 -0
- data/spec/fixtures/speed_geo_type_name.json +1 -0
- data/spec/fixtures/speed_nation.json +1 -0
- data/spec/fixtures/speed_quartile_type.json +1 -0
- data/spec/fixtures/summary_geo.json +1 -0
- data/spec/fixtures/summary_nation.json +1 -0
- data/spec/fixtures/wireless.json +1 -0
- data/spec/fixtures/wireline.json +1 -0
- data/spec/helper.rb +48 -0
- metadata +302 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Census
|
|
4
|
+
|
|
5
|
+
# Returns the US Census Block geography ID information given a passed Latitude and Longitude.
|
|
6
|
+
# @param params [Hash] :geography_type, :latitude, :longitude and optional :format, :callback
|
|
7
|
+
# @param options [Hash] A customizable set of options.
|
|
8
|
+
# @return {Hash}
|
|
9
|
+
# @see http://www.broadbandmap.gov/developer/api/census-api-by-coordinates
|
|
10
|
+
# @example
|
|
11
|
+
# census_coords({:geography_type => 'block', :latitude => 42.456, :longitude => 74.987})
|
|
12
|
+
|
|
13
|
+
def census_coords(params={}, options={})
|
|
14
|
+
params = {:format => 'json'}.merge(params)
|
|
15
|
+
get("census/#{params[:geography_type]}?latitude=#{params[:latitude]}&longitude=#{params[:longitude]}&format=#{params[:format]}&callback=#{params[:callback]}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the geography of a specified geography type by geography id within the entire United States.
|
|
19
|
+
# @param params [Hash] :geography_type, :fips and optional :format, :callback
|
|
20
|
+
# @param options [Hash] A customizable set of options.
|
|
21
|
+
# @return {Hash}
|
|
22
|
+
# @see http://www.broadbandmap.gov/developer/api/census-api-by-fips-code
|
|
23
|
+
# @example
|
|
24
|
+
# census_fips({:geography_type => 'state', :fips => '36'})
|
|
25
|
+
|
|
26
|
+
def census_fips(params={}, options={})
|
|
27
|
+
params = {:format => 'json'}.merge(params)
|
|
28
|
+
get("census/#{params[:geography_type]}/fips/#{params[:fips]}?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns all the geographies specified by a geography name (e.g., Washington) of a specific geography type (e.g., congressional district) within the entire United States.
|
|
32
|
+
# @param params [Hash] :geography_type, :geography_name and optional :format, :max_results, :callback
|
|
33
|
+
# @param options [Hash] A customizable set of options.
|
|
34
|
+
# @return {Hash}
|
|
35
|
+
# @see http://www.broadbandmap.gov/developer/api/census-api-by-geography-name
|
|
36
|
+
# @example
|
|
37
|
+
# census_geo_name({:geography_type => 'county', :geography_name => 'fai'})
|
|
38
|
+
|
|
39
|
+
def census_geo_name(params={}, options={})
|
|
40
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
41
|
+
get("census/#{params[:geography_type]}/#{params[:geography_name]}?format=#{params[:format]}&maxresults=#{params[:max_results]}&all=#{params[:all]}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'faraday_middleware'
|
|
2
|
+
|
|
3
|
+
module BroadbandMap
|
|
4
|
+
class Client
|
|
5
|
+
module Connection
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def connection
|
|
9
|
+
Faraday.new(:url => 'http://www.broadbandmap.gov/broadbandmap/') do |connection|
|
|
10
|
+
connection.use Faraday::Request::UrlEncoded
|
|
11
|
+
connection.use Faraday::Response::RaiseError
|
|
12
|
+
connection.use Faraday::Response::Rashify
|
|
13
|
+
connection.use Faraday::Response::ParseJson
|
|
14
|
+
connection.adapter(Faraday.default_adapter)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Demographics
|
|
4
|
+
|
|
5
|
+
# Returns the demographics data from the coordinates.
|
|
6
|
+
# @param params [Hash] :data_version, :latitude, :longitude and optional :format, :callback
|
|
7
|
+
# @param options [Hash] A customizable set of options.
|
|
8
|
+
# @return {Hash}
|
|
9
|
+
# @see http://www.broadbandmap.gov/developer/api/demographics-api-by-coordinates
|
|
10
|
+
# @example
|
|
11
|
+
# demographics_coords({:data_version => 'fall2010', :latitude => 42.456, :longitude => -74.987})
|
|
12
|
+
|
|
13
|
+
def demographics_coords(params={}, options={})
|
|
14
|
+
params = {:format => 'json'}.merge(params)
|
|
15
|
+
get("demographic/#{params[:data_version]}/coordinates?latitude=#{params[:latitude]}&longitude=#{params[:longitude]}&format=#{params[:format]}&callback=#{params[:callback]}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the demographic information for a particular geography type and geography ID
|
|
19
|
+
# @param params [Hash] :data_version, :geography_type, :geography_ids and optional :format, :callback
|
|
20
|
+
# @param options [Hash] A customizable set of options.
|
|
21
|
+
# @return {Hash}
|
|
22
|
+
# @see http://www.broadbandmap.gov/developer/api/demographics-api-by-geography-type-and-geography-id
|
|
23
|
+
# @example
|
|
24
|
+
# demographics_geo_id({:data_version => 'fall2010', :geography_type => 'county', :geography_ids => ['17081', '17083']})
|
|
25
|
+
|
|
26
|
+
def demographics_geo_id(params={}, options={})
|
|
27
|
+
params = {:format => 'json'}.merge(params)
|
|
28
|
+
ids = ""
|
|
29
|
+
params[:geography_ids].each {|x| ids += x +","}
|
|
30
|
+
ids.chop!
|
|
31
|
+
get("demographic/#{params[:data_version]}/#{params[:geography_type]}/ids/#{ids}?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the demographic information for a particular geography type and geography name.
|
|
35
|
+
# @param params [Hash] :data_version, :geography_type, :geography_names and optional :format, :callback
|
|
36
|
+
# @param options [Hash] A customizable set of options.
|
|
37
|
+
# @return {Hash}
|
|
38
|
+
# @see http://www.broadbandmap.gov/developer/api/demographics-api-by-geography-type-and-geography-name
|
|
39
|
+
# @example
|
|
40
|
+
# demographics_geo_name({:data_version => 'fall2010', :geography_type => 'county', :geography_names => ['jersey', 'jefferson']})
|
|
41
|
+
|
|
42
|
+
def demographics_geo_name(params={}, options={})
|
|
43
|
+
params = {:format => 'json'}.merge(params)
|
|
44
|
+
names = ""
|
|
45
|
+
params[:geography_names].each {|x| names += x +","}
|
|
46
|
+
names.chop!
|
|
47
|
+
get("demographic/#{params[:data_version]}/#{params[:geography_type]}/names/#{names}?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns the demographic information for the whole nation.
|
|
51
|
+
# @param params [Hash] :data_version, and optional :format, :callback
|
|
52
|
+
# @param options [Hash] A customizable set of options.
|
|
53
|
+
# @return {Hash}
|
|
54
|
+
# @see http://www.broadbandmap.gov/developer/api/demographics-api-nation
|
|
55
|
+
# @example
|
|
56
|
+
# demographics_nation({:data_version => 'fall2010'})
|
|
57
|
+
|
|
58
|
+
def demographics_nation(params={}, options={})
|
|
59
|
+
params = {:format => 'json'}.merge(params)
|
|
60
|
+
get("demographic/#{params[:data_version]}/nation?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Geography
|
|
4
|
+
|
|
5
|
+
# Returns a geography of a specified geography type by the geography id.
|
|
6
|
+
# @param params [Hash] :geography_type, :geography_id and optional :format, :callback
|
|
7
|
+
# @param options [Hash] A customizable set of options.
|
|
8
|
+
# @return {Hash}
|
|
9
|
+
# @see http://www.broadbandmap.gov/developer/api/geography-lookup-api-by-geography-id
|
|
10
|
+
# @example
|
|
11
|
+
# geography_id({:geography_type => 'congdistrict', :geography_id => '0111101'})
|
|
12
|
+
|
|
13
|
+
def geography_id(params={}, options={})
|
|
14
|
+
params = {:format => 'json'}.merge(params)
|
|
15
|
+
get("geography/#{params[:geography_type]}/id/#{params[:geography_id]}?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns all geographies of a specified geography type.
|
|
19
|
+
# @param params [Hash] :geography_type, and optional :format, :max_results, :callback
|
|
20
|
+
# @param options [Hash] A customizable set of options.
|
|
21
|
+
# @return {Hash}
|
|
22
|
+
# @see http://www.broadbandmap.gov/developer/api/geography-lookup-api-by-geography-type
|
|
23
|
+
# @example
|
|
24
|
+
# geography_type({:geography_type => 'congdistrict', :max_results => 1000})
|
|
25
|
+
|
|
26
|
+
def geography_type(params={}, options={})
|
|
27
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
28
|
+
get("geography/#{params[:geography_type]}?format=#{params[:format]}&maxresults=#{params[:max_results]}&all=#{params[:all]}&callback=#{params[:callback]}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns geographies by name of a specific geography type.
|
|
32
|
+
# @param params [Hash] :geography_type, :geography_name and optional :format, :max_results, :callback
|
|
33
|
+
# @param options [Hash] A customizable set of options.
|
|
34
|
+
# @return {Hash}
|
|
35
|
+
# @see http://www.broadbandmap.gov/developer/api/geography-lookup-api-by-geography-type-and-geography-name
|
|
36
|
+
# @example
|
|
37
|
+
# geography_type_name({:geography_type => 'censusplace', :geography_name => 'sei'})
|
|
38
|
+
|
|
39
|
+
def geography_type_name(params={}, options={})
|
|
40
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
41
|
+
get("geography/#{params[:geography_type]}/name/#{params[:geography_name]}?format=#{params[:format]}&maxresults=#{params[:max_results]}&all=#{params[:all]}&callback=#{params[:callback]}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns all geographies of specific geography type within a state.
|
|
45
|
+
# @param params [Hash] :state_fips, :geography_type, :geography_type and optional :format, :max_results, :callback
|
|
46
|
+
# @param options [Hash] A customizable set of options.
|
|
47
|
+
# @return {Hash}
|
|
48
|
+
# @see http://www.broadbandmap.gov/developer/api/geography-lookup-api-by-geography-type-within-a-state
|
|
49
|
+
# @example
|
|
50
|
+
# geography_type_state({:geography_type => 'msa', :state_fips => '01'})
|
|
51
|
+
|
|
52
|
+
def geography_type_state(params={}, options={})
|
|
53
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
54
|
+
get("geography/state/#{params[:state_fips]}/#{params[:geography_type]}?format=#{params[:format]}&maxresults=#{params[:max_results]}&all=#{params[:all]}&callback=#{params[:callback]}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Returns geographies by name of a specific geography type within a state.
|
|
58
|
+
# @param params [Hash] :state_fips, :geography_type, :geography_name and optional :format, :max_results, :callback
|
|
59
|
+
# @param options [Hash] A customizable set of options.
|
|
60
|
+
# @return {Hash}
|
|
61
|
+
# @see http://www.broadbandmap.gov/developer/api/geography-lookup-api-by-name-of-specific-geography-type-within-a-state
|
|
62
|
+
# @example
|
|
63
|
+
# geography_type_name_state({:geography_type => 'county', :state_fips => '17', :geography_name => 'mar'})
|
|
64
|
+
|
|
65
|
+
def geography_type_name_state(params={}, options={})
|
|
66
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
67
|
+
get("geography/state/#{params[:state_fips]}/#{params[:geography_type]}/name/#{params[:geography_name]}?format=#{params[:format]}&maxresults=#{params[:max_results]}&all=#{params[:all]}&callback=#{params[:callback]}")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Provider
|
|
4
|
+
|
|
5
|
+
# Returns all providers.
|
|
6
|
+
#
|
|
7
|
+
# @param params [Hash] options for the lookup.
|
|
8
|
+
# @param options [Hash] A customizable set of options.
|
|
9
|
+
# @return {Hash}
|
|
10
|
+
# @see http://www.broadbandmap.gov/developer/api/broadband-provider-api-all-providers
|
|
11
|
+
# @example
|
|
12
|
+
# provider_all()
|
|
13
|
+
|
|
14
|
+
def provider_all(params={}, options={})
|
|
15
|
+
params = {:format => 'json'}.merge(params)
|
|
16
|
+
get("provider?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Searches for all providers with a specified name.
|
|
20
|
+
#
|
|
21
|
+
# @param params [Hash] options for the lookup.
|
|
22
|
+
# @param options [Hash] A customizable set of options.
|
|
23
|
+
# @return {Hash}
|
|
24
|
+
# @see http://www.broadbandmap.gov/developer/api/broadband-provider-api-by-provider-names
|
|
25
|
+
# @example
|
|
26
|
+
# provider_name({:name => 'alb'})
|
|
27
|
+
|
|
28
|
+
def provider_name(params={}, options={})
|
|
29
|
+
params = {:format => 'json', :max_results => 20}.merge(params)
|
|
30
|
+
get("provider/name/#{params[:name]}?format=#{params[:format]}&all=#{params[:all]}&maxresults=#{params[:max_results]}&callback=#{params[:callback]}")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Request
|
|
4
|
+
def get(path, options={})
|
|
5
|
+
request(:get, path, options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def request(method, path, options)
|
|
11
|
+
response = connection.send(method) do |request|
|
|
12
|
+
request.url(path, options)
|
|
13
|
+
end
|
|
14
|
+
response.body
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module SpeedTest
|
|
4
|
+
|
|
5
|
+
# Returns the speed test results for a particular geography type (e.g., state, congressional district) and geography ID.
|
|
6
|
+
# @param params [Hash] :geogrpahy_type and :geography_ids and optional :speed_test_type, :format, :callback
|
|
7
|
+
# @param options [Hash] A customizable set of options.
|
|
8
|
+
# @return {Hash}
|
|
9
|
+
# @see http://www.broadbandmap.gov/developer/api/speed-test-api-by-geography-type-and-geography-id
|
|
10
|
+
# @example
|
|
11
|
+
# speed_test_geo_type_id({:geography_type => 'state', :geography_ids => ['01', '02']})
|
|
12
|
+
|
|
13
|
+
def speed_test_geo_type_id(params={}, options={})
|
|
14
|
+
params = {:format => 'json'}.merge(params)
|
|
15
|
+
ids = ""
|
|
16
|
+
params[:geography_ids].each {|x| ids += x +","}
|
|
17
|
+
ids.chop!
|
|
18
|
+
get("speedtest/#{params[:geography_type]}/ids/#{ids}?format=#{params[:format]}&speedtesttype=#{params[:speed_test_type]}&callback=#{params[:callback]}")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns the speed test results for a particular geography type (e.g., state, congressional district) and geography name (e.g., Virginia).
|
|
22
|
+
# @param params [Hash] :geogrpahy_type and :geography_names and optional :speed_test_type, :format, :callback
|
|
23
|
+
# @param options [Hash] A customizable set of options.
|
|
24
|
+
# @return {Hash}
|
|
25
|
+
# @see http://www.broadbandmap.gov/developer/api/speed-test-api-by-geography-type-and-geography-name
|
|
26
|
+
# @example
|
|
27
|
+
# speed_test_geo_type_name({:geography_type => 'state', :geography_names => ['alabama', 'arizona']})
|
|
28
|
+
|
|
29
|
+
def speed_test_geo_type_name(params={}, options={})
|
|
30
|
+
params = {:format => 'json'}.merge(params)
|
|
31
|
+
names = ""
|
|
32
|
+
params[:geography_names].each {|x| names += x +","}
|
|
33
|
+
names.chop!
|
|
34
|
+
get("speedtest/#{params[:geography_type]}/names/#{names}?format=#{params[:format]}&speedtesttype=#{params[:speed_test_type]}&callback=#{params[:callback]}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the minimum and maximum quartile speeds by geography type within the nation.
|
|
38
|
+
# @param params [Hash] :geogrpahy_type and optional :speed_test_type, :format, :callback
|
|
39
|
+
# @param options [Hash] A customizable set of options.
|
|
40
|
+
# @return {Hash}
|
|
41
|
+
# @see http://www.broadbandmap.gov/developer/api/speed-test-api-minimum-and-maximum-quartile-speeds-by-geography-type
|
|
42
|
+
# @example
|
|
43
|
+
# speed_test_quartile({:geography_type => 'state'})
|
|
44
|
+
|
|
45
|
+
def speed_test_quartile(params={}, options={})
|
|
46
|
+
params = {:format => 'json'}.merge(params)
|
|
47
|
+
get("speedtest/#{params[:geography_type]}/quartile?format=#{params[:format]}&speedtesttype=#{params[:speed_test_type]}&callback=#{params[:callback]}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns all the speed test results for the entire United States.
|
|
51
|
+
# @param params [Hash] optional :speed_test_type, :format, :callback
|
|
52
|
+
# @param options [Hash] A customizable set of options.
|
|
53
|
+
# @return {Hash}
|
|
54
|
+
# @see http://www.broadbandmap.gov/developer/api/speed-test-api-nation
|
|
55
|
+
# @example
|
|
56
|
+
# speed_test_nation()
|
|
57
|
+
|
|
58
|
+
def speed_test_nation(params={}, options={})
|
|
59
|
+
params = {:format => 'json'}.merge(params)
|
|
60
|
+
get("speedtest/nation?format=#{params[:format]}&speedtesttype=#{params[:speed_test_type]}&callback=#{params[:callback]}")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Summary
|
|
4
|
+
|
|
5
|
+
# Returns broadband summary data by geography IDs for a specific geography type
|
|
6
|
+
#
|
|
7
|
+
# @param params [Hash] :data_version, :census_metric_type, :geography_type (optional :format, :callback)
|
|
8
|
+
# @param options [Hash] A customizable set of options.
|
|
9
|
+
# @return {Hash}
|
|
10
|
+
# @see http://www.broadbandmap.gov/developer/api/broadband-summary-api-by-geography-type-and-geography-id
|
|
11
|
+
# @example
|
|
12
|
+
# summary_geo({:data_version => 'fall2010', :census_metric_type => 'population', :geography_type => 'state', :geography_ids => ['10']})
|
|
13
|
+
|
|
14
|
+
def summary_geo(params={}, options={})
|
|
15
|
+
params = {:format => 'json'}.merge(params)
|
|
16
|
+
ids = ""
|
|
17
|
+
params[:geography_ids].each {|x| ids += x +","}
|
|
18
|
+
ids.chop!
|
|
19
|
+
get("analyze/#{params[:data_version]}/summary/#{params[:census_metric_type]}/#{params[:geography_type]}/ids/#{ids}?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns broadband summary data for the nation
|
|
23
|
+
#
|
|
24
|
+
# @param params [Hash] :data_version, :census_metric_type (optional :format, :callback)
|
|
25
|
+
# @param options [Hash] A customizable set of options.
|
|
26
|
+
# @return {Hash}
|
|
27
|
+
# @see http://www.broadbandmap.gov/developer/api/broadband-summary-api-nation
|
|
28
|
+
# @example
|
|
29
|
+
# summary_nation(:data_version => 'fall2010', :census_metric_type => 'population')
|
|
30
|
+
|
|
31
|
+
def summary_nation(params={}, options={})
|
|
32
|
+
params = {:format => 'json'}.merge(params)
|
|
33
|
+
get("analyze/#{params[:data_version]}/summary/#{params[:census_metric_type]}/nation?format=#{params[:format]}&callback=#{params[:callback]}")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module BroadbandMap
|
|
2
|
+
class Client
|
|
3
|
+
module Wire
|
|
4
|
+
|
|
5
|
+
# Returns all the wireless providers within a US census block given a passed latitude and longitude.
|
|
6
|
+
# @param params [Hash] :data_version, :latitude, :longitude and optional :max_results, :format, :callback
|
|
7
|
+
# @param options [Hash] A customizable set of options.
|
|
8
|
+
# @return {Hash}
|
|
9
|
+
# @see http://www.broadbandmap.gov/developer/api/wireless-broadband-api
|
|
10
|
+
# @example
|
|
11
|
+
# wireless({:data_version => 'fall2010', :latitude => 42.456, :longitude => -74.987})
|
|
12
|
+
|
|
13
|
+
def wireless(params={}, options={})
|
|
14
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
15
|
+
get("broadband/#{params[:data_version]}/wireless?latitude=#{params[:latitude]}&longitude=#{params[:longitude]}&format=#{params[:format]}&maxresults=#{params[:max_results]}&callback=#{params[:callback]}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns all the wireline providers within a US census block given a passed latitude and longitude.
|
|
19
|
+
# @param params [Hash] :data_version, :latitude, :longitude and optional :max_results, :format, :callback
|
|
20
|
+
# @param options [Hash] A customizable set of options.
|
|
21
|
+
# @return {Hash}
|
|
22
|
+
# @see http://www.broadbandmap.gov/developer/api/wireline-broadband-api
|
|
23
|
+
# @example
|
|
24
|
+
# wireline({:data_version => 'fall2010', :latitude => 42.456, :longitude => -74.987})
|
|
25
|
+
|
|
26
|
+
def wireline(params={}, options={})
|
|
27
|
+
params = {:format => 'json', :max_results => 100}.merge(params)
|
|
28
|
+
get("broadband/#{params[:data_version]}/wireline?latitude=#{params[:latitude]}&longitude=#{params[:longitude]}&format=#{params[:format]}&maxresults=#{params[:max_results]}&callback=#{params[:callback]}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe BroadbandMap::Client::Almanac do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = BroadbandMap::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe ".almanac_parameters" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("almanac/parameters?format=json&callback=").
|
|
12
|
+
to_return(:status => 200, :body => fixture("almanac_parameters.json"))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return the correct item" do
|
|
16
|
+
test = @client.almanac_parameters()
|
|
17
|
+
a_get("almanac/parameters?format=json&callback=").should have_been_made
|
|
18
|
+
test.results.geographies.property[0].should == "tribalnation"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe ".almanac_ranking_geo_id_within_state" do
|
|
23
|
+
before do
|
|
24
|
+
stub_get("almanac/fall2010/rankby/state/01/population/wirelineproviderequals0/county/id/01101?format=json&order=asc&properties=&callback=").
|
|
25
|
+
to_return(:status => 200, :body => fixture("almanac_rank_geography_id_state.json"))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should return the correct item" do
|
|
29
|
+
test = @client.almanac_ranking_geo_id_within_state({:data_version => 'fall2010', :state_id => '01', :census_metric_type => 'population', :ranking_metric => 'wirelineproviderequals0', :geography_type => 'county', :geography_id => '01101', :sort_order => 'asc'})
|
|
30
|
+
a_get("almanac/fall2010/rankby/state/01/population/wirelineproviderequals0/county/id/01101?format=json&order=asc&properties=&callback=").should have_been_made
|
|
31
|
+
test.results.all[0].rank.should == 1
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe ".almanac_ranking_geo_id_within_nation" do
|
|
36
|
+
before do
|
|
37
|
+
stub_get("almanac/fall2010/rankby/nation/population/wirelineproviderequals0/county/id/51117?format=json&order=asc&properties=&callback=").
|
|
38
|
+
to_return(:status => 200, :body => fixture("almanac_rank_geography_id_nation.json"))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should return the correct item" do
|
|
42
|
+
test = @client.almanac_ranking_geo_id_within_nation({:data_version => 'fall2010', :census_metric_type => 'population', :ranking_metric => 'wirelineproviderequals0', :geography_type => 'county', :geography_id => '51117', :sort_order => 'asc'})
|
|
43
|
+
a_get("almanac/fall2010/rankby/nation/population/wirelineproviderequals0/county/id/51117?format=json&order=asc&properties=&callback=").should have_been_made
|
|
44
|
+
test.results.firstTen[0].geographyId.should == "60020"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe ".almanac_ranking_geo_type_within_state" do
|
|
49
|
+
before do
|
|
50
|
+
stub_get("almanac/fall2010/rankby/state/01/population/wirelineproviderequals0/county?format=json&order=asc&properties=&callback=").
|
|
51
|
+
to_return(:status => 200, :body => fixture("almanac_rank_geo_type_state.json"))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should return the correct item" do
|
|
55
|
+
test = @client.almanac_ranking_geo_type_within_state({:data_version => 'fall2010', :state_id => '01', :census_metric_type => 'population', :ranking_metric => 'wirelineproviderequals0', :geography_type => 'county', :sort_order => 'asc'})
|
|
56
|
+
a_get("almanac/fall2010/rankby/state/01/population/wirelineproviderequals0/county?format=json&order=asc&properties=&callback=").should have_been_made
|
|
57
|
+
test.results.all[0].geographyId.should == "01063"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe ".almanac_ranking_geo_type_within_nation" do
|
|
62
|
+
before do
|
|
63
|
+
stub_get("almanac/fall2010/rankby/nation/population/wirelineproviderequals0/county?format=json&order=asc&properties=&callback=").
|
|
64
|
+
to_return(:status => 200, :body => fixture("almanac_rank_geo_type_nation.json"))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should return the correct item" do
|
|
68
|
+
test = @client.almanac_ranking_geo_type_within_nation({:data_version => 'fall2010', :census_metric_type => 'population', :ranking_metric => 'wirelineproviderequals0', :geography_type => 'county', :sort_order => 'asc'})
|
|
69
|
+
a_get("almanac/fall2010/rankby/nation/population/wirelineproviderequals0/county?format=json&order=asc&properties=&callback=").should have_been_made
|
|
70
|
+
test.results.firstTen[0].geographyId.should == "60020"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|