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.
@@ -9,6 +9,7 @@ module CampaignCash
9
9
  API_VERSION = 'v3'
10
10
  API_NAME = 'elections/us'
11
11
  API_BASE = "/svc/#{API_NAME}/#{API_VERSION}/finances"
12
+ CURRENT_CYCLE = 2010
12
13
 
13
14
  @@api_key = nil
14
15
  @@copyright = nil
@@ -52,31 +52,31 @@ module CampaignCash
52
52
 
53
53
  end
54
54
 
55
- def self.find_by_fecid(cycle, fecid)
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(cycle, category)
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(cycle, name)
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(cycle, state, chamber, district=nil)
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.find_by_fecid(cycle, fecid)
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(cycle, name)
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)}
@@ -21,13 +21,13 @@ module CampaignCash
21
21
  end
22
22
 
23
23
  def self.today
24
- cycle = cycle_from_date
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.ymd(year, month, day)
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']
@@ -1,3 +1,3 @@
1
1
  module CampaignCash
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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(2010, 'RI', 'house')
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
- reply = Base.invoke("2010/filings/#{year}/#{month}/#{day}", {})
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
- reply = Base.invoke('2010/filings', {})
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
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-03 00:00:00 -05:00
18
+ date: 2010-12-23 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency