campaign_cash 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/campaign_cash/base.rb +1 -0
- data/lib/campaign_cash/candidate.rb +5 -5
- data/lib/campaign_cash/committee.rb +3 -3
- data/lib/campaign_cash/filing.rb +2 -2
- data/lib/campaign_cash/version.rb +1 -1
- data/test/campaign_cash/test_candidate.rb +1 -1
- data/test/campaign_cash/test_filing.rb +2 -12
- metadata +4 -4
data/lib/campaign_cash/base.rb
CHANGED
@@ -52,31 +52,31 @@ module CampaignCash
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
def self.
|
55
|
+
def self.find(fecid, cycle=CURRENT_CYCLE)
|
56
56
|
reply = invoke("#{cycle}/candidates/#{fecid}")
|
57
57
|
result = reply['results']
|
58
58
|
self.create_from_api(result.first) if result.first
|
59
59
|
end
|
60
60
|
|
61
|
-
def self.leaders(
|
61
|
+
def self.leaders(category, cycle=CURRENT_CYCLE)
|
62
62
|
reply = invoke("#{cycle}/candidates/leaders/#{category}",{})
|
63
63
|
results = reply['results']
|
64
64
|
results.map{|c| self.create_from_api(c)}
|
65
65
|
end
|
66
66
|
|
67
|
-
def self.search(
|
67
|
+
def self.search(name, cycle=CURRENT_CYCLE)
|
68
68
|
reply = invoke("#{cycle}/candidates/search", {:query => name})
|
69
69
|
results = reply['results']
|
70
70
|
results.map{|c| self.create_from_api_search_results(c)}
|
71
71
|
end
|
72
72
|
|
73
|
-
def self.new_candidates(cycle)
|
73
|
+
def self.new_candidates(cycle=CURRENT_CYCLE)
|
74
74
|
reply = invoke("#{cycle}/candidates/new",{})
|
75
75
|
results = reply['results']
|
76
76
|
results.map{|c| self.create_from_api(c)}
|
77
77
|
end
|
78
78
|
|
79
|
-
def self.state_chamber(
|
79
|
+
def self.state_chamber(state, chamber, district=nil, cycle=CURRENT_CYCLE)
|
80
80
|
district ? path = "#{cycle}/seats/#{state}/#{chamber}/#{district}" : path = "#{cycle}/seats/#{state}/#{chamber}"
|
81
81
|
reply = invoke(path,{})
|
82
82
|
results = reply['results']
|
@@ -52,19 +52,19 @@ module CampaignCash
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
def self.
|
55
|
+
def self.find(fecid, cycle=CURRENT_CYCLE)
|
56
56
|
reply = invoke("#{cycle}/committees/#{fecid}")
|
57
57
|
result = reply['results']
|
58
58
|
self.create_from_api(result.first) if result.first
|
59
59
|
end
|
60
60
|
|
61
|
-
def self.search(
|
61
|
+
def self.search(name, cycle=CURRENT_CYCLE)
|
62
62
|
reply = invoke("#{cycle}/committees/search", {:query => name})
|
63
63
|
results = reply['results']
|
64
64
|
results.map{|c| self.create_from_api_search_results(c)}
|
65
65
|
end
|
66
66
|
|
67
|
-
def self.new_candidates(cycle)
|
67
|
+
def self.new_candidates(cycle=CURRENT_CYCLE)
|
68
68
|
reply = invoke("#{cycle}/committees/new",{})
|
69
69
|
results = reply['results']
|
70
70
|
results.map{|c| self.create_from_api(c)}
|
data/lib/campaign_cash/filing.rb
CHANGED
@@ -21,13 +21,13 @@ module CampaignCash
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.today
|
24
|
-
cycle
|
24
|
+
cycle=CURRENT_CYCLE
|
25
25
|
reply = Base.invoke("#{cycle}/filings", {})
|
26
26
|
results = reply['results']
|
27
27
|
@filings = results.map{|c| Filing.create_from_api(c)}
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.
|
30
|
+
def self.date(year, month, day)
|
31
31
|
cycle = cycle_from_date(Date.parse("#{month}/#{day}/#{year}"))
|
32
32
|
reply = Base.invoke("#{cycle}/filings/#{year}/#{month}/#{day}", {})
|
33
33
|
results = reply['results']
|
@@ -73,7 +73,7 @@ class TestCampaignCash::TestCandidate < Test::Unit::TestCase
|
|
73
73
|
|
74
74
|
context "state candidates" do
|
75
75
|
setup do
|
76
|
-
@candidates = Candidate.state_chamber(
|
76
|
+
@candidates = Candidate.state_chamber('RI', 'house', nil, 2010)
|
77
77
|
end
|
78
78
|
|
79
79
|
should "return 29 House candidates from Rhode Island" do
|
@@ -6,27 +6,17 @@ class TestCampaignCash::TestFiling < Test::Unit::TestCase
|
|
6
6
|
context "a day" do
|
7
7
|
setup do
|
8
8
|
month, day, year = "11", "27", "2010"
|
9
|
-
|
10
|
-
@results = reply['results']
|
11
|
-
@filings = @results.map{|c| Filing.create_from_api(c)}
|
9
|
+
@filings = Filing.date(year, month, day)
|
12
10
|
end
|
13
11
|
|
14
12
|
should "return a list of objects of the Filing type" do
|
15
13
|
assert_kind_of(Filing, @filings.first)
|
16
14
|
end
|
17
|
-
|
18
|
-
%w(committee_name fec_uri committee amended).each do |attr|
|
19
|
-
should "assign the value of the @#{attr} attribute from the '#{attr}' key in the hash" do
|
20
|
-
assert_equal(@results.first[attr], @filings.first.send(attr))
|
21
|
-
end
|
22
|
-
end
|
23
15
|
end
|
24
16
|
|
25
17
|
context "today's filings" do
|
26
18
|
setup do
|
27
|
-
|
28
|
-
@results = reply['results']
|
29
|
-
@filings = @results.map{|c| Filing.create_from_api(c)}
|
19
|
+
@filings = Filing.today
|
30
20
|
end
|
31
21
|
|
32
22
|
should "return a list of objects of the Filing type" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campaign_cash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Derek Willis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|