campaign_cash 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +61 -0
- data/campaign_cash.gemspec +2 -2
- data/lib/campaign_cash/candidate.rb +8 -1
- data/lib/campaign_cash/version.rb +1 -1
- data/test/campaign_cash/test_candidate.rb +9 -0
- metadata +6 -5
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= campaign_cash
|
2
|
+
|
3
|
+
* Docs[http://dwillis.github.com/campaign_cash/]
|
4
|
+
* Source[http://github.com/dwillis/campaign_cash]
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Simple ruby wrapper for The New York Times Campaign Finance API[http://developer.nytimes.com/docs/read/campaign_finance_api]. You'll need an API key.
|
9
|
+
|
10
|
+
== INSTALL:
|
11
|
+
|
12
|
+
* <tt>sudo gem install campaign_cash</tt>
|
13
|
+
|
14
|
+
== USAGE:
|
15
|
+
|
16
|
+
You'll want to set your API key as an environment variable in order to run the tests. Otherwise, you'll need to set it like so:
|
17
|
+
|
18
|
+
Base.api_key = YOUR_API_KEY
|
19
|
+
|
20
|
+
Currently there are methods to support retrieving candidates and committees, and every method requires at least one parameter,
|
21
|
+
the election cycle. Some examples:
|
22
|
+
|
23
|
+
> Candidate.find_by_fecid(2010,"H4NY07011") # find Gary Ackerman's details for the 2010 cycle
|
24
|
+
> Committee.search(2010, "Growth") # find all committees in the 2010 cycle with the word 'Growth' in the name.
|
25
|
+
|
26
|
+
Check out the tests for further examples.
|
27
|
+
|
28
|
+
== Note on Patches/Pull Requests
|
29
|
+
|
30
|
+
* Fork the project.
|
31
|
+
* Make your feature addition or bug fix.
|
32
|
+
* Add tests for it. This is important so I don't break it in a
|
33
|
+
future version unintentionally.
|
34
|
+
* Commit, do not mess with rakefile, version, or history.
|
35
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
36
|
+
* Send me a pull request. Bonus points for topic branches.
|
37
|
+
|
38
|
+
== LICENSE:
|
39
|
+
|
40
|
+
(The MIT License)
|
41
|
+
|
42
|
+
Copyright (c) 2010 Derek Willis
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
'Software'), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
58
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
59
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
60
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
61
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/campaign_cash.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ['Derek Willis']
|
9
9
|
s.email = ['dwillis@gmail.com']
|
10
10
|
s.homepage = "http://rubygems.org/gems/campaign_cash"
|
11
|
-
s.
|
12
|
-
s.
|
11
|
+
s.description = "A thin client for The New York Times Campaign Finance API"
|
12
|
+
s.summary = "Following the money."
|
13
13
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
s.rubyforge_project = "campaign_cash"
|
@@ -51,7 +51,7 @@ module CampaignCash
|
|
51
51
|
:committee => params['committee']
|
52
52
|
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def self.find_by_fecid(cycle, fecid)
|
56
56
|
reply = invoke("#{cycle}/candidates/#{fecid}")
|
57
57
|
result = reply['results']
|
@@ -76,5 +76,12 @@ module CampaignCash
|
|
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)
|
80
|
+
district ? path = "#{cycle}/seats/#{state}/#{chamber}/#{district}" : path = "#{cycle}/seats/#{state}/#{chamber}"
|
81
|
+
reply = invoke(path,{})
|
82
|
+
results = reply['results']
|
83
|
+
results.map{|c| self.create_from_api_search_results(c)}
|
84
|
+
end
|
85
|
+
|
79
86
|
end
|
80
87
|
end
|
@@ -71,4 +71,13 @@ class TestCampaignCash::TestCandidate < Test::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
context "state candidates" do
|
75
|
+
setup do
|
76
|
+
@candidates = Candidate.state_chamber(2010, 'RI', 'house')
|
77
|
+
end
|
78
|
+
|
79
|
+
should "return 29 House candidates from Rhode Island" do
|
80
|
+
assert_equal @candidates.size, 29
|
81
|
+
end
|
82
|
+
end
|
74
83
|
end
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Derek Willis
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 1.0.0
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
|
-
description:
|
37
|
+
description: A thin client for The New York Times Campaign Finance API
|
38
38
|
email:
|
39
39
|
- dwillis@gmail.com
|
40
40
|
executables: []
|
@@ -46,6 +46,7 @@ extra_rdoc_files: []
|
|
46
46
|
files:
|
47
47
|
- .gitignore
|
48
48
|
- Gemfile
|
49
|
+
- README.rdoc
|
49
50
|
- Rakefile
|
50
51
|
- campaign_cash.gemspec
|
51
52
|
- lib/campaign_cash.rb
|
@@ -91,6 +92,6 @@ rubyforge_project: campaign_cash
|
|
91
92
|
rubygems_version: 1.3.7
|
92
93
|
signing_key:
|
93
94
|
specification_version: 3
|
94
|
-
summary:
|
95
|
+
summary: Following the money.
|
95
96
|
test_files: []
|
96
97
|
|