fec_results 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +6 -6
- data/api/2000/congress/results.json +2668 -0
- data/api/2000/president/general_election_results.json +449 -0
- data/api/2000/president/popular_vote_summary.json +1 -0
- data/api/2000/president/primary_election_results.json +498 -0
- data/api/2000/president/primary_party_summary.json +1 -0
- data/api/2000/president/state_electoral_and_popular_vote_summary.json +1 -0
- data/api/2000/summary/chamber_votes_by_party.json +55 -0
- data/api/2000/summary/congressional_votes_by_election.json +55 -0
- data/api/2000/summary/general_election_votes.json +55 -0
- data/api/2000/summary/general_election_votes_by_party.json +55 -0
- data/api/2000/summary/party_labels.json +76 -0
- data/api/2002/congress/results.json +2401 -0
- data/api/2002/summary/chamber_votes_by_party.json +54 -0
- data/api/2002/summary/congressional_votes_by_election.json +54 -0
- data/api/2002/summary/general_election_votes.json +1 -0
- data/api/2002/summary/general_election_votes_by_party.json +1 -0
- data/api/2002/summary/party_labels.json +54 -0
- data/api/2004/congress/results.json +2309 -0
- data/api/2004/president/general_election_results.json +430 -0
- data/api/2004/president/popular_vote_summary.json +19 -0
- data/api/2004/president/primary_election_results.json +498 -0
- data/api/2004/president/primary_party_summary.json +7 -0
- data/api/2004/president/state_electoral_and_popular_vote_summary.json +56 -0
- data/api/2004/summary/chamber_votes_by_party.json +55 -0
- data/api/2004/summary/congressional_votes_by_election.json +55 -0
- data/api/2004/summary/general_election_votes.json +55 -0
- data/api/2004/summary/general_election_votes_by_party.json +55 -0
- data/api/2004/summary/party_labels.json +85 -0
- data/api/2006/congress/results.json +2377 -0
- data/api/2006/summary/chamber_votes_by_party.json +54 -0
- data/api/2006/summary/congressional_votes_by_election.json +54 -0
- data/api/2006/summary/general_election_votes.json +54 -0
- data/api/2006/summary/general_election_votes_by_party.json +54 -0
- data/api/2006/summary/party_labels.json +67 -0
- data/api/2008/congress/results.json +2401 -0
- data/api/2008/president/general_election_results.json +485 -0
- data/api/2008/president/popular_vote_summary.json +26 -0
- data/api/2008/president/primary_election_results.json +720 -0
- data/api/2008/president/primary_party_summary.json +11 -0
- data/api/2008/president/state_electoral_and_popular_vote_summary.json +51 -0
- data/api/2008/summary/chamber_votes_by_party.json +56 -0
- data/api/2008/summary/congressional_votes_by_election.json +56 -0
- data/api/2008/summary/general_election_votes.json +56 -0
- data/api/2008/summary/general_election_votes_by_party.json +56 -0
- data/api/2008/summary/party_labels.json +100 -0
- data/api/2010/congress/results.json +3300 -0
- data/api/2010/summary/chamber_votes_by_party.json +55 -0
- data/api/2010/summary/congressional_votes_by_election.json +55 -0
- data/api/2010/summary/general_election_votes.json +55 -0
- data/api/2010/summary/general_election_votes_by_party.json +55 -0
- data/api/2010/summary/party_labels.json +82 -0
- data/api/2012/congress/results.json +3081 -0
- data/api/2012/president/general_election_results.json +484 -0
- data/api/2012/president/popular_vote_summary.json +30 -0
- data/api/2012/president/primary_election_results.json +453 -0
- data/api/2012/president/primary_party_summary.json +9 -0
- data/api/2012/president/state_electoral_and_popular_vote_summary.json +51 -0
- data/api/2012/summary/chamber_votes_by_party.json +56 -0
- data/api/2012/summary/congressional_votes_by_election.json +56 -0
- data/api/2012/summary/general_election_votes.json +56 -0
- data/api/2012/summary/general_election_votes_by_party.json +56 -0
- data/api/2012/summary/party_labels.json +112 -0
- data/fec_results.gemspec +1 -0
- data/images/bg_hr.png +0 -0
- data/images/blacktocat.png +0 -0
- data/images/icon_download.png +0 -0
- data/images/sprite_download.png +0 -0
- data/index.html +159 -0
- data/javascripts/main.js +1 -0
- data/lib/fec_results.rb +3 -0
- data/lib/fec_results/congress.rb +56 -17
- data/lib/fec_results/president.rb +48 -48
- data/lib/fec_results/result.rb +2 -2
- data/lib/fec_results/summary.rb +120 -98
- data/lib/fec_results/version.rb +1 -1
- data/params.json +1 -0
- data/stylesheets/pygment_trac.css +70 -0
- data/stylesheets/stylesheet.css +419 -0
- metadata +100 -14
data/lib/fec_results/result.rb
CHANGED
@@ -20,7 +20,7 @@ module FecResults
|
|
20
20
|
self.new :year => r[:year],
|
21
21
|
:date => r[:date],
|
22
22
|
:chamber => r[:chamber],
|
23
|
-
:
|
23
|
+
state: r[:state],
|
24
24
|
:district => r[:district],
|
25
25
|
:fec_id => r[:fec_id],
|
26
26
|
:incumbent => r[:incumbent],
|
@@ -28,7 +28,7 @@ module FecResults
|
|
28
28
|
:candidate_first => r[:candidate_first],
|
29
29
|
:candidate_suffix => r[:candidate_suffix],
|
30
30
|
:candidate_name => r[:candidate_name],
|
31
|
-
:
|
31
|
+
party: r[:party],
|
32
32
|
:primary_votes => r[:primary_votes],
|
33
33
|
:primary_pct => r[:primary_pct],
|
34
34
|
:primary_unopposed => r[:primary_unopposed],
|
data/lib/fec_results/summary.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
module FecResults
|
2
2
|
class Summary
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :year, :url
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(params={})
|
7
7
|
params.each_pair do |k,v|
|
8
8
|
instance_variable_set("@#{k}", v)
|
9
9
|
end
|
10
10
|
@url = FecResults::SUMMARY_URLS[year.to_s]
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def to_s
|
14
14
|
"#<FecResults::Summary:#{year.to_s}>"
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
#### main instance methods called with optional arguments to filter.
|
18
18
|
|
19
19
|
def general_election_votes(*args)
|
20
20
|
send("process_general_election_votes_#{year}", *args)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def general_election_votes_by_party(*args)
|
24
24
|
send("process_general_election_votes_by_party_#{year}", *args)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def congressional_votes_by_election(*args)
|
28
28
|
send("process_congressional_votes_by_election_#{year}", *args)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def chamber_votes_by_party(*args)
|
32
32
|
send("process_chamber_votes_by_party_#{year}", *args)
|
33
33
|
end
|
@@ -40,98 +40,111 @@ module FecResults
|
|
40
40
|
def party_labels
|
41
41
|
send("party_labels_#{year}")
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
#### cycle-specific methods called by main methods above
|
45
|
-
|
45
|
+
|
46
|
+
def process_general_election_votes_2014(options={})
|
47
|
+
results = []
|
48
|
+
t = RemoteTable.new(url, sheet: 'Table 1. GE Votes Cast', skip: 2)
|
49
|
+
rows = t.entries
|
50
|
+
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
51
|
+
rows.each do |row|
|
52
|
+
break if row['State'] == 'Total:'
|
53
|
+
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil: row['U.S. Senate Vote'].to_i
|
54
|
+
results << OpenStruct.new(state: row['State'], state_abbrev: row['State'], senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i)
|
55
|
+
end
|
56
|
+
results
|
57
|
+
end
|
58
|
+
|
46
59
|
def process_general_election_votes_2012(options={})
|
47
60
|
results = []
|
48
|
-
t = RemoteTable.new(url, :
|
61
|
+
t = RemoteTable.new(url, sheet: 'Table 3.GEVotes for Pres, H & S', skip: 3)
|
49
62
|
rows = t.entries
|
50
63
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
51
64
|
rows.each do |row|
|
52
65
|
break if row['State'] == 'Total:'
|
53
66
|
pres_votes = row['Presidential Vote'].to_i == 0 ? nil : row['Presidential Vote'].to_i
|
54
67
|
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil : row['U.S. Senate Vote'].to_i
|
55
|
-
results << OpenStruct.new(:
|
68
|
+
results << OpenStruct.new(state: row['State'], presidential_votes: pres_votes, senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i)
|
56
69
|
end
|
57
70
|
results
|
58
71
|
end
|
59
72
|
|
60
73
|
def process_general_election_votes_2010(options={})
|
61
74
|
results = []
|
62
|
-
t = RemoteTable.new(url, :
|
75
|
+
t = RemoteTable.new(url, sheet: 'Table 1. GE Votes Cast for Cong', skip: 2)
|
63
76
|
rows = t.entries
|
64
77
|
rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
|
65
78
|
rows.each do |row|
|
66
79
|
break if row['STATE ABBREVIATION'] == 'Total:'
|
67
80
|
sen_votes = row['U.S. SENATE VOTE'].to_i == 0 ? nil: row['U.S. SENATE VOTE'].to_i
|
68
|
-
results << OpenStruct.new(:
|
81
|
+
results << OpenStruct.new(state: row['STATE'], state_abbrev: row['STATE ABBREVIATION'], senate_votes: sen_votes, house_votes: row['U.S. HOUSE VOTE'].to_i)
|
69
82
|
end
|
70
83
|
results
|
71
84
|
end
|
72
85
|
|
73
86
|
def process_general_election_votes_2008(options={})
|
74
87
|
results = []
|
75
|
-
t = RemoteTable.new(url, :
|
88
|
+
t = RemoteTable.new(url, sheet: 'Table 3.GEVotes for Pres, H & S', skip: 2)
|
76
89
|
rows = t.entries
|
77
90
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
78
91
|
rows.each do |row|
|
79
92
|
break if row['State'] == 'Total:'
|
80
93
|
pres_votes = row['Presidential Vote'].to_i == 0 ? nil : row['Presidential Vote'].to_i
|
81
94
|
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil : row['U.S. Senate Vote'].to_i
|
82
|
-
results << OpenStruct.new(:
|
95
|
+
results << OpenStruct.new(state_abbrev: row['State'], presidential_votes: pres_votes, senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i)
|
83
96
|
end
|
84
97
|
results
|
85
98
|
end
|
86
|
-
|
99
|
+
|
87
100
|
def process_general_election_votes_2006(options={})
|
88
101
|
results = []
|
89
|
-
t = RemoteTable.new(url, :
|
102
|
+
t = RemoteTable.new(url, sheet: 'Table 1. GE Votes by State ', skip: 2)
|
90
103
|
rows = t.entries
|
91
104
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
92
105
|
rows.each do |row|
|
93
106
|
break if row['State'] == 'Total:'
|
94
107
|
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil : row['U.S. Senate Vote'].to_i
|
95
|
-
results << OpenStruct.new(:
|
108
|
+
results << OpenStruct.new(state_abbrev: row['State'], senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i, total_votes: row['Combined Vote'].to_i)
|
96
109
|
end
|
97
110
|
results
|
98
111
|
end
|
99
|
-
|
112
|
+
|
100
113
|
def process_general_election_votes_2004(options={})
|
101
114
|
results = []
|
102
|
-
t = RemoteTable.new(url, :
|
115
|
+
t = RemoteTable.new(url, sheet: 'Table 3. GE Votes by State', skip: 2)
|
103
116
|
rows = t.entries
|
104
117
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
105
118
|
rows.each do |row|
|
106
119
|
break if row['State'] == 'Total:'
|
107
120
|
pres_votes = row['Presidential Vote'].to_i == 0 ? nil : row['Presidential Vote'].to_i
|
108
121
|
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil : row['U.S. Senate Vote'].to_i
|
109
|
-
results << OpenStruct.new(:
|
122
|
+
results << OpenStruct.new(state_abbrev: row['State'], presidential_votes: pres_votes, senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i)
|
110
123
|
end
|
111
124
|
results
|
112
125
|
end
|
113
|
-
|
126
|
+
|
114
127
|
def process_general_election_votes_2002(options={})
|
115
128
|
raise NotImplementedError.new("This method not available for 2002")
|
116
129
|
end
|
117
|
-
|
130
|
+
|
118
131
|
def process_general_election_votes_2000(options={})
|
119
132
|
results = []
|
120
|
-
t = RemoteTable.new(url, :
|
133
|
+
t = RemoteTable.new(url, sheet: 'GE Votes- Pres,Sen,House-p.4', skip: 1)
|
121
134
|
rows = t.entries
|
122
135
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
123
136
|
rows.each do |row|
|
124
137
|
break if row['State'] == 'Total:'
|
125
138
|
pres_votes = row['Presidential Vote'].to_i == 0 ? nil : row['Presidential Vote'].to_i
|
126
139
|
sen_votes = row['U.S. Senate Vote'].to_i == 0 ? nil : row['U.S. Senate Vote'].to_i
|
127
|
-
results << OpenStruct.new(:
|
140
|
+
results << OpenStruct.new(state_abbrev: row['State'], presidential_votes: pres_votes, senate_votes: sen_votes, house_votes: row['U.S. House Vote'].to_i)
|
128
141
|
end
|
129
142
|
results
|
130
|
-
end
|
143
|
+
end
|
131
144
|
|
132
145
|
def process_general_election_votes_by_party_2012(options={})
|
133
146
|
results = []
|
134
|
-
t = RemoteTable.new(url, :
|
147
|
+
t = RemoteTable.new(url, sheet: 'Table 4. GE Votes Cast by Party', skip: 3)
|
135
148
|
rows = t.entries
|
136
149
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
137
150
|
rows.each do |row|
|
@@ -139,14 +152,14 @@ module FecResults
|
|
139
152
|
dem_votes = row['Democratic Candidates'].to_i == 0 ? nil : row['Democratic Candidates'].to_i
|
140
153
|
gop_votes = row['Republican Candidates'].to_i == 0 ? nil : row['Republican Candidates'].to_i
|
141
154
|
other_votes = row['Other Candidates'].to_i == 0 ? nil : row['Other Candidates'].to_i
|
142
|
-
results << OpenStruct.new(:
|
155
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
143
156
|
end
|
144
157
|
results
|
145
158
|
end
|
146
159
|
|
147
160
|
def process_general_election_votes_by_party_2010(options={})
|
148
161
|
results = []
|
149
|
-
t = RemoteTable.new(url, :
|
162
|
+
t = RemoteTable.new(url, sheet: 'Table 2. GE Votes by Party', skip: 4, headers: false)
|
150
163
|
rows = t.entries
|
151
164
|
rows = rows.select{|r| r[1] == options[:state]} if options[:state]
|
152
165
|
rows.each do |row|
|
@@ -154,14 +167,14 @@ module FecResults
|
|
154
167
|
dem_votes = row[2].to_i == 0 ? nil : row[2].to_i
|
155
168
|
gop_votes = row[3].to_i == 0 ? nil : row[3].to_i
|
156
169
|
other_votes = row[4].to_i == 0 ? nil : row[4].to_i
|
157
|
-
results << OpenStruct.new(:
|
170
|
+
results << OpenStruct.new(state: row[0], state_abbrev: row[1], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
158
171
|
end
|
159
172
|
results
|
160
173
|
end
|
161
174
|
|
162
175
|
def process_general_election_votes_by_party_2008(options={})
|
163
176
|
results = []
|
164
|
-
t = RemoteTable.new(url, :
|
177
|
+
t = RemoteTable.new(url, sheet: 'Table 4. GE Votes Cast by Party', skip: 3)
|
165
178
|
rows = t.entries
|
166
179
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
167
180
|
rows.each do |row|
|
@@ -169,14 +182,14 @@ module FecResults
|
|
169
182
|
dem_votes = row['Democratic Candidates'].to_i == 0 ? nil : row['Democratic Candidates'].to_i
|
170
183
|
gop_votes = row['Republican Candidates'].to_i == 0 ? nil : row['Republican Candidates'].to_i
|
171
184
|
other_votes = row['Other Candidates'].to_i == 0 ? nil : row['Other Candidates'].to_i
|
172
|
-
results << OpenStruct.new(:
|
185
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
173
186
|
end
|
174
187
|
results
|
175
188
|
end
|
176
189
|
|
177
190
|
def process_general_election_votes_by_party_2006(options={})
|
178
191
|
results = []
|
179
|
-
t = RemoteTable.new(url, :
|
192
|
+
t = RemoteTable.new(url, sheet: 'Table 2. GE Votes by Party', skip: 3)
|
180
193
|
rows = t.entries
|
181
194
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
182
195
|
rows.each do |row|
|
@@ -184,14 +197,14 @@ module FecResults
|
|
184
197
|
dem_votes = row['Democratic Candidates'].to_i == 0 ? nil : row['Democratic Candidates'].to_i
|
185
198
|
gop_votes = row['Republican Candidates'].to_i == 0 ? nil : row['Republican Candidates'].to_i
|
186
199
|
other_votes = row['Other Candidates'].to_i == 0 ? nil : row['Other Candidates'].to_i
|
187
|
-
results << OpenStruct.new(:
|
200
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
188
201
|
end
|
189
202
|
results
|
190
203
|
end
|
191
|
-
|
204
|
+
|
192
205
|
def process_general_election_votes_by_party_2004(options={})
|
193
206
|
results = []
|
194
|
-
t = RemoteTable.new(url, :
|
207
|
+
t = RemoteTable.new(url, sheet: 'Table 4. GE Votes by Party', skip: 3)
|
195
208
|
rows = t.entries
|
196
209
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
197
210
|
rows.each do |row|
|
@@ -199,18 +212,18 @@ module FecResults
|
|
199
212
|
dem_votes = row['Democratic Candidates'].to_i == 0 ? nil : row['Democratic Candidates'].to_i
|
200
213
|
gop_votes = row['Republican Candidates'].to_i == 0 ? nil : row['Republican Candidates'].to_i
|
201
214
|
other_votes = row['Other Candidates'].to_i == 0 ? nil : row['Other Candidates'].to_i
|
202
|
-
results << OpenStruct.new(:
|
215
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
203
216
|
end
|
204
217
|
results
|
205
218
|
end
|
206
|
-
|
219
|
+
|
207
220
|
def process_general_election_votes_by_party_2002(options={})
|
208
221
|
raise NotImplementedError.new("This method not available for 2002")
|
209
222
|
end
|
210
|
-
|
223
|
+
|
211
224
|
def process_general_election_votes_by_party_2000(options={})
|
212
225
|
results = []
|
213
|
-
t = RemoteTable.new(url, :
|
226
|
+
t = RemoteTable.new(url, sheet: 'GE Votes by Party -p.5', skip: 1)
|
214
227
|
rows = t.entries
|
215
228
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
216
229
|
rows.each do |row|
|
@@ -218,14 +231,14 @@ module FecResults
|
|
218
231
|
dem_votes = row['Democratic Candidates'].to_i == 0 ? nil : row['Democratic Candidates'].to_i
|
219
232
|
gop_votes = row['Republican Candidates'].to_i == 0 ? nil : row['Republican Candidates'].to_i
|
220
233
|
other_votes = row['Other Candidates'].to_i == 0 ? nil : row['Other Candidates'].to_i
|
221
|
-
results << OpenStruct.new(:
|
234
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_candidates: dem_votes, republican_candidates: gop_votes, other_candidates: other_votes)
|
222
235
|
end
|
223
236
|
results
|
224
237
|
end
|
225
|
-
|
238
|
+
|
226
239
|
def process_congressional_votes_by_election_2012(options={})
|
227
240
|
results = []
|
228
|
-
t = RemoteTable.new(url, :
|
241
|
+
t = RemoteTable.new(url, sheet: 'Table 5. P&G VotesCastforCong', skip: 4, headers: false)
|
229
242
|
rows = t.entries
|
230
243
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
231
244
|
rows.each do |row|
|
@@ -234,14 +247,14 @@ module FecResults
|
|
234
247
|
senate_general_votes = row[2].to_i == 0 ? nil : row[2].to_i
|
235
248
|
house_primary_votes = row[3].to_i == 0 ? nil : row[3].to_i
|
236
249
|
house_general_votes = row[4].to_i == 0 ? nil : row[4].to_i
|
237
|
-
results << OpenStruct.new(:
|
250
|
+
results << OpenStruct.new(state_abbrev: row[0], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
238
251
|
end
|
239
252
|
results
|
240
253
|
end
|
241
254
|
|
242
255
|
def process_congressional_votes_by_election_2010(options={})
|
243
256
|
results = []
|
244
|
-
t = RemoteTable.new(url, :
|
257
|
+
t = RemoteTable.new(url, sheet: 'Table 3. Prim & Gen Votes Cast', skip: 2)
|
245
258
|
rows = t.entries
|
246
259
|
rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
|
247
260
|
rows.each do |row|
|
@@ -250,14 +263,14 @@ module FecResults
|
|
250
263
|
senate_general_votes = row['GENERAL U.S. SENATE VOTE'].to_i == 0 ? nil : row['GENERAL U.S. SENATE VOTE'].to_i
|
251
264
|
house_primary_votes = row['PRIMARY U.S. HOUSE VOTE'].to_i == 0 ? nil : row['PRIMARY U.S. HOUSE VOTE'].to_i
|
252
265
|
house_general_votes = row['GENERAL U.S. HOUSE VOTE'].to_i == 0 ? nil : row['GENERAL U.S. HOUSE VOTE'].to_i
|
253
|
-
results << OpenStruct.new(:
|
266
|
+
results << OpenStruct.new(state: row['STATE'], state_abbrev: row['STATE ABBREVIATION'], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
254
267
|
end
|
255
268
|
results
|
256
269
|
end
|
257
|
-
|
270
|
+
|
258
271
|
def process_congressional_votes_by_election_2008(options={})
|
259
272
|
results = []
|
260
|
-
t = RemoteTable.new(url, :
|
273
|
+
t = RemoteTable.new(url, sheet: 'Table 5. P&G VotesCastforCong', skip: 4, headers: false)
|
261
274
|
rows = t.entries
|
262
275
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
263
276
|
rows.each do |row|
|
@@ -266,14 +279,14 @@ module FecResults
|
|
266
279
|
senate_general_votes = row[2].to_i == 0 ? nil : row[2].to_i
|
267
280
|
house_primary_votes = row[3].to_i == 0 ? nil : row[3].to_i
|
268
281
|
house_general_votes = row[4].to_i == 0 ? nil : row[4].to_i
|
269
|
-
results << OpenStruct.new(:
|
282
|
+
results << OpenStruct.new(state_abbrev: row[0], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
270
283
|
end
|
271
284
|
results
|
272
285
|
end
|
273
286
|
|
274
287
|
def process_congressional_votes_by_election_2006(options={})
|
275
288
|
results = []
|
276
|
-
t = RemoteTable.new(url, :
|
289
|
+
t = RemoteTable.new(url, sheet: 'Table 3. P&G Votes for Congress', skip: 2)
|
277
290
|
rows = t.entries
|
278
291
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
279
292
|
rows.each do |row|
|
@@ -282,14 +295,14 @@ module FecResults
|
|
282
295
|
senate_general_votes = row['GENERAL U.S. Senate Vote'].to_i == 0 ? nil : row['GENERAL U.S. Senate Vote'].to_i
|
283
296
|
house_primary_votes = row['PRIMARY U.S. House Vote'].to_i == 0 ? nil : row['PRIMARY U.S. House Vote'].to_i
|
284
297
|
house_general_votes = row['GENERAL U.S. House Vote'].to_i == 0 ? nil : row['GENERAL U.S. House Vote'].to_i
|
285
|
-
results << OpenStruct.new(:
|
298
|
+
results << OpenStruct.new(state_abbrev: row['State'], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
286
299
|
end
|
287
300
|
results
|
288
301
|
end
|
289
302
|
|
290
303
|
def process_congressional_votes_by_election_2004(options={})
|
291
304
|
results = []
|
292
|
-
t = RemoteTable.new(url, :
|
305
|
+
t = RemoteTable.new(url, sheet: 'Table 5. P&G Votes for Congress', skip: 2)
|
293
306
|
rows = t.entries
|
294
307
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
295
308
|
rows.each do |row|
|
@@ -298,14 +311,14 @@ module FecResults
|
|
298
311
|
senate_general_votes = row['GENERAL U.S. Senate Vote'].to_i == 0 ? nil : row['GENERAL U.S. Senate Vote'].to_i
|
299
312
|
house_primary_votes = row['PRIMARY U.S. House Vote'].to_i == 0 ? nil : row['PRIMARY U.S. House Vote'].to_i
|
300
313
|
house_general_votes = row['GENERAL U.S. House Vote'].to_i == 0 ? nil : row['GENERAL U.S. House Vote'].to_i
|
301
|
-
results << OpenStruct.new(:
|
314
|
+
results << OpenStruct.new(state_abbrev: row['State'], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
302
315
|
end
|
303
316
|
results
|
304
317
|
end
|
305
318
|
|
306
319
|
def process_congressional_votes_by_election_2002(options={})
|
307
320
|
results = []
|
308
|
-
t = RemoteTable.new(url, :
|
321
|
+
t = RemoteTable.new(url, sheet: 'Table 1. Primary & General Vote', skip: 4, headers: false)
|
309
322
|
rows = t.entries
|
310
323
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
311
324
|
rows.each do |row|
|
@@ -314,14 +327,14 @@ module FecResults
|
|
314
327
|
senate_general_votes = row[2].to_i == 0 ? nil : row[2].to_i
|
315
328
|
house_primary_votes = row[3].to_i == 0 ? nil : row[3].to_i
|
316
329
|
house_general_votes = row[4].to_i == 0 ? nil : row[4].to_i
|
317
|
-
results << OpenStruct.new(:
|
330
|
+
results << OpenStruct.new(state_abbrev: row[0], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
318
331
|
end
|
319
332
|
results
|
320
333
|
end
|
321
|
-
|
334
|
+
|
322
335
|
def process_congressional_votes_by_election_2000(options={})
|
323
336
|
results = []
|
324
|
-
t = RemoteTable.new(url, :
|
337
|
+
t = RemoteTable.new(url, sheet: 'P&G Votes-US Congress-p. 6', skip: 1)
|
325
338
|
rows = t.entries
|
326
339
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
327
340
|
rows.each do |row|
|
@@ -330,17 +343,17 @@ module FecResults
|
|
330
343
|
senate_general_votes = row['General U.S. Senate Vote'].to_i == 0 ? nil : row['General U.S. Senate Vote'].to_i
|
331
344
|
house_primary_votes = row['Primary U.S. House Vote'].to_i == 0 ? nil : row['Primary U.S. House Vote'].to_i
|
332
345
|
house_general_votes = row['General U.S. House Vote'].to_i == 0 ? nil : row['General U.S. House Vote'].to_i
|
333
|
-
results << OpenStruct.new(:
|
346
|
+
results << OpenStruct.new(state_abbrev: row['State'], senate_primary_votes: senate_primary_votes, senate_general_votes: senate_general_votes, house_primary_votes: house_primary_votes, house_general_votes: house_general_votes)
|
334
347
|
end
|
335
348
|
results
|
336
349
|
end
|
337
|
-
|
350
|
+
|
338
351
|
# columns are dem primary, gop primary, other primary, dem general, gop general, other general
|
339
352
|
# runoff election votes are included in the primary totals
|
340
353
|
def process_chamber_votes_by_party_2012(options={})
|
341
354
|
results = []
|
342
355
|
sheet = options[:chamber] == 'senate' ? 'Table 6. Senate by Party' : 'Table 7. House by Party'
|
343
|
-
t = RemoteTable.new(url, :
|
356
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 4, headers: false)
|
344
357
|
rows = t.entries
|
345
358
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
346
359
|
rows.each do |row|
|
@@ -351,8 +364,8 @@ module FecResults
|
|
351
364
|
dem_general = row[4].to_i == 0 ? nil : row[4].to_i
|
352
365
|
gop_general = row[5].to_i == 0 ? nil : row[5].to_i
|
353
366
|
other_general = row[6].to_i == 0 ? nil : row[6].to_i
|
354
|
-
results << OpenStruct.new(:
|
355
|
-
:
|
367
|
+
results << OpenStruct.new(state_abbrev: row[0], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
368
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
356
369
|
end
|
357
370
|
results
|
358
371
|
end
|
@@ -360,7 +373,7 @@ module FecResults
|
|
360
373
|
def process_chamber_votes_by_party_2010(options={})
|
361
374
|
results = []
|
362
375
|
sheet = options[:chamber] == 'senate' ? 'Table 4. Senate by Party' : 'Table 5. House by Party'
|
363
|
-
t = RemoteTable.new(url, :
|
376
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 2)
|
364
377
|
rows = t.entries
|
365
378
|
rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
|
366
379
|
rows.each do |row|
|
@@ -371,8 +384,8 @@ module FecResults
|
|
371
384
|
dem_general = row['GENERAL ELECTION DEMOCRATIC'].to_i == 0 ? nil : row['GENERAL ELECTION DEMOCRATIC'].to_i
|
372
385
|
gop_general = row['GENERAL ELECTION REPUBLICAN'].to_i == 0 ? nil : row['GENERAL ELECTION REPUBLICAN'].to_i
|
373
386
|
other_general = row['GENERAL ELECTION OTHER'].to_i == 0 ? nil : row['GENERAL ELECTION OTHER'].to_i
|
374
|
-
results << OpenStruct.new(:
|
375
|
-
:
|
387
|
+
results << OpenStruct.new(state: row['STATE'], state_abbrev: row['STATE ABBREVIATION'], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
388
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
376
389
|
end
|
377
390
|
results
|
378
391
|
end
|
@@ -380,7 +393,7 @@ module FecResults
|
|
380
393
|
def process_chamber_votes_by_party_2008(options={})
|
381
394
|
results = []
|
382
395
|
sheet = options[:chamber] == 'senate' ? 'Table 6. Senate by Party' : 'Table 7. House by Party'
|
383
|
-
t = RemoteTable.new(url, :
|
396
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 4, headers: false)
|
384
397
|
rows = t.entries
|
385
398
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
386
399
|
rows.each do |row|
|
@@ -391,8 +404,8 @@ module FecResults
|
|
391
404
|
dem_general = row[4].to_i == 0 ? nil : row[4].to_i
|
392
405
|
gop_general = row[5].to_i == 0 ? nil : row[5].to_i
|
393
406
|
other_general = row[6].to_i == 0 ? nil : row[6].to_i
|
394
|
-
results << OpenStruct.new(:
|
395
|
-
:
|
407
|
+
results << OpenStruct.new(state_abbrev: row[0], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
408
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
396
409
|
end
|
397
410
|
results
|
398
411
|
end
|
@@ -400,7 +413,7 @@ module FecResults
|
|
400
413
|
def process_chamber_votes_by_party_2006(options={})
|
401
414
|
results = []
|
402
415
|
sheet = options[:chamber] == 'senate' ? 'Table 4. Senate Votes by Party' : 'Table 5. House Votes by Party'
|
403
|
-
t = RemoteTable.new(url, :
|
416
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 2)
|
404
417
|
rows = t.entries
|
405
418
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
406
419
|
rows.each do |row|
|
@@ -411,8 +424,8 @@ module FecResults
|
|
411
424
|
dem_general = row['GENERAL Democratic'].to_i == 0 ? nil : row['GENERAL Democratic'].to_i
|
412
425
|
gop_general = row['GENERAL Republican'].to_i == 0 ? nil : row['GENERAL Republican'].to_i
|
413
426
|
other_general = row['GENERAL Other'].to_i == 0 ? nil : row['GENERAL Other'].to_i
|
414
|
-
results << OpenStruct.new(:
|
415
|
-
:
|
427
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
428
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
416
429
|
end
|
417
430
|
results
|
418
431
|
end
|
@@ -421,7 +434,7 @@ module FecResults
|
|
421
434
|
results = []
|
422
435
|
sheet = options[:chamber] == 'senate' ? 'Table 6. Senate Votes by Party' : 'Table 7. House Votes by Party'
|
423
436
|
state = options[:chamber] == 'senate' ? 'STATE' : 'State'
|
424
|
-
t = RemoteTable.new(url, :
|
437
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 2)
|
425
438
|
rows = t.entries
|
426
439
|
rows = rows.select{|r| r[state] == options[:state]} if options[:state]
|
427
440
|
rows.each do |row|
|
@@ -432,8 +445,8 @@ module FecResults
|
|
432
445
|
dem_general = row['GENERAL Democratic'].to_i == 0 ? nil : row['GENERAL Democratic'].to_i
|
433
446
|
gop_general = row['GENERAL Republican'].to_i == 0 ? nil : row['GENERAL Republican'].to_i
|
434
447
|
other_general = row['GENERAL Other'].to_i == 0 ? nil : row['GENERAL Other'].to_i
|
435
|
-
results << OpenStruct.new(:
|
436
|
-
:
|
448
|
+
results << OpenStruct.new(state_abbrev: row[state], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
449
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
437
450
|
end
|
438
451
|
results
|
439
452
|
end
|
@@ -441,7 +454,7 @@ module FecResults
|
|
441
454
|
def process_chamber_votes_by_party_2002(options={})
|
442
455
|
results = []
|
443
456
|
sheet = options[:chamber] == 'senate' ? 'Table 2. Senate Votes by Party' : 'Table 3. House Votes by Party'
|
444
|
-
t = RemoteTable.new(url, :
|
457
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 4, headers: false)
|
445
458
|
rows = t.entries
|
446
459
|
rows = rows.select{|r| r[0] == options[:state]} if options[:state]
|
447
460
|
rows.each do |row|
|
@@ -452,8 +465,8 @@ module FecResults
|
|
452
465
|
dem_general = row[4].to_i == 0 ? nil : row[4].to_i
|
453
466
|
gop_general = row[5].to_i == 0 ? nil : row[5].to_i
|
454
467
|
other_general = row[6].to_i == 0 ? nil : row[6].to_i
|
455
|
-
results << OpenStruct.new(:
|
456
|
-
:
|
468
|
+
results << OpenStruct.new(state_abbrev: row[0], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
469
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
457
470
|
end
|
458
471
|
results
|
459
472
|
end
|
@@ -461,7 +474,7 @@ module FecResults
|
|
461
474
|
def process_chamber_votes_by_party_2000(options={})
|
462
475
|
results = []
|
463
476
|
sheet = options[:chamber] == 'senate' ? 'Senate by Party-p. 7' : 'House by Party-p. 8'
|
464
|
-
t = RemoteTable.new(url, :
|
477
|
+
t = RemoteTable.new(url, sheet: sheet, skip: 1)
|
465
478
|
rows = t.entries
|
466
479
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
467
480
|
rows.each do |row|
|
@@ -472,87 +485,96 @@ module FecResults
|
|
472
485
|
dem_general = row['Democratic General'].to_i == 0 ? nil : row['Democratic General'].to_i
|
473
486
|
gop_general = row['Republican General '].to_i == 0 ? nil : row['Republican General '].to_i
|
474
487
|
other_general = row['Other General '].to_i == 0 ? nil : row['Other General '].to_i
|
475
|
-
results << OpenStruct.new(:
|
476
|
-
:
|
488
|
+
results << OpenStruct.new(state_abbrev: row['State'], democratic_primary_votes: dem_primary, republican_primary_votes: gop_primary, other_primary_votes: other_primary,
|
489
|
+
democratic_general_votes: dem_general, republican_general_votes: gop_general, other_general_votes: other_general)
|
477
490
|
end
|
478
491
|
results
|
479
492
|
end
|
480
493
|
|
481
494
|
def process_house_party_gains_2010(options={})
|
482
495
|
results = []
|
483
|
-
t = RemoteTable.new(url, :
|
496
|
+
t = RemoteTable.new(url, sheet: 'Table 6. House Party Gains', skip: 3)
|
484
497
|
rows = t.entries
|
485
498
|
rows = rows.select{|r| r['State'] == options[:state]} if options[:state]
|
486
499
|
rows.each do |row|
|
487
500
|
break if row['State'] == 'Total:'
|
488
|
-
results << OpenStruct.new(:
|
489
|
-
:
|
501
|
+
results << OpenStruct.new(state_abbrev: row['State'], republican_seats_2010: row['2010 Republican Seats'].to_i, democratic_seats_2010: row['2010 Democratic Seats'].to_i,
|
502
|
+
republican_seats_2008: row['2008 Republican Seats'].to_i, democratic_seats_2008: row['2008 Democratic Seats'].to_i, change_in_republican_seats: row['Change in # of Republican Seats, 2008-2010'].to_i)
|
503
|
+
end
|
504
|
+
results
|
505
|
+
end
|
506
|
+
|
507
|
+
def party_labels_2014
|
508
|
+
results = []
|
509
|
+
t = RemoteTable.new(FecResults::CONGRESS_URLS[year.to_s], sheet: '2014 Party Labels', skip: 5, headers: false)
|
510
|
+
t.entries.each do |row|
|
511
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
490
512
|
end
|
491
513
|
results
|
492
514
|
end
|
493
515
|
|
494
516
|
def party_labels_2012
|
495
517
|
results = []
|
496
|
-
t = RemoteTable.new(url, :
|
518
|
+
t = RemoteTable.new(url, sheet: '2012 Party Labels', skip: 5, headers: false)
|
497
519
|
t.entries.each do |row|
|
498
|
-
results << OpenStruct.new(:
|
520
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
499
521
|
end
|
500
522
|
results
|
501
523
|
end
|
502
524
|
|
503
525
|
def party_labels_2010
|
504
526
|
results = []
|
505
|
-
t = RemoteTable.new(FecResults::CONGRESS_URLS[year.to_s], :
|
527
|
+
t = RemoteTable.new(FecResults::CONGRESS_URLS[year.to_s], sheet: '2010 Party Labels', skip: 5, headers: false)
|
506
528
|
t.entries.each do |row|
|
507
|
-
results << OpenStruct.new(:
|
529
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
508
530
|
end
|
509
531
|
results
|
510
532
|
end
|
511
533
|
|
512
534
|
def party_labels_2008
|
513
535
|
results = []
|
514
|
-
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s], :
|
536
|
+
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s], sheet: '2008 Party Labels', skip: 5, headers: false)
|
515
537
|
t.entries.each do |row|
|
516
|
-
results << OpenStruct.new(:
|
538
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
517
539
|
end
|
518
540
|
results
|
519
541
|
end
|
520
542
|
|
521
543
|
def party_labels_2006
|
522
544
|
results = []
|
523
|
-
t = RemoteTable.new(FecResults::CONGRESS_URLS[year.to_s], :
|
545
|
+
t = RemoteTable.new(FecResults::CONGRESS_URLS[year.to_s], sheet: '2006 Party Labels', skip: 7, headers: false)
|
524
546
|
t.entries.each do |row|
|
525
|
-
results << OpenStruct.new(:
|
547
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
526
548
|
end
|
527
549
|
results
|
528
550
|
end
|
529
551
|
|
530
552
|
def party_labels_2004
|
531
553
|
results = []
|
532
|
-
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s], :
|
554
|
+
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s], sheet: '2004 Party Labels', skip: 7, headers: false)
|
533
555
|
t.entries.each do |row|
|
534
|
-
results << OpenStruct.new(:
|
556
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
535
557
|
end
|
536
558
|
results
|
537
559
|
end
|
538
560
|
|
539
561
|
def party_labels_2002
|
540
562
|
results = []
|
541
|
-
t = RemoteTable.new(url, :
|
563
|
+
t = RemoteTable.new(url, sheet: '2002 Party Labels', skip: 3, headers: false)
|
542
564
|
t.entries.each do |row|
|
543
|
-
results << OpenStruct.new(:
|
565
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
544
566
|
end
|
545
567
|
results
|
546
568
|
end
|
547
569
|
|
548
570
|
def party_labels_2000
|
549
571
|
results = []
|
550
|
-
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s].first, :
|
572
|
+
t = RemoteTable.new(FecResults::PRESIDENT_URLS[year.to_s].first, sheet: 'Guide to 2000 Party Labels', headers: false)
|
551
573
|
t.entries.each do |row|
|
552
|
-
results << OpenStruct.new(:
|
574
|
+
results << OpenStruct.new(abbrev: row[0], name: row[2])
|
553
575
|
end
|
554
576
|
results
|
555
577
|
end
|
556
578
|
|
557
579
|
end
|
558
|
-
end
|
580
|
+
end
|