netroots-ruby-votesmart 0.2.0 → 0.2.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.
data/VERSION.yml
CHANGED
data/lib/vote_smart/common.rb
CHANGED
@@ -41,6 +41,11 @@ module VoteSmart
|
|
41
41
|
response || {}
|
42
42
|
end
|
43
43
|
|
44
|
+
def self.response_child_array response, *children
|
45
|
+
child = response_child response, *children
|
46
|
+
child.kind_of?(Array) ? child : [child]
|
47
|
+
end
|
48
|
+
|
44
49
|
def self.request(api_method, params = {})
|
45
50
|
url = construct_url api_method, params
|
46
51
|
|
data/lib/vote_smart/official.rb
CHANGED
@@ -3,7 +3,7 @@ module VoteSmart
|
|
3
3
|
class Official < Common
|
4
4
|
|
5
5
|
attr_accessor :id, :first_name, :nick_name, :middle_name, :last_name, :suffix, :title,
|
6
|
-
:election_parties, :office_parties, :district_id, :district_name, :state_id
|
6
|
+
:election_parties, :office_parties, :district_id, :district_name, :state_id, :district
|
7
7
|
|
8
8
|
set_attribute_map "candidateId" => :id, "firstName" => :first_name, "nickName" => :nick_name,
|
9
9
|
"middleName" => :middle_name, "lastName" => :last_name, "suffix" => :suffix,
|
@@ -11,7 +11,7 @@ module VoteSmart
|
|
11
11
|
"officeDistrictName" => :district_name, "officeStateId" => :state_id
|
12
12
|
|
13
13
|
def offices
|
14
|
-
Official.
|
14
|
+
Official.response_child_array(Address.get_office(self.id), "address", "office").collect {|office| CandidateOffice.new(office) }
|
15
15
|
end
|
16
16
|
|
17
17
|
def inspect
|
@@ -19,7 +19,9 @@ module VoteSmart
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.find_by_district district
|
22
|
-
find_by_district_id district.id
|
22
|
+
official = find_by_district_id district.id
|
23
|
+
official.district = district if official
|
24
|
+
official
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.find_by_district_id district_id
|
@@ -0,0 +1 @@
|
|
1
|
+
{"address":{"generalInfo":{"title":"Project Vote Smart - Campaign Address - Lois Court","linkBack":"http:\/\/votesmart.org\/bio.php?can_id=106446"},"candidate":{"lastName":"Court","title":"Rep.","nickName":"","middleName":"","firstName":"Lois","suffix":""},"office":{"notes":{"contactName":"","contactTitle":""},"phone":{"ttyd":"","tollFree":"","fax1":"","fax2":"","phone1":"303-866-2967","phone2":""},"address":{"city":"Denver","zip":"80203","type":"Capitol","street":"Colorado State Capitol\n200 East Colfax","state":"CO"}}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"candidateList":{"generalInfo":{"title":"Project Vote Smart - Search Candidates","linkBack":"http:\/\/votesmart.org\/"},"candidate":{"electionDistrictName":"","lastName":"Court","candidateId":"106446","title":"Representative","officeDistrictName":"","nickName":"","electionYear":"","electionStatus":"","electionParties":"Democratic","middleName":"","firstName":"Lois","electionDistrictId":"","officeParties":"Democratic","electionStateId":"","officeStateId":"CO","officeDistrictId":"21397","suffix":""}}}
|
@@ -12,7 +12,7 @@ module VoteSmart
|
|
12
12
|
it_should_find :item => {:last_name => "Isakson", :id => "1721"}
|
13
13
|
end
|
14
14
|
|
15
|
-
describe "offices" do
|
15
|
+
describe "multiple offices" do
|
16
16
|
|
17
17
|
def do_find
|
18
18
|
@official = Official.find_by_district_id("20451")
|
@@ -23,6 +23,16 @@ module VoteSmart
|
|
23
23
|
:last => {:address => {:type => "Washington, D.C."}}
|
24
24
|
end
|
25
25
|
|
26
|
+
describe "one office" do
|
27
|
+
|
28
|
+
def do_find
|
29
|
+
@official = Official.find_by_district_id("21397")
|
30
|
+
@official.offices
|
31
|
+
end
|
32
|
+
|
33
|
+
it_should_find :count => 1, :first => {:address => {:type => "Capitol"}}
|
34
|
+
end
|
35
|
+
|
26
36
|
describe "find by address" do
|
27
37
|
|
28
38
|
before :each do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netroots-ruby-votesmart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Cunning
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/vote_smart/state.rb
|
53
53
|
- lib/vote_smart/vote.rb
|
54
54
|
- spec/responses
|
55
|
+
- spec/responses/Address.get_office.106446.js
|
55
56
|
- spec/responses/Address.get_office.1721.js
|
56
57
|
- spec/responses/authorization_failed.js
|
57
58
|
- spec/responses/District.get_by_office_state.7.GA.js
|
@@ -64,6 +65,7 @@ files:
|
|
64
65
|
- spec/responses/Office.get_types.js
|
65
66
|
- spec/responses/Official.get_by_district.20451.js
|
66
67
|
- spec/responses/Official.get_by_district.20689.js
|
68
|
+
- spec/responses/Official.get_by_district.21397.js
|
67
69
|
- spec/responses/Official.get_by_district.21946.js
|
68
70
|
- spec/responses/Official.get_by_office_state.12.GA.js
|
69
71
|
- spec/responses/Official.get_by_office_state.13.GA.js
|