opensecrets 0.0.3 → 0.0.4
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/README.rdoc +5 -0
- data/VERSION +1 -1
- data/examples/example.rb +11 -2
- data/lib/opensecrets.rb +35 -2
- data/opensecrets.gemspec +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -33,6 +33,11 @@ like to contribute please see : http://sunlightlabs.com/projects/opensecrets-rub
|
|
33
33
|
* API Documentation : http://rdoc.info/projects/grempe/opensecrets
|
34
34
|
* Report Bugs / Request Features : http://github.com/grempe/opensecrets/issues
|
35
35
|
|
36
|
+
|
37
|
+
== TODO
|
38
|
+
|
39
|
+
* Shoulda Tests. As there are currently none.
|
40
|
+
|
36
41
|
== Note on Patches/Pull Requests
|
37
42
|
|
38
43
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/examples/example.rb
CHANGED
@@ -6,10 +6,13 @@ require 'opensecrets'
|
|
6
6
|
require 'crack'
|
7
7
|
require 'pp'
|
8
8
|
|
9
|
+
|
10
|
+
# For convenience and security you can export an environment variable to hold your API key.
|
11
|
+
API_KEY = ENV['OPENSECRETS_API_KEY'] ||= 'YOUR_API_KEY'
|
9
12
|
CID = 'N00007360' # Nancy Pelosi
|
10
13
|
|
11
14
|
|
12
|
-
member = OpenSecrets::Member.new(
|
15
|
+
member = OpenSecrets::Member.new(API_KEY)
|
13
16
|
|
14
17
|
puts "\n\nMEMBER : PFD PROFILE\n\n"
|
15
18
|
pp member.pfd({:cid => CID, :year => '2008'})["response"]
|
@@ -18,7 +21,7 @@ puts "\n\nMEMBER : TRAVEL & TRIPS\n\n"
|
|
18
21
|
pp member.trips({:cid => CID, :year => '2008'})["response"]
|
19
22
|
|
20
23
|
|
21
|
-
cand = OpenSecrets::Candidate.new(
|
24
|
+
cand = OpenSecrets::Candidate.new(API_KEY)
|
22
25
|
|
23
26
|
puts "\n\nCANDIDATE : SUMMARY\n\n"
|
24
27
|
pp cand.summary({:cid => CID})["response"]
|
@@ -35,3 +38,9 @@ pp cand.contributions_by_industry({:cid => CID, :indcode => 'K01'})["response"]
|
|
35
38
|
puts "\n\nCANDIDATE : SECTOR\n\n"
|
36
39
|
pp cand.sector({:cid => CID})["response"]
|
37
40
|
|
41
|
+
|
42
|
+
com = OpenSecrets::Committee.new(API_KEY)
|
43
|
+
|
44
|
+
puts "\n\nCOMMITTEE\n\n"
|
45
|
+
pp com.by_industry({:cmte => 'HARM', :congno => '110', :indus => 'F10'})["response"]
|
46
|
+
|
data/lib/opensecrets.rb
CHANGED
@@ -45,7 +45,7 @@ module OpenSecrets
|
|
45
45
|
self.class.get("/", :query => options)
|
46
46
|
end
|
47
47
|
|
48
|
-
end
|
48
|
+
end # member
|
49
49
|
|
50
50
|
class Candidate
|
51
51
|
include HTTParty
|
@@ -129,7 +129,40 @@ module OpenSecrets
|
|
129
129
|
self.class.get("/", :query => options)
|
130
130
|
end
|
131
131
|
|
132
|
-
end
|
132
|
+
end # candidate
|
133
|
+
|
134
|
+
class Committee
|
135
|
+
include HTTParty
|
136
|
+
base_uri 'http://www.opensecrets.org/api'
|
137
|
+
default_params :output => 'xml'
|
138
|
+
format :xml
|
139
|
+
|
140
|
+
# OpenSecrets information about a specific committee.
|
141
|
+
#
|
142
|
+
# @option options [String] apikey ("") an OpenSecrets API Key
|
143
|
+
#
|
144
|
+
def initialize(apikey)
|
145
|
+
raise ArgumentError, 'You must provide an API Key' if apikey.blank?
|
146
|
+
self.class.default_params :apikey => apikey
|
147
|
+
end
|
148
|
+
|
149
|
+
# Provides summary fundraising information for a specific committee, industry and Congress number.
|
150
|
+
#
|
151
|
+
# See : http://www.opensecrets.org/api/?method=congCmteIndus&output=doc
|
152
|
+
#
|
153
|
+
# @option options [String] :cmte ("") Committee ID in CQ format
|
154
|
+
# @option options [String] :congno ("") Congress Number (like 110)
|
155
|
+
# @option options [String] :indus ("") Industry code
|
156
|
+
#
|
157
|
+
def by_industry(options = {})
|
158
|
+
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].blank?
|
159
|
+
raise ArgumentError, 'You must provide a :congno option' if options[:congno].blank?
|
160
|
+
raise ArgumentError, 'You must provide a :indus option' if options[:indus].blank?
|
161
|
+
options.merge!({:method => 'congCmteIndus'})
|
162
|
+
self.class.get("/", :query => options)
|
163
|
+
end
|
164
|
+
|
165
|
+
end # committee
|
133
166
|
|
134
167
|
end
|
135
168
|
|
data/opensecrets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{opensecrets}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Glenn Rempe"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-05}
|
13
13
|
s.description = %q{OpenSecrets are the best kind. Created as a community service as requested by the Sunlight Foundation.}
|
14
14
|
s.email = %q{glenn@rempe.us}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensecrets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glenn Rempe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|