campaign_cash 2.3 → 2.3.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/Gemfile.lock +1 -1
- data/README.rdoc +1 -0
- data/lib/campaign_cash/candidate.rb +11 -6
- data/lib/campaign_cash/committee.rb +6 -0
- data/lib/campaign_cash/filing.rb +2 -1
- data/lib/campaign_cash/version.rb +1 -1
- data/test/campaign_cash/test_candidate.rb +12 -4
- data/test/campaign_cash/test_committee.rb +14 -3
- metadata +4 -3
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -233,6 +233,7 @@ Electioneering Communications are broadcast ads funded by third party groups tha
|
|
233
233
|
* Al Shaw, almshaw@gmail.com
|
234
234
|
* Jason Holt, jjh@offensivepolitics.net
|
235
235
|
* Benjamin Jackson, http://twitter.com/benjaminjackson
|
236
|
+
* Daniel Leavitt, https://github.com/dleavitt
|
236
237
|
|
237
238
|
== Copyright
|
238
239
|
|
@@ -127,14 +127,19 @@ module CampaignCash
|
|
127
127
|
results.map{|c| self.create(c)}
|
128
128
|
end
|
129
129
|
|
130
|
-
# Returns an array of candidates for a given state
|
131
|
-
# district
|
132
|
-
def self.
|
133
|
-
|
134
|
-
|
135
|
-
|
130
|
+
# Returns an array of candidates for a given state within a cycle, with optional chamber and
|
131
|
+
# district parameters. For example, House candidates from New York. Defaults to the current cycle.
|
132
|
+
def self.state(state, chamber=nil, district=nil, cycle=CURRENT_CYCLE, offset=nil)
|
133
|
+
path = "#{cycle}/seats/#{state}"
|
134
|
+
if chamber
|
135
|
+
path += "/#{chamber}"
|
136
|
+
path += "/#{district}" if district
|
137
|
+
end
|
138
|
+
reply = invoke(path,{:offset => offset})
|
139
|
+
results = reply['results']
|
136
140
|
results.map{|c| self.create_from_search_results(c)}
|
137
141
|
end
|
138
142
|
|
143
|
+
instance_eval { alias :state_chamber :state }
|
139
144
|
end
|
140
145
|
end
|
@@ -157,5 +157,11 @@ module CampaignCash
|
|
157
157
|
results.map{|c| Filing.create(c)}
|
158
158
|
end
|
159
159
|
|
160
|
+
def unamended_filings(cycle=CURRENT_CYCLE, offset=nil)
|
161
|
+
reply = Base.invoke("#{cycle}/committees/#{id}/filings",{:offset => offset})
|
162
|
+
results = reply['results'].select{|f| f['amended'] == false}
|
163
|
+
results.map{|c| Filing.create(c)}
|
164
|
+
end
|
165
|
+
|
160
166
|
end
|
161
167
|
end
|
data/lib/campaign_cash/filing.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module CampaignCash
|
2
2
|
class Filing < Base
|
3
3
|
|
4
|
-
attr_reader :committee_name, :date_coverage_from, :amended_uri, :fec_uri, :date_coverage_to, :committee, :report_title, :amended, :date_filed, :cycle, :form_type, :original_filing, :original_uri, :paper, :committee_type
|
4
|
+
attr_reader :committee_name, :date_coverage_from, :amended_uri, :fec_uri, :date_coverage_to, :committee, :report_title, :amended, :date_filed, :cycle, :form_type, :original_filing, :original_uri, :paper, :committee_type, :filing_id
|
5
5
|
|
6
6
|
def initialize(params={})
|
7
7
|
params.each_pair do |k,v|
|
@@ -22,6 +22,7 @@ module CampaignCash
|
|
22
22
|
:original_uri => params['original_uri'],
|
23
23
|
:paper => params['paper'],
|
24
24
|
:form_type => params['form_type'],
|
25
|
+
:filing_id => params['form_id'],
|
25
26
|
:committee_type => Committee.get_committee_type(params['committee_type'])
|
26
27
|
end
|
27
28
|
|
@@ -74,12 +74,20 @@ class TestCampaignCash::TestCandidate < Test::Unit::TestCase
|
|
74
74
|
end
|
75
75
|
|
76
76
|
context "state candidates" do
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
should "return 32 total candidates from Rhode Island" do
|
78
|
+
assert_equal Candidate.state('RI', nil, nil, 2010).length, 32
|
79
|
+
end
|
80
80
|
|
81
81
|
should "return 29 House candidates from Rhode Island" do
|
82
|
-
assert_equal
|
82
|
+
assert_equal Candidate.state('RI', "house", nil, 2010).length, 29
|
83
|
+
end
|
84
|
+
|
85
|
+
should "return 3 Senate candidates from Rhode Island" do
|
86
|
+
assert_equal Candidate.state('RI', "senate", nil, 2010).length, 3
|
87
|
+
end
|
88
|
+
|
89
|
+
should "return 17 House candidates from District 1 of Rhode Island" do
|
90
|
+
assert_equal Candidate.state('RI', "house", 1, 2010).length, 17
|
83
91
|
end
|
84
92
|
end
|
85
93
|
end
|
@@ -56,8 +56,20 @@ class TestCampaignCash::TestCommittee < Test::Unit::TestCase
|
|
56
56
|
@filings = results.map{|f| Filing.create(f)}
|
57
57
|
end
|
58
58
|
|
59
|
-
should "return
|
60
|
-
assert_equal @filings.size,
|
59
|
+
should "return 11 filings" do
|
60
|
+
assert_equal @filings.size, 11
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "committee unamended filings" do
|
65
|
+
setup do
|
66
|
+
reply = Base.invoke('2012/committees/C00431171/filings', {})
|
67
|
+
results = reply['results'].select{|f| f['amended'] == false}
|
68
|
+
@filings = results.map{|f| Filing.create(f)}
|
69
|
+
end
|
70
|
+
|
71
|
+
should "return filings that are not amended" do
|
72
|
+
assert_equal @filings.select{|f| f.amended == true}.size, 0
|
61
73
|
end
|
62
74
|
end
|
63
75
|
|
@@ -107,7 +119,6 @@ class TestCampaignCash::TestCommittee < Test::Unit::TestCase
|
|
107
119
|
should "return an array of super pacs" do
|
108
120
|
assert_equal([true], @committees.map{|c| c.super_pac }.uniq)
|
109
121
|
end
|
110
|
-
|
111
122
|
end
|
112
123
|
|
113
124
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campaign_cash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 2.3.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Derek Willis
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-22 00:00:00 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
21
|
name: json
|