technicalpickles-daywalker 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ After registering, you will receive an email prompting you to activate the API k
26
26
  pp Daywalker::District.find_by_zip('27511')
27
27
  pp Daywalker::District.find_by_latlng(40.739157, -73.990929)
28
28
  pp Daywalker::Legislator.find(:one, :state => 'NY', :district => 4)
29
- pp Daywalker::Legislator.find_all_by_state_and_senator('NY', :senator)
29
+ pp Daywalker::Legislator.find_all_by_state_and_title('NY', :senator)
30
30
 
31
31
 
32
32
  == FAQ
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 0
3
+ :patch: 1
4
4
  :major: 0
@@ -8,7 +8,12 @@ module Daywalker
8
8
  def self.handle_response(response)
9
9
  case response.code.to_i
10
10
  when 403 then raise BadApiKey
11
- when 200 then parse(response.body)
11
+ when 200
12
+ begin
13
+ parse(response.body)
14
+ rescue => e
15
+ raise "Error while parsing #{response.body.inspect} => #{e.inspect}"
16
+ end
12
17
 
13
18
  when 400 then handle_bad_request(response.body)
14
19
  else raise "Don't know how to handle code #{response.code.inspect}"
@@ -91,8 +91,8 @@ module Daywalker
91
91
  # Daywalker::Legislator.find_all_by_state_and_senator('NY', :senator)
92
92
  def self.find(sym, conditions)
93
93
  url = case sym
94
- when :one then '/legislators.get'
95
- when :all then '/legislators.getList'
94
+ when :one then '/legislators.get.xml'
95
+ when :all then '/legislators.getList.xml'
96
96
  else raise ArgumentError, "invalid argument #{sym.inspect}, only :one and :all are allowed"
97
97
  end
98
98
 
@@ -55,7 +55,7 @@ describe Daywalker::Legislator do
55
55
  describe 'by state and district, with one result,' do
56
56
  describe 'happy path' do
57
57
  before do
58
- register_uri_with_response 'legislators.get?apikey=redacted&state=NY&district=4', 'legislators_find_by_ny_district_4.xml'
58
+ register_uri_with_response 'legislators.get.xml?apikey=redacted&state=NY&district=4', 'legislators_find_by_ny_district_4.xml'
59
59
  @legislator = Daywalker::Legislator.find(:one, :state => 'NY', :district => 4)
60
60
  end
61
61
 
@@ -67,7 +67,7 @@ describe Daywalker::Legislator do
67
67
 
68
68
  describe 'by state and district, with bad API key' do
69
69
  before do
70
- register_uri_with_response 'legislators.get?apikey=redacted&state=NY&district=4', 'legislators_find_by_ny_district_4_bad_api.xml'
70
+ register_uri_with_response 'legislators.get.xml?apikey=redacted&state=NY&district=4', 'legislators_find_by_ny_district_4_bad_api.xml'
71
71
  end
72
72
 
73
73
  it 'should raise a missing parameter error for zip' do
@@ -84,7 +84,7 @@ describe Daywalker::Legislator do
84
84
  describe 'happy path' do
85
85
  before do
86
86
  # curl -i "http://services.sunlightlabs.com/api/legislators.getList.xml?state=NY&title=Sen&apikey=redacted" > legislators_find_ny_senators.xml
87
- register_uri_with_response 'legislators.getList?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators.xml'
87
+ register_uri_with_response 'legislators.getList.xml?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators.xml'
88
88
  @legislators = Daywalker::Legislator.find(:all, :state => 'NY', :title => :senator)
89
89
  end
90
90
 
@@ -95,7 +95,7 @@ describe Daywalker::Legislator do
95
95
 
96
96
  describe 'with bad API key' do
97
97
  before do
98
- register_uri_with_response 'legislators.getList?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators_bad_api.xml'
98
+ register_uri_with_response 'legislators.getList.xml?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators_bad_api.xml'
99
99
  end
100
100
 
101
101
  it 'should raise BadApiKey error' do
@@ -119,7 +119,7 @@ describe Daywalker::Legislator do
119
119
  # TODO switch this to mocking
120
120
  describe 'dynamic finder find_all_by_state_and_title' do
121
121
  before do
122
- register_uri_with_response 'legislators.getList?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators.xml'
122
+ register_uri_with_response 'legislators.getList.xml?state=NY&apikey=redacted&title=Sen', 'legislators_find_ny_senators.xml'
123
123
 
124
124
  @legislators = Daywalker::Legislator.find_all_by_state_and_title('NY', :senator)
125
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: technicalpickles-daywalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols