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.
Files changed (77) hide show
  1. data/.autotest +1 -0
  2. data/.gemtest +0 -0
  3. data/.gitignore +41 -0
  4. data/.rspec +3 -0
  5. data/.yardopts +3 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.md +10 -0
  8. data/README.md +66 -0
  9. data/Rakefile +18 -0
  10. data/broadband_map.gemspec +32 -0
  11. data/lib/broadband_map.rb +19 -0
  12. data/lib/broadband_map/client.rb +32 -0
  13. data/lib/broadband_map/client/almanac.rb +74 -0
  14. data/lib/broadband_map/client/bip.rb +50 -0
  15. data/lib/broadband_map/client/btop.rb +50 -0
  16. data/lib/broadband_map/client/cai.rb +65 -0
  17. data/lib/broadband_map/client/census.rb +46 -0
  18. data/lib/broadband_map/client/connection.rb +19 -0
  19. data/lib/broadband_map/client/demographics.rb +65 -0
  20. data/lib/broadband_map/client/geography.rb +72 -0
  21. data/lib/broadband_map/client/provider.rb +34 -0
  22. data/lib/broadband_map/client/request.rb +18 -0
  23. data/lib/broadband_map/client/speed_test.rb +65 -0
  24. data/lib/broadband_map/client/summary.rb +38 -0
  25. data/lib/broadband_map/client/wire.rb +33 -0
  26. data/lib/broadband_map/version.rb +3 -0
  27. data/spec/broadband_map/almanac_spec.rb +74 -0
  28. data/spec/broadband_map/bip_spec.rb +47 -0
  29. data/spec/broadband_map/btop_spec.rb +47 -0
  30. data/spec/broadband_map/cai_spec.rb +62 -0
  31. data/spec/broadband_map/census_spec.rb +48 -0
  32. data/spec/broadband_map/demographics_spec.rb +61 -0
  33. data/spec/broadband_map/geography_spec.rb +74 -0
  34. data/spec/broadband_map/providers_spec.rb +34 -0
  35. data/spec/broadband_map/speed_test_spec.rb +61 -0
  36. data/spec/broadband_map/summary_spec.rb +36 -0
  37. data/spec/broadband_map/wire_spec.rb +35 -0
  38. data/spec/broadband_map_spec.rb +10 -0
  39. data/spec/fixtures/almanac_parameters.json +1 -0
  40. data/spec/fixtures/almanac_rank_geo_type_nation.json +1 -0
  41. data/spec/fixtures/almanac_rank_geo_type_state.json +1 -0
  42. data/spec/fixtures/almanac_rank_geography_id_nation.json +1 -0
  43. data/spec/fixtures/almanac_rank_geography_id_state.json +1 -0
  44. data/spec/fixtures/bip_nation.json +1 -0
  45. data/spec/fixtures/bip_state_id.json +1 -0
  46. data/spec/fixtures/bip_state_name.json +1 -0
  47. data/spec/fixtures/btop_nation.json +1 -0
  48. data/spec/fixtures/btop_state_id.json +1 -0
  49. data/spec/fixtures/btop_state_name.json +1 -0
  50. data/spec/fixtures/cai_closest.json +1 -0
  51. data/spec/fixtures/cai_geo_id.json +1 -0
  52. data/spec/fixtures/cai_geo_name.json +1 -0
  53. data/spec/fixtures/cai_nation.json +1 -0
  54. data/spec/fixtures/census_coords.json +1 -0
  55. data/spec/fixtures/census_fips.json +1 -0
  56. data/spec/fixtures/census_geo_name.json +1 -0
  57. data/spec/fixtures/demo_coords.json +1 -0
  58. data/spec/fixtures/demo_geo_id.json +1 -0
  59. data/spec/fixtures/demo_geo_name.json +1 -0
  60. data/spec/fixtures/demo_nation.json +1 -0
  61. data/spec/fixtures/geo_id.json +1 -0
  62. data/spec/fixtures/geo_type.json +1 -0
  63. data/spec/fixtures/geo_type_name.json +1 -0
  64. data/spec/fixtures/geo_type_state.json +1 -0
  65. data/spec/fixtures/geo_type_state_name.json +1 -0
  66. data/spec/fixtures/providers_all.json +1 -0
  67. data/spec/fixtures/providers_name.json +1 -0
  68. data/spec/fixtures/speed_geo_type_id.json +1 -0
  69. data/spec/fixtures/speed_geo_type_name.json +1 -0
  70. data/spec/fixtures/speed_nation.json +1 -0
  71. data/spec/fixtures/speed_quartile_type.json +1 -0
  72. data/spec/fixtures/summary_geo.json +1 -0
  73. data/spec/fixtures/summary_nation.json +1 -0
  74. data/spec/fixtures/wireless.json +1 -0
  75. data/spec/fixtures/wireline.json +1 -0
  76. data/spec/helper.rb +48 -0
  77. metadata +302 -0
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Bip do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".bip_state_id" do
10
+ before do
11
+ stub_get("bip/stateids/01,02?format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("bip_state_id.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.bip_state_id(:state_ids => ['01', '02'])
17
+ a_get("bip/stateids/01,02?format=json&callback=").should have_been_made
18
+ test.results[0].geographyId.should == "01"
19
+ end
20
+ end
21
+
22
+ describe ".bip_state_name" do
23
+ before do
24
+ stub_get("bip/states/alaska,alabama?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("bip_state_name.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.bip_state_name(:state_names => ['alaska', 'alabama'])
30
+ a_get("bip/states/alaska,alabama?format=json&callback=").should have_been_made
31
+ test.results[0].geographyId.should == '01'
32
+ end
33
+ end
34
+
35
+ describe ".bip_nation" do
36
+ before do
37
+ stub_get("bip/nation?format=json&callback=").
38
+ to_return(:status => 200, :body => fixture("bip_nation.json"))
39
+ end
40
+
41
+ it "should return the correct item" do
42
+ test = @client.bip_nation()
43
+ a_get("bip/nation?format=json&callback=").should have_been_made
44
+ test.results[0].grantRequest.should == 542135078
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Btop do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".btop_state_id" do
10
+ before do
11
+ stub_get("btop/stateids/01,02?format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("btop_state_id.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.btop_state_id(:state_ids => ['01', '02'])
17
+ a_get("btop/stateids/01,02?format=json&callback=").should have_been_made
18
+ test.results[0].geographyId.should == "01"
19
+ end
20
+ end
21
+
22
+ describe ".btop_state_name" do
23
+ before do
24
+ stub_get("btop/states/alaska,alabama?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("btop_state_name.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.btop_state_name(:state_names => ['alaska', 'alabama'])
30
+ a_get("btop/states/alaska,alabama?format=json&callback=").should have_been_made
31
+ test.results[0].geographyId.should == '01'
32
+ end
33
+ end
34
+
35
+ describe ".btop_nation" do
36
+ before do
37
+ stub_get("btop/nation?format=json&callback=").
38
+ to_return(:status => 200, :body => fixture("btop_nation.json"))
39
+ end
40
+
41
+ it "should return the correct item" do
42
+ test = @client.btop_nation()
43
+ a_get("btop/nation?format=json&callback=").should have_been_made
44
+ test.results[0].totalAwardInDollars.should == 3484813380
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,62 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Cai do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".cai_closest" do
10
+ before do
11
+ stub_get("cai/closest?latitude=41.486857&longitude=-71.294392&maxresults=2&format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("cai_closest.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.cai_closest({:latitude => 41.486857, :longitude => -71.294392, :max_results=> 2})
17
+ a_get("cai/closest?latitude=41.486857&longitude=-71.294392&maxresults=2&format=json&callback=").should have_been_made
18
+ test.results[0].latitude.should == 41.49
19
+ end
20
+ end
21
+
22
+ describe ".cai_geo_id" do
23
+ before do
24
+ stub_get("cai/fall2010/state/ids/01,02?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("cai_geo_id.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.cai_geo_id({:data_version => 'fall2010', :geography_type => 'state', :geography_ids => ['01','02']})
30
+ a_get("cai/fall2010/state/ids/01,02?format=json&callback=").should have_been_made
31
+ test.results[0].geographyId.should == '01'
32
+ end
33
+ end
34
+
35
+ describe ".cai_geo_name" do
36
+ before do
37
+ stub_get("cai/fall2010/state/names/alabama,arizona?format=json&callback=").
38
+ to_return(:status => 200, :body => fixture("cai_geo_name.json"))
39
+ end
40
+
41
+ it "should return the correct item" do
42
+ test = @client.cai_geo_name({:data_version => 'fall2010', :geography_type => 'state', :geography_names => ['alabama', 'arizona']})
43
+ a_get("cai/fall2010/state/names/alabama,arizona?format=json&callback=").should have_been_made
44
+ test.results[0].geographyId.should == '01'
45
+ end
46
+ end
47
+
48
+ describe ".cai_nation" do
49
+ before do
50
+ stub_get("cai/fall2010/nation?format=json&callback=").
51
+ to_return(:status => 200, :body => fixture("cai_nation.json"))
52
+ end
53
+
54
+ it "should return the correct item" do
55
+ test = @client.cai_nation({:data_version => 'fall2010'})
56
+ a_get("cai/fall2010/nation?format=json&callback=").should have_been_made
57
+ test.results[0].geographyId.should == '99'
58
+ end
59
+ end
60
+
61
+
62
+ end
@@ -0,0 +1,48 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Census do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".census_coords" do
10
+ before do
11
+ stub_get("census/block?latitude=42.456&longitude=74.987&format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("census_coords.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.census_coords({:geography_type => 'block', :latitude => 42.456, :longitude => 74.987})
17
+ a_get("census/block?latitude=42.456&longitude=74.987&format=json&callback=").should have_been_made
18
+ test.results.block[0].envelope.miny.should == 42.44690600000003
19
+ end
20
+ end
21
+
22
+ describe ".census_fips" do
23
+ before do
24
+ stub_get("census/state/fips/36?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("census_fips.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.census_fips({:geography_type => 'state', :fips => '36'})
30
+ a_get("census/state/fips/36?format=json&callback=").should have_been_made
31
+ test.results.state[0].fips.should == '36'
32
+ end
33
+ end
34
+
35
+ describe ".census_geo_name" do
36
+ before do
37
+ stub_get("census/county/fai?format=json&maxresults=100&all=").
38
+ to_return(:status => 200, :body => fixture("census_geo_name.json"))
39
+ end
40
+
41
+ it "shoudl return the correct item" do
42
+ test = @client.census_geo_name({:geography_type => 'county', :geography_name => 'fai'})
43
+ a_get("census/county/fai?format=json&maxresults=100&all=").should have_been_made
44
+ test.results.county[0].fips.should == '02090'
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,61 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Demographics do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe '.demographics_coords' do
10
+ before do
11
+ stub_get("demographic/fall2010/coordinates?latitude=42.456&longitude=-74.987&format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("demo_coords.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.demographics_coords({:data_version => 'fall2010', :latitude => 42.456, :longitude => -74.987})
17
+ a_get("demographic/fall2010/coordinates?latitude=42.456&longitude=-74.987&format=json&callback=").should have_been_made
18
+ test.results.medianIncome.should == 44057
19
+ end
20
+ end
21
+
22
+ describe '.demographics_geo_id' do
23
+ before do
24
+ stub_get("demographic/fall2010/county/ids/17081,17083?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("demo_geo_id.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.demographics_geo_id({:data_version => 'fall2010', :geography_type => 'county', :geography_ids => ['17081', '17083']})
30
+ a_get("demographic/fall2010/county/ids/17081,17083?format=json&callback=").should have_been_made
31
+ test.results[0].geographyId.should == '17083'
32
+ end
33
+ end
34
+
35
+ describe '.demographics_geo_names' do
36
+ before do
37
+ stub_get("demographic/fall2010/county/names/jersey,jefferson?format=json&callback=").
38
+ to_return(:status => 200, :body => fixture("demo_geo_name.json"))
39
+ end
40
+
41
+ it "should return the correct item" do
42
+ test = @client.demographics_geo_name({:data_version => 'fall2010', :geography_type => 'county', :geography_names => ['jersey', 'jefferson']})
43
+ a_get("demographic/fall2010/county/names/jersey,jefferson?format=json&callback=").should have_been_made
44
+ test.results[0].geographyId.should == '36045'
45
+ end
46
+ end
47
+
48
+ describe '.demographics_nation' do
49
+ before do
50
+ stub_get("demographic/fall2010/nation?format=json&callback=").
51
+ to_return(:status => 200, :body => fixture("demo_nation.json"))
52
+ end
53
+
54
+ it "should return the correct item" do
55
+ test = @client.demographics_nation({:data_version => 'fall2010'})
56
+ a_get("demographic/fall2010/nation?format=json&callback=").should have_been_made
57
+ test.results[0].landArea.should == 3803232.4871
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,74 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Geography do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".geography_id" do
10
+ before do
11
+ stub_get("geography/congdistrict/id/0111101?format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("geo_id.json"))
13
+ end
14
+
15
+ it "should get the correct item" do
16
+ test = @client.geography_id({:geography_type => 'congdistrict', :geography_id => '0111101'})
17
+ a_get("geography/congdistrict/id/0111101?format=json&callback=").should have_been_made
18
+ test.results[0].geographyId.should == "0111101"
19
+ end
20
+ end
21
+
22
+ describe ".geography_type" do
23
+ before do
24
+ stub_get("geography/congdistrict?format=json&maxresults=1000&all=&callback=").
25
+ to_return(:status => 200, :body => fixture("geo_type.json"))
26
+ end
27
+
28
+ it "should get the correct item" do
29
+ test = @client.geography_type({:geography_type => 'congdistrict', :max_results => 1000})
30
+ a_get("geography/congdistrict?format=json&maxresults=1000&all=&callback=").should have_been_made
31
+ test.results[0].geographyId.should == "0211100"
32
+ end
33
+ end
34
+
35
+ describe ".geography_type_name" do
36
+ before do
37
+ stub_get("geography/censusplace/name/sei?format=json&maxresults=100&all=&callback=").
38
+ to_return(:status => 200, :body => fixture("geo_type_name.json"))
39
+ end
40
+
41
+ it "should get the correct item" do
42
+ test = @client.geography_type_name({:geography_type => 'censusplace', :geography_name => 'sei'})
43
+ a_get("geography/censusplace/name/sei?format=json&maxresults=100&all=&callback=").should have_been_made
44
+ test.results[0].stateFips.should == "08"
45
+ end
46
+ end
47
+
48
+ describe ".geography_type_state" do
49
+ before do
50
+ stub_get("geography/state/01/msa?format=json&maxresults=100&all=&callback=").
51
+ to_return(:status => 200, :body => fixture("geo_type_state.json"))
52
+ end
53
+
54
+ it "should get the correct item" do
55
+ test = @client.geography_type_state({:geography_type => 'msa', :state_fips => '01'})
56
+ a_get("geography/state/01/msa?format=json&maxresults=100&all=&callback=").should have_been_made
57
+ test.results[0].geographyId.should == "11500"
58
+ end
59
+ end
60
+
61
+ describe ".geography_type_name_state" do
62
+ before do
63
+ stub_get("geography/state/17/county/name/mar?format=json&maxresults=100&all=&callback=").
64
+ to_return(:status => 200, :body => fixture("geo_type_state_name.json"))
65
+ end
66
+
67
+ it "should get the correct item" do
68
+ test = @client.geography_type_name_state({:geography_type => 'county', :state_fips => '17', :geography_name => 'mar'})
69
+ a_get("geography/state/17/county/name/mar?format=json&maxresults=100&all=&callback=").should have_been_made
70
+ test.results[0].geographyId.should == "17121"
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,34 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Bip do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".provider_all" do
10
+ before do
11
+ stub_get("provider?format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("providers_all.json"))
13
+ end
14
+
15
+ it "should return correct item" do
16
+ test = @client.provider_all()
17
+ a_get("provider?format=json&callback=").should have_been_made
18
+ test.results[0].holdingCompanyNumber.should == "131413"
19
+ end
20
+ end
21
+
22
+ describe ".provider_name" do
23
+ before do
24
+ stub_get("provider/name/alb?format=json&all=&maxresults=20&callback=").
25
+ to_return(:status => 200, :body => fixture("providers_name.json"))
26
+ end
27
+
28
+ it "should return correct item" do
29
+ test = @client.provider_name({:name => 'alb'})
30
+ a_get("provider/name/alb?format=json&all=&maxresults=20&callback=").should have_been_made
31
+ test.results[0].holdingCompanyNumber.should == '130031'
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,61 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::SpeedTest do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".speed_test_geo_type_id" do
10
+ before do
11
+ stub_get("speedtest/state/ids/01,02?format=json&speedtesttype=&callback=").
12
+ to_return(:status => 200, :body => fixture("speed_geo_type_id.json"))
13
+ end
14
+
15
+ it "should get the correct item" do
16
+ test = @client.speed_test_geo_type_id({:geography_type => 'state', :geography_ids => ['01', '02']})
17
+ a_get("speedtest/state/ids/01,02?format=json&speedtesttype=&callback=").should have_been_made
18
+ test.results[0].geographyId.should == "01"
19
+ end
20
+ end
21
+
22
+ describe ".speed_test_geo_type_name" do
23
+ before do
24
+ stub_get("speedtest/state/names/alabama,arizona?format=json&speedtesttype=&callback=").
25
+ to_return(:status => 200, :body => fixture("speed_geo_type_id.json"))
26
+ end
27
+
28
+ it "should get the correct item" do
29
+ test = @client.speed_test_geo_type_name({:geography_type => 'state', :geography_names => ['alabama', 'arizona']})
30
+ a_get("speedtest/state/names/alabama,arizona?format=json&speedtesttype=&callback=").should have_been_made
31
+ test.results[0].geographyId.should == "01"
32
+ end
33
+ end
34
+
35
+ describe ".speed_test_quartile" do
36
+ before do
37
+ stub_get("speedtest/state/quartile?format=json&speedtesttype=&callback=").
38
+ to_return(:status => 200, :body => fixture("speed_quartile_type.json"))
39
+ end
40
+
41
+ it "should get the correct item" do
42
+ test = @client.speed_test_quartile({:geography_type => 'state'})
43
+ a_get("speedtest/state/quartile?format=json&speedtesttype=&callback=").should have_been_made
44
+ test.results.minimumLowerQuartileDownload.should == 0.00781
45
+ end
46
+ end
47
+
48
+ describe ".speed_test_nation" do
49
+ before do
50
+ stub_get("speedtest/nation?format=json&speedtesttype=&callback=").
51
+ to_return(:status => 200, :body => fixture("speed_nation.json"))
52
+ end
53
+
54
+ it "should get the correct item" do
55
+ test = @client.speed_test_nation()
56
+ a_get("speedtest/nation?format=json&speedtesttype=&callback=").should have_been_made
57
+ test.results[0].geographyId.should == "99"
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ describe BroadbandMap::Client::Summary do
4
+
5
+ before do
6
+ @client = BroadbandMap::Client.new
7
+ end
8
+
9
+ describe ".summary_geo" do
10
+ before do
11
+ stub_get("analyze/fall2010/summary/population/state/ids/10?format=json&callback=").
12
+ to_return(:status => 200, :body => fixture("summary_geo.json"))
13
+ end
14
+
15
+ it "should return the correct item" do
16
+ test = @client.summary_geo({:data_version => 'fall2010', :census_metric_type => 'population', :geography_type => 'state', :geography_ids => ['10']})
17
+ a_get("analyze/fall2010/summary/population/state/ids/10?format=json&callback=").should have_been_made
18
+ test.results[0].geographyId.should == "10"
19
+ end
20
+ end
21
+
22
+ describe ".summary_nation" do
23
+ before do
24
+ stub_get("analyze/fall2010/summary/population/nation?format=json&callback=").
25
+ to_return(:status => 200, :body => fixture("summary_nation.json"))
26
+ end
27
+
28
+ it "should return the correct item" do
29
+ test = @client.summary_nation(:data_version => 'fall2010', :census_metric_type => 'population')
30
+ a_get("analyze/fall2010/summary/population/nation?format=json&callback=").should have_been_made
31
+ test.results[0].geographyId.should == '99'
32
+ end
33
+ end
34
+
35
+
36
+ end