campaign_cash 2.3 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- campaign_cash (2.0.7)
4
+ campaign_cash (2.3)
5
5
  json
6
6
 
7
7
  GEM
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 and chamber within a cycle, with an optional
131
- # district parameter. For example, House candidates from New York. Defaults to the current cycle.
132
- def self.state_chamber(state, chamber, district=nil, cycle=CURRENT_CYCLE, offset=nil)
133
- district ? path = "#{cycle}/seats/#{state}/#{chamber}/#{district}" : path = "#{cycle}/seats/#{state}/#{chamber}"
134
- reply = invoke(path,{:offset => offset})
135
- results = reply['results']
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module CampaignCash
2
- VERSION = "2.3"
2
+ VERSION = "2.3.1"
3
3
  end
@@ -74,12 +74,20 @@ class TestCampaignCash::TestCandidate < Test::Unit::TestCase
74
74
  end
75
75
 
76
76
  context "state candidates" do
77
- setup do
78
- @candidates = Candidate.state_chamber('RI', 'house', nil, 2010)
79
- end
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 @candidates.size, 29
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 8 filings" do
60
- assert_equal @filings.size, 8
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: 5
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- version: "2.3"
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-15 00:00:00 Z
18
+ date: 2012-03-22 00:00:00 Z
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
21
  name: json