campaign_cash 1.5 → 1.6
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/campaign_cash.gemspec +1 -1
- data/lib/campaign_cash/candidate.rb +28 -9
- data/lib/campaign_cash/version.rb +1 -1
- metadata +5 -5
data/campaign_cash.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = CampaignCash::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ['Derek Willis']
|
10
|
-
s.email = ['dwillis@
|
10
|
+
s.email = ['dwillis@nytimes.com']
|
11
11
|
s.homepage = "http://rubygems.org/gems/campaign_cash"
|
12
12
|
s.description = "A thin client for The New York Times Campaign Finance API"
|
13
13
|
s.summary = "Following the money."
|
@@ -4,12 +4,12 @@ module CampaignCash
|
|
4
4
|
# Represents a candidate object based on the FEC's candidate and candidate summary files.
|
5
5
|
# A candidate is a person seeking a particular office within a particular two-year election
|
6
6
|
# cycle. Each candidate is assigned a unique ID within a cycle.
|
7
|
-
attr_reader :name, :id, :state, :district, :party, :fec_uri, :
|
7
|
+
attr_reader :name, :id, :state, :district, :party, :fec_uri, :committee_id,
|
8
8
|
:mailing_city, :mailing_address, :mailing_state, :mailing_zip,
|
9
9
|
:total_receipts, :total_contributions, :total_from_individuals,
|
10
10
|
:total_from_pacs, :candidate_loans, :total_disbursements,
|
11
11
|
:total_refunds, :debts_owed, :begin_cash, :end_cash, :status,
|
12
|
-
:date_coverage_to, :date_coverage_from, :relative_uri
|
12
|
+
:date_coverage_to, :date_coverage_from, :relative_uri, :office
|
13
13
|
|
14
14
|
def initialize(params={})
|
15
15
|
params.each_pair do |k,v|
|
@@ -21,11 +21,12 @@ module CampaignCash
|
|
21
21
|
def self.create(params={})
|
22
22
|
self.new :name => params['name'],
|
23
23
|
:id => params['id'],
|
24
|
-
:state => params['state'],
|
25
|
-
:
|
24
|
+
:state => params['state'].split('/').last[0..1],
|
25
|
+
:office => parse_office(params['id'].first),
|
26
|
+
:district => parse_district(params['district']),
|
26
27
|
:party => params['party'],
|
27
28
|
:fec_uri => params['fec_uri'],
|
28
|
-
:
|
29
|
+
:committee_id => params['committee'].split('/').last[0..8],
|
29
30
|
:mailing_city => params['mailing_city'],
|
30
31
|
:mailing_address => params['mailing_address'],
|
31
32
|
:mailing_state => params['mailing_state'],
|
@@ -48,14 +49,32 @@ module CampaignCash
|
|
48
49
|
def self.create_from_search_results(params={})
|
49
50
|
self.new :name => params['candidate']['name'],
|
50
51
|
:id => params['candidate']['id'],
|
51
|
-
:state => params['state'],
|
52
|
-
:
|
52
|
+
:state => params['state'].split('/').last[0..1],
|
53
|
+
:office => parse_office(params['candidate']['id'].first),
|
54
|
+
:district => parse_district(params['district']),
|
53
55
|
:party => params['candidate']['party'],
|
54
|
-
:
|
55
|
-
:committee => params['committee']
|
56
|
+
:committee_id => params['committee'].split('/').last[0..8]
|
56
57
|
|
57
58
|
end
|
58
59
|
|
60
|
+
def self.parse_office(id)
|
61
|
+
if id.first == "H"
|
62
|
+
'house'
|
63
|
+
elsif id.first == 'S'
|
64
|
+
'senate'
|
65
|
+
else
|
66
|
+
'president'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.parse_district(uri)
|
71
|
+
if uri.split('/').last.split('.').first.to_i > 0
|
72
|
+
uri.split('/').last.split('.').first.to_i
|
73
|
+
else
|
74
|
+
0
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
59
78
|
# Retrieve a candidate object via its FEC candidate id within a cycle.
|
60
79
|
# Defaults to the current cycle.
|
61
80
|
def self.find(fecid, cycle=CURRENT_CYCLE)
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campaign_cash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 6
|
9
|
+
version: "1.6"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Derek Willis
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-12-
|
17
|
+
date: 2011-12-18 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version_requirements: *id002
|
50
50
|
description: A thin client for The New York Times Campaign Finance API
|
51
51
|
email:
|
52
|
-
- dwillis@
|
52
|
+
- dwillis@nytimes.com
|
53
53
|
executables: []
|
54
54
|
|
55
55
|
extensions: []
|