pyr 0.2.5 → 0.2.6

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: 118839e5f2a9f5725eebc66f603f338383ff8e82
4
- data.tar.gz: 3879eb7384f392f3e5be09b7fe4161e7e21dd2ca
3
+ metadata.gz: ea77ac4b5fe041319a0edff8e173cb200ea4f4f0
4
+ data.tar.gz: 8a988b40f80559222bce3a60697c96c5272b770f
5
5
  SHA512:
6
- metadata.gz: d121f0caaea055c6fe8a09193702b2060d359e964453d85ae94a6c8c85c967109adbc3710d1c72fc13718ba92ef7313e1e81ebf3e484d0b09be0de583321ed73
7
- data.tar.gz: 79eef9001f2530c13f9c6104123f0858c24583e803829b80b2a448d4f271b9b30165ff3646427b7433de202cc9a67a46aa44b8092def94f7081b56c0dccec711
6
+ metadata.gz: 1f74b966917b39d84d78d4bfa85f0019aafab98d8bac66eb558687fca72ad6ce68ed23b20de280178a83611839b5e3dec29ad726adcb211772f1acc1c2c48917
7
+ data.tar.gz: 3dbb8631337eb18f10010626a9e788961d62c22f64c1926857b0f05652f14a942cf2a6eeba7414cc4c3c18d03b5e349626801c04aabca9279cc1be595311dbbc
data/README.md CHANGED
@@ -28,20 +28,20 @@ response = PYR.call :reps do |r|
28
28
  r.long = -72.5778415
29
29
  end
30
30
 
31
- response.uri
32
- => "https://phone-your-rep.herokuapp.com/api/beta/reps?lat=44.5588028&long=-72.5778415&"
31
+ response.path
32
+ => "reps?lat=44.5588028&long=-72.5778415"
33
33
 
34
34
  ## or ##
35
35
 
36
36
  response = PYR.call(:reps) { |r| r.address = 'Vermont' }
37
37
 
38
- response.uri
39
- => "https://phone-your-rep.herokuapp.com/api/beta/reps?address=Vermont&"
38
+ response.path
39
+ => "reps?address=Vermont"
40
40
 
41
41
  response.code
42
42
  => 200
43
43
 
44
- response.message
44
+ response.reason_phrase
45
45
  => "OK"
46
46
 
47
47
  response.headers
@@ -102,6 +102,10 @@ office = PYR.call(:reps, 'S000033').objects.first.office_locations.district.firs
102
102
  # Pass in the object itself as the param to PYR.call
103
103
  office.office_id == PYR.call(office).objects.first.office_id
104
104
  => true
105
+
106
+ # Or use #call on the object itself
107
+ office.office_id == office.call.objects.first.office_id
108
+ => true
105
109
  ```
106
110
 
107
111
  ### Querying by Phone Your Rep URI
data/lib/pyr/response.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module PYR
4
4
  # The object returned by a request call to the API.
5
5
  class Response
6
- attr_reader :body, :uri, :code, :reason_phrase, :headers, :objects, :controller
6
+ attr_reader :body, :path, :code, :reason_phrase, :headers, :objects, :controller
7
7
 
8
8
  def initialize(base_url: nil, resource: nil, response_object: nil)
9
9
  assign_url_and_controller(base_url, resource, response_object)
@@ -14,18 +14,18 @@ module PYR
14
14
  def assign_url_and_controller(base_url, resource, response_object)
15
15
  if resource
16
16
  @controller = resource.controller
17
- @uri = resource.to_s
17
+ @path = resource.to_s
18
18
  elsif base_url
19
19
  @controller = base_url.sub!(API_BASE_URI, '').split('/').first
20
- @uri = base_url
20
+ @path = base_url
21
21
  elsif response_object
22
22
  @controller = response_object.controller
23
- @uri = response_object.self.sub(API_BASE_URI, '')
23
+ @path = response_object.self.sub(API_BASE_URI, '')
24
24
  end
25
25
  end
26
26
 
27
27
  def fetch_and_parse_payload
28
- response = API_CONN.get uri
28
+ response = API_CONN.get path
29
29
  @body = response.body
30
30
  @code = response.status
31
31
  @reason_phrase = response.reason_phrase
data/lib/pyr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PYR
4
- VERSION = '0.2.5' # :nodoc:
4
+ VERSION = '0.2.6' # :nodoc:
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg