fec_results 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +6 -6
  3. data/api/2000/congress/results.json +2668 -0
  4. data/api/2000/president/general_election_results.json +449 -0
  5. data/api/2000/president/popular_vote_summary.json +1 -0
  6. data/api/2000/president/primary_election_results.json +498 -0
  7. data/api/2000/president/primary_party_summary.json +1 -0
  8. data/api/2000/president/state_electoral_and_popular_vote_summary.json +1 -0
  9. data/api/2000/summary/chamber_votes_by_party.json +55 -0
  10. data/api/2000/summary/congressional_votes_by_election.json +55 -0
  11. data/api/2000/summary/general_election_votes.json +55 -0
  12. data/api/2000/summary/general_election_votes_by_party.json +55 -0
  13. data/api/2000/summary/party_labels.json +76 -0
  14. data/api/2002/congress/results.json +2401 -0
  15. data/api/2002/summary/chamber_votes_by_party.json +54 -0
  16. data/api/2002/summary/congressional_votes_by_election.json +54 -0
  17. data/api/2002/summary/general_election_votes.json +1 -0
  18. data/api/2002/summary/general_election_votes_by_party.json +1 -0
  19. data/api/2002/summary/party_labels.json +54 -0
  20. data/api/2004/congress/results.json +2309 -0
  21. data/api/2004/president/general_election_results.json +430 -0
  22. data/api/2004/president/popular_vote_summary.json +19 -0
  23. data/api/2004/president/primary_election_results.json +498 -0
  24. data/api/2004/president/primary_party_summary.json +7 -0
  25. data/api/2004/president/state_electoral_and_popular_vote_summary.json +56 -0
  26. data/api/2004/summary/chamber_votes_by_party.json +55 -0
  27. data/api/2004/summary/congressional_votes_by_election.json +55 -0
  28. data/api/2004/summary/general_election_votes.json +55 -0
  29. data/api/2004/summary/general_election_votes_by_party.json +55 -0
  30. data/api/2004/summary/party_labels.json +85 -0
  31. data/api/2006/congress/results.json +2377 -0
  32. data/api/2006/summary/chamber_votes_by_party.json +54 -0
  33. data/api/2006/summary/congressional_votes_by_election.json +54 -0
  34. data/api/2006/summary/general_election_votes.json +54 -0
  35. data/api/2006/summary/general_election_votes_by_party.json +54 -0
  36. data/api/2006/summary/party_labels.json +67 -0
  37. data/api/2008/congress/results.json +2401 -0
  38. data/api/2008/president/general_election_results.json +485 -0
  39. data/api/2008/president/popular_vote_summary.json +26 -0
  40. data/api/2008/president/primary_election_results.json +720 -0
  41. data/api/2008/president/primary_party_summary.json +11 -0
  42. data/api/2008/president/state_electoral_and_popular_vote_summary.json +51 -0
  43. data/api/2008/summary/chamber_votes_by_party.json +56 -0
  44. data/api/2008/summary/congressional_votes_by_election.json +56 -0
  45. data/api/2008/summary/general_election_votes.json +56 -0
  46. data/api/2008/summary/general_election_votes_by_party.json +56 -0
  47. data/api/2008/summary/party_labels.json +100 -0
  48. data/api/2010/congress/results.json +3300 -0
  49. data/api/2010/summary/chamber_votes_by_party.json +55 -0
  50. data/api/2010/summary/congressional_votes_by_election.json +55 -0
  51. data/api/2010/summary/general_election_votes.json +55 -0
  52. data/api/2010/summary/general_election_votes_by_party.json +55 -0
  53. data/api/2010/summary/party_labels.json +82 -0
  54. data/api/2012/congress/results.json +3081 -0
  55. data/api/2012/president/general_election_results.json +484 -0
  56. data/api/2012/president/popular_vote_summary.json +30 -0
  57. data/api/2012/president/primary_election_results.json +453 -0
  58. data/api/2012/president/primary_party_summary.json +9 -0
  59. data/api/2012/president/state_electoral_and_popular_vote_summary.json +51 -0
  60. data/api/2012/summary/chamber_votes_by_party.json +56 -0
  61. data/api/2012/summary/congressional_votes_by_election.json +56 -0
  62. data/api/2012/summary/general_election_votes.json +56 -0
  63. data/api/2012/summary/general_election_votes_by_party.json +56 -0
  64. data/api/2012/summary/party_labels.json +112 -0
  65. data/fec_results.gemspec +1 -0
  66. data/images/bg_hr.png +0 -0
  67. data/images/blacktocat.png +0 -0
  68. data/images/icon_download.png +0 -0
  69. data/images/sprite_download.png +0 -0
  70. data/index.html +159 -0
  71. data/javascripts/main.js +1 -0
  72. data/lib/fec_results.rb +3 -0
  73. data/lib/fec_results/congress.rb +56 -17
  74. data/lib/fec_results/president.rb +48 -48
  75. data/lib/fec_results/result.rb +2 -2
  76. data/lib/fec_results/summary.rb +120 -98
  77. data/lib/fec_results/version.rb +1 -1
  78. data/params.json +1 -0
  79. data/stylesheets/pygment_trac.css +70 -0
  80. data/stylesheets/stylesheet.css +419 -0
  81. metadata +100 -14
@@ -0,0 +1 @@
1
+ console.log('This would be the main JS file.');
data/lib/fec_results.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'remote_table'
3
3
  require 'american_date'
4
4
  require 'ostruct'
5
+ require 'roo-xls'
5
6
 
6
7
  require "fec_results/version"
7
8
  require "fec_results/congress"
@@ -12,6 +13,7 @@ require "fec_results/president"
12
13
  module FecResults
13
14
 
14
15
  SUMMARY_URLS = {
16
+ '2014' => 'http://www.fec.gov/pubrec/fe2014/tables2014.xls',
15
17
  '2012' => 'http://www.fec.gov/pubrec/fe2012/tables2012.xls',
16
18
  '2010' => 'http://www.fec.gov/pubrec/fe2010/tables10.xls',
17
19
  '2008' => 'http://www.fec.gov/pubrec/fe2008/tables2008.xls',
@@ -22,6 +24,7 @@ module FecResults
22
24
  }
23
25
 
24
26
  CONGRESS_URLS = {
27
+ '2014' => 'http://www.fec.gov/pubrec/fe2014/results14.xls',
25
28
  '2012' => 'http://www.fec.gov/pubrec/fe2012/2012congresults.xls',
26
29
  '2010' => 'http://www.fec.gov/pubrec/fe2010/results10.xls',
27
30
  '2008' => 'http://www.fec.gov/pubrec/fe2008/2008congresults.xls',
@@ -3,7 +3,7 @@ module FecResults
3
3
 
4
4
  attr_reader :year, :url
5
5
 
6
- # given a year and an optional chamber ('house' or 'senate') and state ('ar', 'az', etc.)
6
+ # given a year and an optional chamber ('house' or 'senate') and state ('ar', 'az', etc.)
7
7
  # retrieves election results that fit the criteria
8
8
  def initialize(params={})
9
9
  params.each_pair do |k,v|
@@ -11,19 +11,58 @@ module FecResults
11
11
  end
12
12
  @url = FecResults::CONGRESS_URLS[year.to_s]
13
13
  end
14
-
14
+
15
15
  def results(options={})
16
16
  send("process_#{year}", options)
17
17
  end
18
18
 
19
+ def process_2014(options)
20
+ results = []
21
+ senate = RemoteTable.new(url, sheet: "2014 US Senate Results by State")
22
+ house = RemoteTable.new(url, sheet: "2014 US House Results by State")
23
+ rows = senate.entries + house.entries
24
+ rows = rows.select{|r| r['D'] == options[:chamber]} if options[:chamber]
25
+ rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
26
+ rows.each do |candidate|
27
+ c = {year: year}
28
+ next if candidate['CANDIDATE NAME (Last)'].blank?
29
+ next if candidate['D'].blank?
30
+ # find the office_type
31
+ if candidate['FEC ID#'].first != 'n'
32
+ c[:chamber] = candidate['FEC ID#'].first
33
+ elsif candidate['D'].first == 'S'
34
+ c[:chamber] = "S"
35
+ else
36
+ c[:chamber] = 'H'
37
+ end
38
+ c[:state] = candidate['STATE ABBREVIATION']
39
+ c[:district] = candidate['D']
40
+ c[:party] = candidate['PARTY']
41
+ c[:incumbent] = candidate['(I)'] == '(I)' ? true : false
42
+ c[:fec_id] = candidate['FEC ID#']
43
+ c[:candidate_first] = candidate['CANDIDATE NAME (First)']
44
+ c[:candidate_last] = candidate['CANDIDATE NAME (Last)']
45
+ c[:candidate_name] = candidate['CANDIDATE NAME']
46
+
47
+ c = update_vote_tallies(c, candidate, 'PRIMARY VOTES', 'PRIMARY %', 'RUNOFF VOTES', 'RUNOFF %', 'GENERAL VOTES ', 'GENERAL %')
48
+ c = update_general_runoff(c, candidate, 'GE RUNOFF ELECTION VOTES (LA)', 'GE RUNOFF ELECTION % (LA)') if c[:state] == 'LA'
49
+ c = update_combined_totals(c, candidate, 'COMBINED GE PARTY TOTALS (CT, NY, SC)', 'COMBINED % (CT, NY, SC)') if ['CT', 'NY', 'SC'].include?(c[:state])
50
+
51
+ c[:general_winner] = candidate['GE WINNER INDICATOR'] == "W" ? true : false unless c[:general_pct].nil?
52
+
53
+ results << c
54
+ end
55
+ Result.create_from_results(results)
56
+ end
57
+
19
58
  def process_2012(options)
20
59
  results = []
21
- t = RemoteTable.new(url, :sheet => "2012 US House & Senate Resuts")
60
+ t = RemoteTable.new(url, :sheet => "2012 US House & Senate Results")
22
61
  rows = t.entries
23
62
  rows = rows.select{|r| r['D'] == options[:chamber]} if options[:chamber]
24
63
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
25
64
  rows.each do |candidate|
26
- c = {:year => year}
65
+ c = {year: year}
27
66
  next if candidate['CANDIDATE NAME (Last)'].blank?
28
67
  next if candidate['D'].blank?
29
68
  # find the office_type
@@ -56,12 +95,12 @@ module FecResults
56
95
 
57
96
  def process_2010(options)
58
97
  results = []
59
- t = RemoteTable.new(url, :sheet => "2010 US House & Senate Results")
98
+ t = RemoteTable.new(url, sheet: "2010 US House & Senate Results")
60
99
  rows = t.entries
61
100
  rows = rows.select{|r| r['DISTRICT'] == options[:chamber]} if options[:chamber]
62
101
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
63
102
  rows.each do |candidate|
64
- c = {:year => year}
103
+ c = {year: year}
65
104
  next if candidate['CANDIDATE NAME (Last)'].blank?
66
105
  next if candidate['DISTRICT'].blank?
67
106
  # find the office_type
@@ -91,12 +130,12 @@ module FecResults
91
130
 
92
131
  def process_2008(options)
93
132
  results = []
94
- t = RemoteTable.new(url, :sheet => "2008 House and Senate Results")
133
+ t = RemoteTable.new(url, sheet: "2008 House and Senate Results")
95
134
  rows = t.entries
96
135
  rows = rows.select{|r| r['DISTRICT'] == options[:chamber]} if options[:chamber]
97
136
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
98
137
  rows.each do |candidate|
99
- c = {:year => year}
138
+ c = {year: year}
100
139
  next if candidate['Candidate Name (Last)'].blank?
101
140
  next if candidate['DISTRICT'].blank?
102
141
  # find the office_type
@@ -127,12 +166,12 @@ module FecResults
127
166
 
128
167
  def process_2006(options)
129
168
  results = []
130
- t = RemoteTable.new(url, :sheet => "2006 US House & Senate Results")
169
+ t = RemoteTable.new(url, sheet: "2006 US House & Senate Results")
131
170
  rows = t.entries
132
171
  rows = rows.select{|r| r['DISTRICT'] == options[:chamber]} if options[:chamber]
133
172
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
134
173
  rows.each do |candidate|
135
- c = {:year => year}
174
+ c = {year: year}
136
175
  next if candidate['LAST NAME'].blank?
137
176
  next if candidate['DISTRICT'].blank?
138
177
  # find the office_type
@@ -163,12 +202,12 @@ module FecResults
163
202
 
164
203
  def process_2004(options)
165
204
  results = []
166
- t = RemoteTable.new(url, :sheet => "2004 US HOUSE & SENATE RESULTS")
205
+ t = RemoteTable.new(url, sheet: "2004 US HOUSE & SENATE RESULTS")
167
206
  rows = t.entries
168
207
  rows = rows.select{|r| r['DISTRICT'] == options[:chamber]} if options[:chamber]
169
208
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
170
209
  rows.each do |candidate|
171
- c = {:year => year}
210
+ c = {year: year}
172
211
  next if candidate['LAST NAME'].blank?
173
212
  next if candidate['DISTRICT'].blank?
174
213
  # find the office_type
@@ -198,12 +237,12 @@ module FecResults
198
237
 
199
238
  def process_2002(options={})
200
239
  results = []
201
- t = RemoteTable.new(url, :sheet => "2002 House & Senate Results")
240
+ t = RemoteTable.new(url, sheet: "2002 House & Senate Results")
202
241
  rows = t.entries
203
242
  rows = rows.select{|r| r['DISTRICT'] == options[:chamber]} if options[:chamber]
204
243
  rows = rows.select{|r| r['STATE'] == options[:state]} if options[:state]
205
244
  rows.each do |candidate|
206
- c = {:year => year}
245
+ c = {year: year}
207
246
  next if candidate['LAST NAME'].blank?
208
247
  next if candidate['DISTRICT'].blank?
209
248
  # find the office_type
@@ -234,11 +273,11 @@ module FecResults
234
273
  def process_2000(options={})
235
274
  results = []
236
275
  url.each do |u|
237
- t = RemoteTable.new(u.keys.first, :sheet => u.values.first)
276
+ t = RemoteTable.new(u.keys.first, sheet: u.values.first)
238
277
  rows = t.entries
239
278
  rows = rows.select{|r| r['STATE'] == options[:state]} if options[:state]
240
279
  rows.each do |candidate|
241
- c = {:year => year}
280
+ c = {year: year}
242
281
  next if candidate['NAME'][0..4] == 'Total'
243
282
  next if candidate['DISTRICT'].blank?
244
283
  if candidate['DISTRICT'].first == 'S'
@@ -340,4 +379,4 @@ module FecResults
340
379
  end
341
380
 
342
381
  end
343
- end
382
+ end
@@ -9,13 +9,13 @@ module FecResults
9
9
  end
10
10
  @url = FecResults::PRESIDENT_URLS[year.to_s]
11
11
  end
12
-
12
+
13
13
  def to_s
14
14
  "#<FecResults::President:#{year.to_s}>"
15
15
  end
16
-
16
+
17
17
  #### main instance methods called with optional arguments to filter.
18
-
18
+
19
19
  def popular_vote_summary(*args)
20
20
  send("popular_vote_summary_#{year}", *args)
21
21
  end
@@ -23,7 +23,7 @@ module FecResults
23
23
  def state_electoral_and_popular_vote_summary(*args)
24
24
  send("state_electoral_and_popular_vote_summary_#{year}", *args)
25
25
  end
26
-
26
+
27
27
  def primary_party_summary
28
28
  send("primary_party_summary_#{year}")
29
29
  end
@@ -35,95 +35,95 @@ module FecResults
35
35
  def primary_election_results(*args)
36
36
  send("primary_election_results_#{year}", *args)
37
37
  end
38
-
38
+
39
39
  #### cycle-specific methods called by main methods above
40
40
 
41
41
  def popular_vote_summary_2012(options={})
42
42
  results = []
43
- t = RemoteTable.new(url, :sheet => 'Table 1. 2012 Pres Popular Vote', :skip => 3)
43
+ t = RemoteTable.new(url, sheet: 'Table 1. 2012 Pres Popular Vote', skip: 3)
44
44
  t.entries.each do |row|
45
45
  break if row['Candidate (Party Label)'] == 'Total:'
46
- results << OpenStruct.new(:candidate => row['Candidate (Party Label)'], :popular_votes => row['Popular Vote Total'].to_i, :popular_vote_percent => row['Percent of Popular Vote'].to_f)
46
+ results << OpenStruct.new(candidate: row['Candidate (Party Label)'], popular_votes: row['Popular Vote Total'].to_i, popular_vote_percent: row['Percent of Popular Vote'].to_f)
47
47
  end
48
48
  results
49
49
  end
50
50
 
51
51
  def popular_vote_summary_2008(options={})
52
52
  results = []
53
- t = RemoteTable.new(FecResults::SUMMARY_URLS[year.to_s], :sheet => 'Table 1. 2008 Pres Popular Vote', :skip => 3)
53
+ t = RemoteTable.new(FecResults::SUMMARY_URLS[year.to_s], sheet: 'Table 1. 2008 Pres Popular Vote', skip: 3)
54
54
  t.entries.each do |row|
55
55
  break if row['Candidate (Party Label)'] == 'Total:'
56
- results << OpenStruct.new(:candidate => row['Candidate (Party Label)'], :popular_votes => row['Popular Vote Total'].to_i, :popular_vote_percent => row['Percent of Popular Vote'].to_f)
56
+ results << OpenStruct.new(candidate: row['Candidate (Party Label)'], popular_votes: row['Popular Vote Total'].to_i, popular_vote_percent: row['Percent of Popular Vote'].to_f)
57
57
  end
58
58
  results
59
59
  end
60
-
60
+
61
61
  def popular_vote_summary_2004(options={})
62
62
  results = []
63
- t = RemoteTable.new(url, :sheet => 'Table 1. Pres Popular Vote', :skip => 3)
63
+ t = RemoteTable.new(url, sheet: 'Table 1. Pres Popular Vote', skip: 3)
64
64
  t.entries.each do |row|
65
65
  break if row['Candidate'] == 'Total:'
66
- results << OpenStruct.new(:candidate => row['Candidate'], :party => row['(Party Label)'], :popular_votes => row['Popular Vote Total'].to_i, :popular_vote_percent => row['Percent of Popular Vote'].to_f)
66
+ results << OpenStruct.new(candidate: row['Candidate'], party: row['(Party Label)'], popular_votes: row['Popular Vote Total'].to_i, popular_vote_percent: row['Percent of Popular Vote'].to_f)
67
67
  end
68
68
  results
69
69
  end
70
70
 
71
71
  def state_electoral_and_popular_vote_summary_2012(options={})
72
72
  results = []
73
- t = RemoteTable.new(url, :sheet => 'Table 2. Electoral & Pop Vote', :skip => 4, :headers => false)
73
+ t = RemoteTable.new(url, sheet: 'Table 2. Electoral & Pop Vote', skip: 4, headers: false)
74
74
  t.entries.each do |row|
75
75
  break if row[0] == 'Total:'
76
- results << OpenStruct.new(:state => row[0], :democratic_electoral_votes => row[1].to_i, :republican_electoral_votes => row[2].to_i, :democratic_popular_votes => row[3].to_i, :republican_popular_votes => row[4].to_i, :other_popular_votes => row[5].to_i, :total_votes => row[6].to_i)
76
+ results << OpenStruct.new(state: row[0], democratic_electoral_votes: row[1].to_i, republican_electoral_votes: row[2].to_i, :democratic_popular_votes => row[3].to_i, :republican_popular_votes => row[4].to_i, :other_popular_votes => row[5].to_i, total_votes: row[6].to_i)
77
77
  end
78
78
  results
79
79
  end
80
80
 
81
81
  def state_electoral_and_popular_vote_summary_2008(options={})
82
82
  results = []
83
- t = RemoteTable.new(FecResults::SUMMARY_URLS[year.to_s], :sheet => 'Table 2. Electoral & Pop Vote', :skip => 4, :headers => false)
83
+ t = RemoteTable.new(FecResults::SUMMARY_URLS[year.to_s], sheet: 'Table 2. Electoral & Pop Vote', skip: 4, headers: false)
84
84
  t.entries.each do |row|
85
85
  break if row[0] == 'Total:'
86
- results << OpenStruct.new(:state => row[0], :democratic_electoral_votes => row[1].to_i, :republican_electoral_votes => row[2].to_i, :democratic_popular_votes => row[3].to_i, :republican_popular_votes => row[4].to_i, :other_popular_votes => row[5].to_i, :total_votes => row[6].to_i)
86
+ results << OpenStruct.new(state: row[0], democratic_electoral_votes: row[1].to_i, republican_electoral_votes: row[2].to_i, :democratic_popular_votes => row[3].to_i, :republican_popular_votes => row[4].to_i, :other_popular_votes => row[5].to_i, total_votes: row[6].to_i)
87
87
  end
88
88
  results
89
89
  end
90
90
 
91
91
  def state_electoral_and_popular_vote_summary_2004(options={})
92
92
  results = []
93
- t = RemoteTable.new(url, :sheet => 'Table 2. Pres Elec & Pop Vote', :skip => 2)
93
+ t = RemoteTable.new(url, sheet: 'Table 2. Pres Elec & Pop Vote', skip: 2)
94
94
  t.entries.each do |row|
95
95
  break if row[0] == 'Total:'
96
- results << OpenStruct.new(:state => row['STATE'], :democratic_electoral_votes => row['Electoral Vote Kerry (D)'].to_i, :republican_electoral_votes => row['Electoral Vote Bush (R)'].to_i, :democratic_popular_votes => row['Popular Vote Kerry (D)'].to_i, :republican_popular_votes => row['Popular Vote Bush (R)'].to_i, :other_popular_votes => row['Popular Vote All Others'].to_i, :total_votes => row['Popular Vote Total Vote'].to_i)
96
+ results << OpenStruct.new(state: row['STATE'], democratic_electoral_votes: row['Electoral Vote Kerry (D)'].to_i, republican_electoral_votes: row['Electoral Vote Bush (R)'].to_i, :democratic_popular_votes => row['Popular Vote Kerry (D)'].to_i, :republican_popular_votes => row['Popular Vote Bush (R)'].to_i, :other_popular_votes => row['Popular Vote All Others'].to_i, total_votes: row['Popular Vote Total Vote'].to_i)
97
97
  end
98
98
  results
99
99
  end
100
100
 
101
101
  def primary_party_summary_2012(options={})
102
102
  results = []
103
- t = RemoteTable.new(url, :sheet => '2012 Pres Primary Party Summary', :skip => 1, :headers => false)
103
+ t = RemoteTable.new(url, sheet: '2012 Pres Primary Party Summary', skip: 1, headers: false)
104
104
  t.entries.each do |row|
105
105
  break if row[0] == 'Total Primary Votes:'
106
- results << OpenStruct.new(:party => row[0], :total_votes => row[1].to_i)
106
+ results << OpenStruct.new(party: row[0], total_votes: row[1].to_i)
107
107
  end
108
108
  results
109
109
  end
110
-
110
+
111
111
  def primary_party_summary_2008(options={})
112
112
  results = []
113
- t = RemoteTable.new(url, :sheet => '2008 Pres Primary Party Summary', :skip => 1, :headers => false)
113
+ t = RemoteTable.new(url, sheet: '2008 Pres Primary Party Summary', skip: 1, headers: false)
114
114
  t.entries.each do |row|
115
115
  break if row[0] == 'Total Primary Votes:'
116
- results << OpenStruct.new(:party => row[0], :total_votes => row[1].to_i)
116
+ results << OpenStruct.new(party: row[0], total_votes: row[1].to_i)
117
117
  end
118
118
  results
119
119
  end
120
-
120
+
121
121
  def primary_party_summary_2004(options={})
122
122
  results = []
123
- t = RemoteTable.new(url, :sheet => '2004 Pres Primary Party Summary', :skip => 1, :headers => false)
123
+ t = RemoteTable.new(url, sheet: '2004 Pres Primary Party Summary', skip: 1, headers: false)
124
124
  t.entries.each do |row|
125
125
  break if row[0] == 'Total Primary Votes Cast:'
126
- results << OpenStruct.new(:party => row[0], :total_votes => row[1].to_i)
126
+ results << OpenStruct.new(party: row[0], total_votes: row[1].to_i)
127
127
  end
128
128
  results
129
129
  end
@@ -134,12 +134,12 @@ module FecResults
134
134
 
135
135
  def general_election_results_2012(options={})
136
136
  results = []
137
- t = RemoteTable.new(url, :sheet => '2012 Pres General Results')
137
+ t = RemoteTable.new(url, sheet: '2012 Pres General Results')
138
138
  rows = t.entries
139
139
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
140
140
  rows.each do |candidate|
141
141
  next if candidate['LAST NAME, FIRST'].blank?
142
- c = {:year => year}
142
+ c = {year: year}
143
143
  c[:chamber] = "P"
144
144
  c[:state] = candidate['STATE ABBREVIATION']
145
145
  c[:party] = candidate['PARTY'] == 'Combined Parties:' ? "COMBINED TOTAL" : candidate['PARTY']
@@ -156,15 +156,15 @@ module FecResults
156
156
  end
157
157
  Result.create_from_results(results)
158
158
  end
159
-
159
+
160
160
  def primary_election_results_2012(options={})
161
161
  results = []
162
- t = RemoteTable.new(url, :sheet => '2012 Pres Primary Results')
162
+ t = RemoteTable.new(url, sheet: '2012 Pres Primary Results')
163
163
  rows = t.entries
164
164
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
165
165
  rows.each do |candidate|
166
166
  next if candidate['LAST NAME, FIRST'].blank?
167
- c = {:year => year}
167
+ c = {year: year}
168
168
  c[:chamber] = "P"
169
169
  c[:state] = candidate['STATE ABBREVIATION']
170
170
  c[:party] = candidate['PARTY']
@@ -184,12 +184,12 @@ module FecResults
184
184
 
185
185
  def general_election_results_2008(options={})
186
186
  results = []
187
- t = RemoteTable.new(url, :sheet => '2008 PRES GENERAL RESULTS')
187
+ t = RemoteTable.new(url, sheet: '2008 PRES GENERAL RESULTS')
188
188
  rows = t.entries
189
189
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
190
190
  rows.each do |candidate|
191
191
  next if candidate['LAST NAME, FIRST'].blank?
192
- c = {:year => year}
192
+ c = {year: year}
193
193
  c[:chamber] = "P"
194
194
  c[:date] = Date.parse(candidate['GENERAL ELECTION DATE'])
195
195
  c[:state] = candidate['STATE ABBREVIATION']
@@ -206,16 +206,16 @@ module FecResults
206
206
  results << c
207
207
  end
208
208
  Result.create_from_results(results)
209
- end
210
-
209
+ end
210
+
211
211
  def primary_election_results_2008(options={})
212
212
  results = []
213
- t = RemoteTable.new(url, :sheet => '2008 Pres Primary Results')
213
+ t = RemoteTable.new(url, sheet: '2008 Pres Primary Results')
214
214
  rows = t.entries
215
215
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
216
216
  rows.each do |candidate|
217
217
  next if candidate['LAST NAME, FIRST'].blank?
218
- c = {:year => year}
218
+ c = {year: year}
219
219
  c[:chamber] = "P"
220
220
  c[:date] = Date.parse(candidate['PRIMARY DATE'])
221
221
  c[:state] = candidate['STATE ABBREVIATION']
@@ -233,15 +233,15 @@ module FecResults
233
233
  end
234
234
  Result.create_from_results(results)
235
235
  end
236
-
236
+
237
237
  def general_election_results_2004(options={})
238
238
  results = []
239
- t = RemoteTable.new(url, :sheet => '2004 PRES GENERAL RESULTS')
239
+ t = RemoteTable.new(url, sheet: '2004 PRES GENERAL RESULTS')
240
240
  rows = t.entries
241
241
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
242
242
  rows.each do |candidate|
243
243
  next if candidate['LAST NAME, FIRST'].blank?
244
- c = {:year => year}
244
+ c = {year: year}
245
245
  c[:date] = Date.parse(candidate["GENERAL ELECTION DATE"])
246
246
  c[:chamber] = "P"
247
247
  c[:state] = candidate['STATE ABBREVIATION']
@@ -261,12 +261,12 @@ module FecResults
261
261
 
262
262
  def primary_election_results_2004(options={})
263
263
  results = []
264
- t = RemoteTable.new(url, :sheet => '2004 PRES PRIMARY RESULTS')
264
+ t = RemoteTable.new(url, sheet: '2004 PRES PRIMARY RESULTS')
265
265
  rows = t.entries
266
266
  rows = rows.select{|r| r['STATE ABBREVIATION'] == options[:state]} if options[:state]
267
267
  rows.each do |candidate|
268
268
  next if candidate['LAST NAME, FIRST'].blank?
269
- c = {:year => year}
269
+ c = {year: year}
270
270
  c[:date] = Date.parse(candidate["PRIMARY DATE"])
271
271
  c[:chamber] = "P"
272
272
  c[:state] = candidate['STATE ABBREVIATION']
@@ -283,15 +283,15 @@ module FecResults
283
283
  end
284
284
  Result.create_from_results(results)
285
285
  end
286
-
286
+
287
287
  def general_election_results_2000(options={})
288
288
  results = []
289
- t = RemoteTable.new(url.first, :sheet => 'Master (with Totals & Percents)', :skip => 1, :headers => false)
289
+ t = RemoteTable.new(url.first, sheet: 'Master (with Totals & Percents)', skip: 1, headers: false)
290
290
  rows = t.entries
291
291
  rows = rows.select{|r| r[0] == options[:state]} if options[:state]
292
292
  rows.each do |candidate|
293
293
  next if candidate[2].blank?
294
- c = {:year => year}
294
+ c = {year: year}
295
295
  c[:date] = Date.parse("11/7/2000")
296
296
  c[:chamber] = "P"
297
297
  c[:state] = candidate[0]
@@ -311,13 +311,13 @@ module FecResults
311
311
 
312
312
  def primary_election_results_2000(options={})
313
313
  results = []
314
- t = RemoteTable.new(url.last, :sheet => 'Primary Results by State')
314
+ t = RemoteTable.new(url.last, sheet: 'Primary Results by State')
315
315
  rows = t.entries
316
316
  rows = rows.select{|r| r['STATE'] == options[:state]} if options[:state]
317
317
  rows.each do |candidate|
318
318
  next if candidate['PARTY'].blank?
319
319
  next if candidate['CANDIDATE'] == 'Total Party Votes'
320
- c = {:year => year}
320
+ c = {year: year}
321
321
  c[:date] = nil
322
322
  c[:chamber] = "P"
323
323
  c[:state] = candidate['STATE']
@@ -337,4 +337,4 @@ module FecResults
337
337
 
338
338
 
339
339
  end
340
- end
340
+ end