get_your_rep 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c39c75a50253c1577d10857f573ecaa22d15db5
4
- data.tar.gz: 864d2b90e058ced10c772a335b8955267e1c72b9
3
+ metadata.gz: b5f769e58bb91ca979e0f229c3dadba02b7f0c34
4
+ data.tar.gz: b424ff7f61fee46fbea66a6276ffd862191101b6
5
5
  SHA512:
6
- metadata.gz: c3953b26969bd0c12c19e30c114c1d7c2110dba4800d7370b5907a61b31d550720ab8a3c73774ddafa5bf07a57cbfad62601d2de7a3cedd55442550b6145104a
7
- data.tar.gz: 682ed118c5cf9e013f2bcfe525a113b5946cbd4aeebf005d9402e0bf08b02e0125fde00a01c2ee564860681f8ac4a98bb62c559ad3a91b77ce5be3aab64fcbd0
6
+ metadata.gz: '0488d142b46f8d9ef184dfad2584ef24b024626beda353eb953ea40c3694a510f45505617d350f0d4c6f9082b8d9eba314f05a52b47cfe86b4c583cef480b1a9'
7
+ data.tar.gz: 5ae6e4bcc469611ea104fe964488a66197e1ebab08589e0eac86501301186c1cbeb4df658abf235283e6339f6c613b50a1fa1e86261b85c18e1acf8168ed19c1
@@ -11,10 +11,7 @@ module GetYourRep
11
11
  @coordinates = get_coordinates(address)
12
12
  @response = get_rep
13
13
 
14
- if @response.empty?
15
- puts 'Could not find your rep. Your location search might be too broad, try refining it.'
16
- return GetYourRep::Delegation.new
17
- elsif @response.first['error']
14
+ if @response.empty? || @response.is_a?(String) || @response.first['error']
18
15
  puts 'Error message received. Confirm and re-enter your address and check your parameters.'
19
16
  puts @response
20
17
  return GetYourRep::Delegation.new
@@ -34,10 +31,14 @@ module GetYourRep
34
31
 
35
32
  # Sets parameters for and executes Open States API request.
36
33
  def self.get_rep
37
- lat = @coordinates.first
38
- long = @coordinates.last
39
- url = "http://openstates.org/api/v1/legislators/geo/?lat=#{lat}&long=#{long}"
40
- HTTParty.get(url).parsed_response
34
+ if @coordinates
35
+ lat = @coordinates.first
36
+ long = @coordinates.last
37
+ url = "http://openstates.org/api/v1/legislators/geo/?lat=#{lat}&long=#{long}"
38
+ HTTParty.get(url).parsed_response
39
+ else
40
+ []
41
+ end
41
42
  end
42
43
 
43
44
  # Parses the JSON response and assembles it into a Delegation object.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_your_rep
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
  - msimonborg