pyr 0.3.3 → 0.3.4

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: 4208acf8b6be9c9d1b0d025ee817610501f8abf2
4
- data.tar.gz: 880b3b112c64501d24859f04f74980f2366aa3cd
3
+ metadata.gz: 38e39c4009939ac2aeebaa972f147bf2d8cc9a75
4
+ data.tar.gz: 22fcfbe77d163fba7efdc6a9079ef9b7d0dda0f3
5
5
  SHA512:
6
- metadata.gz: 8e3feeffe64379121dafa3dd21aa38eea4abb74c9c7c41771b3b561ebdf8a9e566fa9dc867403d465c07bcdba5cd746b918b49e74abb193ec2c96bbaacc3e442
7
- data.tar.gz: b542e60905a65a8071f85860ac08833adf5ec604ab70ec67221fef8847fab14496a0372dbd9823b91589803f7e2aa4babaac84ea2c849c0467dfaa425313737e
6
+ metadata.gz: 4f93053da22ae238b21e805c366fd10eb672da945600bbac528ae92b7eb1a53e617027ea6c3cdddd321690260a3c22a3458828353cc84d73a0b1e7ff6021c91e
7
+ data.tar.gz: 78a38d8a378ca65c0291fd61832a7cdb5262c8db8a9c789a8c5e05de67e0d614f29642afee444ac1b093d6b02c7609eae9f96b2cfe738abfe8777400ec761600
data/README.md CHANGED
@@ -51,7 +51,7 @@ response.body
51
51
  => { ... }
52
52
 
53
53
  reps = response.objects
54
- => #<PYR::RepRelation [#<PYR::Rep id: 1, ...>]>
54
+ => #<PYR::RepRelation [#<PYR::Rep ...>]>
55
55
 
56
56
  reps.first.official_full
57
57
  => "Bernard Sanders"
@@ -84,10 +84,10 @@ reps.democratic.senators.count
84
84
  => 46
85
85
 
86
86
  reps.where official_full: 'Bernard Sanders'
87
- => #<PYR::RepRelation [#<PYR::Rep id: 428, self: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", state: #<PYR::State:0x007fdb11d42580>, district: nil, active: true, bioguide_id: "S000033", official_full: "Bernard Sanders", role: "United States Senator", party: "Independent", senate_class: "01", last: "Sanders", first: "Bernard", middle: nil, nickname: "Bernie", suffix: nil, contact_form: "http://www.sanders.senate.gov/contact/", url: "https://www.sanders.senate.gov", photo: "https://phoneyourrep.github.io/images/congress/450x550/S000033.jpg", twitter: "SenSanders", facebook: "senatorsanders", youtube: "senatorsanders", instagram: nil, googleplus: nil, twitter_id: "29442313", facebook_id: nil, youtube_id: "UCD_DaKNac0Ta-2PeHuoQ1uA", instagram_id: nil, office_locations_count: 3>]>
87
+ => #<PYR::RepRelation [#<PYR::Rep self: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", state: #<PYR::State:0x007fdb11d42580>, district: nil, active: true, bioguide_id: "S000033", official_full: "Bernard Sanders", role: "United States Senator", party: "Independent", senate_class: "01", last: "Sanders", first: "Bernard", middle: nil, nickname: "Bernie", suffix: nil, contact_form: "http://www.sanders.senate.gov/contact/", url: "https://www.sanders.senate.gov", photo: "https://phoneyourrep.github.io/images/congress/450x550/S000033.jpg", twitter: "SenSanders", facebook: "senatorsanders", youtube: "senatorsanders", instagram: nil, googleplus: nil, twitter_id: "29442313", facebook_id: nil, youtube_id: "UCD_DaKNac0Ta-2PeHuoQ1uA", instagram_id: nil, office_locations_count: 3>]>
88
88
 
89
89
  reps.independent.where { |r| r.state.name == 'Vermont' }.first
90
- => #<PYR::Rep id: 428, self: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", state: #<PYR::State:0x007fdb11d42580>, district: nil, active: true, bioguide_id: "S000033", official_full: "Bernard Sanders", role: "United States Senator", party: "Independent", senate_class: "01", last: "Sanders", first: "Bernard", middle: nil, nickname: "Bernie", suffix: nil, contact_form: "http://www.sanders.senate.gov/contact/", url: "https://www.sanders.senate.gov", photo: "https://phoneyourrep.github.io/images/congress/450x550/S000033.jpg", twitter: "SenSanders", facebook: "senatorsanders", youtube: "senatorsanders", instagram: nil, googleplus: nil, twitter_id: "29442313", facebook_id: nil, youtube_id: "UCD_DaKNac0Ta-2PeHuoQ1uA", instagram_id: nil, office_locations_count: 3>
90
+ => #<PYR::Rep self: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", state: #<PYR::State:0x007fdb11d42580>, district: nil, active: true, bioguide_id: "S000033", official_full: "Bernard Sanders", role: "United States Senator", party: "Independent", senate_class: "01", last: "Sanders", first: "Bernard", middle: nil, nickname: "Bernie", suffix: nil, contact_form: "http://www.sanders.senate.gov/contact/", url: "https://www.sanders.senate.gov", photo: "https://phoneyourrep.github.io/images/congress/450x550/S000033.jpg", twitter: "SenSanders", facebook: "senatorsanders", youtube: "senatorsanders", instagram: nil, googleplus: nil, twitter_id: "29442313", facebook_id: nil, youtube_id: "UCD_DaKNac0Ta-2PeHuoQ1uA", instagram_id: nil, office_locations_count: 3>
91
91
  ```
92
92
 
93
93
  ### Querying by ID
@@ -99,14 +99,14 @@ bernie = PYR.call(:reps, 'S000033').objects.first
99
99
  ### Querying by Object
100
100
  ```ruby
101
101
  office = PYR.reps('S000033').objects.first.office_locations.district.first
102
- => #<PYR::OfficeLocation id: 1, city: "Burlington", rep: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", active: true, office_id: "S000033-burlington", bioguide_id: "S000033", office_type: "district", distance: nil, building: "", address: "1 Church St.", suite: "3rd Floor", city: "Burlington", state: "VT", zip: "05401", phone: "802-862-0697", fax: "802-860-6370", hours: "", latitude: 44.4802081, longitude: -73.2130702, v_card_link: "https://phone-your-rep.herokuapp.com/v_cards/S000033-burlington", downloads: 14, qr_code_link: "https://s3.amazonaws.com/phone-your-rep-images/S000033_burlington.png">
102
+ => #<PYR::OfficeLocation city: "Burlington", rep: "https://phone-your-rep.herokuapp.com/api/beta/reps/S000033", active: true, office_id: "S000033-burlington", bioguide_id: "S000033", office_type: "district", distance: nil, building: "", address: "1 Church St.", suite: "3rd Floor", city: "Burlington", state: "VT", zip: "05401", phone: "802-862-0697", fax: "802-860-6370", hours: "", latitude: 44.4802081, longitude: -73.2130702, v_card_link: "https://phone-your-rep.herokuapp.com/v_cards/S000033-burlington", downloads: 14, qr_code_link: "https://s3.amazonaws.com/phone-your-rep-images/S000033_burlington.png">
103
103
 
104
104
  # Pass in the object itself as the param to PYR.call
105
- office.office_id == PYR.call(office).objects.first.office_id
105
+ office == PYR.call(office).objects.first
106
106
  => true
107
107
 
108
108
  # Or use #call on the object itself
109
- office.office_id == office.call.objects.first.office_id
109
+ office == office.call.objects.first
110
110
  => true
111
111
  ```
112
112
 
@@ -119,7 +119,7 @@ uri = rep.district.self
119
119
 
120
120
  district = PYR.call(uri).objects.first
121
121
 
122
- => #<PYR::District id: 2, self: "https://phone-your-rep.herokuapp.com/api/beta/districts/5000", full_code: "5000", code: "00", state_code: "50">
122
+ => #<PYR::District self: "https://phone-your-rep.herokuapp.com/api/beta/districts/5000", full_code: "5000", code: "00", state_code: "50">
123
123
  ```
124
124
 
125
125
  ## Development
data/lib/pyr.rb CHANGED
@@ -69,8 +69,10 @@ require 'pyr/version'
69
69
  #
70
70
  # PYR.reps('S000033').objects.first.official_full # => "Bernard Sanders"
71
71
  #
72
- # Any of the following resources can be passed as the first argument to `PYR.call`,
73
- # or called as a class method directly to the PYR module, as in the above example.
72
+ # Any of the following resources can be passed as the first argument to
73
+ # `PYR.call`, or called as a class method directly to the PYR module,
74
+ # as in the above example.
75
+ #
74
76
  # Both options yield a resource to the block for setting params.
75
77
  # :reps, :office_locations, :states, :districts, :zctas
76
78
  #
@@ -115,12 +117,14 @@ module PYR
115
117
  #
116
118
  # Arguments can be:
117
119
  #
118
- # a particular PYR::ResponseObject itself to query that object's 'self' url;
120
+ # * a particular PYR::ResponseObject itself to query that object's 'self' url;
121
+ #
122
+ # * a valid Phone Your Rep URI beginning with the API_BASE_URI string value;
119
123
  #
120
- # a valid Phone Your Rep URI beginning with the API_BASE_URI string value;
124
+ # * or, perhaps most commonly, a resource name (String or Symbol) with
125
+ # optional ID(String).
121
126
  #
122
- # or, perhaps most commonly, a resource name (String or Symbol) with
123
- # optional ID(String).
127
+ # @return [Response]
124
128
  def self.call(resource, id = nil, &config_block)
125
129
  if resource.is_a?(ResponseObject)
126
130
  request_object = { response_object: resource }
@@ -136,35 +140,50 @@ module PYR
136
140
 
137
141
  # Call the :reps resource.
138
142
  #
143
+ # @example
139
144
  # PYR.reps { |r| r.address = '123 Main St, USA 12345' }
145
+ #
146
+ # @return [PYR::Response]
140
147
  def self.reps(id = nil, &config_block)
141
148
  call(:reps, id, &config_block)
142
149
  end
143
150
 
144
151
  # Call the :office_locations resource.
145
152
  #
153
+ # @example
146
154
  # PYR.office_locations { |r| r.address = '123 Main St, USA 12345' }
147
- def self.office_locations(id=nil, &config_block)
155
+ #
156
+ # @return [PYR::Response]
157
+ def self.office_locations(id = nil, &config_block)
148
158
  call(:office_locations, id, &config_block)
149
159
  end
150
160
 
151
161
  # Call the :zctas resource.
152
162
  #
163
+ # @example
153
164
  # PYR.zctas('90026') { |r| r.reps = true }
165
+ #
166
+ # @return [PYR::Response]
154
167
  def self.zctas(id = nil, &config_block)
155
168
  call(:zctas, id, &config_block)
156
169
  end
157
170
 
158
171
  # Call the :states resource.
159
172
  #
173
+ # @example
160
174
  # PYR.states '50'
175
+ #
176
+ # @return [PYR::Response]
161
177
  def self.states(id = nil, &config_block)
162
178
  call(:states, id, &config_block)
163
179
  end
164
180
 
165
181
  # Call the :districts resource.
166
182
  #
183
+ # @example
167
184
  # PYR.districts '5000'
185
+ #
186
+ # @return [PYR::Response]
168
187
  def self.districts(id = nil, &config_block)
169
188
  call(:districts, id, &config_block)
170
189
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  module PYR
5
- VERSION = '0.3.3' # :nodoc:
4
+ VERSION = '0.3.4' # :nodoc:
6
5
  end
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.required_ruby_version = '>= 2.3.0'
38
38
  spec.add_dependency 'faraday', '~> 0.12.0'
39
39
  spec.add_dependency 'faraday_middleware', '~> 0.11.0'
40
- spec.add_dependency 'lazy_record', '~> 0.4.0'
40
+ spec.add_dependency 'lazy_record', '~> 0.6.0'
41
41
  spec.add_development_dependency 'bundler', '~> 1.14'
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.4.0
47
+ version: 0.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.4.0
54
+ version: 0.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement