opensecrets 0.0.5 → 1.0.0
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.
- checksums.yaml +7 -0
- data/.document +3 -4
- data/.gitignore +16 -20
- data/.yardopts +1 -2
- data/Gemfile +4 -0
- data/LICENSE +18 -17
- data/README.md +71 -0
- data/Rakefile +7 -46
- data/SIGNED.md +83 -0
- data/examples/example.rb +13 -7
- data/lib/opensecrets.rb +53 -28
- data/lib/opensecrets/version.rb +5 -0
- data/opensecrets.gemspec +25 -59
- metadata +61 -81
- data/README.rdoc +0 -60
- data/test/helper.rb +0 -10
- data/test/test_opensecrets.rb +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79019e6b1090840c34d5bf0495980655530bcc65
|
4
|
+
data.tar.gz: f464caea7550d8c6e36ce17b4bbe7ea7e5b09579
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e20c06f815fd6498aba6a9c142546691304ba3098c6b47dfd1de0af3cdd89ae8b7488e92ed31a9cdf2234be7398358bb6d46aa86519aa90e17ffa5941c37398d
|
7
|
+
data.tar.gz: 4609a39ab2b4e2087c31adb25ef1098f8c69b20bea1b6d0629ca251c1bab03241f215b50745e7f2b12f27979415592b6cee25ba8d7dd9d8e8ae40136605243d8
|
data/.document
CHANGED
data/.gitignore
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
1
|
+
.ruby-version
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
17
10
|
coverage
|
18
|
-
doc
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
19
13
|
pkg
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
data/.yardopts
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
--title opensecrets - LICENSE
|
2
|
-
|
1
|
+
--title opensecrets - LICENSE README.md
|
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2009-2015 Glenn Rempe
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# OpenSecrets
|
2
|
+
|
3
|
+
## Description
|
4
|
+
A Ruby wrapper around the OpenSecrets.org API.
|
5
|
+
|
6
|
+
You will need to have an OpenSecrets.org API key before you can use this library.
|
7
|
+
|
8
|
+
See the [OpenSecrets API documentation](https://www.opensecrets.org/resources/create/api_doc.php).
|
9
|
+
|
10
|
+
This project was inspired by a project suggestion on the SunlightLabs.com website. If you would
|
11
|
+
like to contribute or learn more please see [https://sunlightfoundation.com/](https://sunlightfoundation.com/)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
gem install opensecrets
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
See `examples/example.rb` for more complete examples.
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'opensecrets'
|
23
|
+
require 'pp'
|
24
|
+
|
25
|
+
# Note, you can also provide your API key in an environment variable for security and convenience.
|
26
|
+
# export OPENSECRETS_API_KEY=YOUR_API_KEY
|
27
|
+
# If you provide your key this way you do not have to provide a key in the OpenSecrets::*.new constructors.
|
28
|
+
# A key provided to the constructor overrides any environment variable that is set.
|
29
|
+
|
30
|
+
member = OpenSecrets::Member.new('YOUR OPEN SECRETS API KEY')
|
31
|
+
pp member.pfd({:cid => 'N00007360', :year => '2008'})["response"]
|
32
|
+
|
33
|
+
cand = OpenSecrets::Candidate.new('YOUR OPEN SECRETS API KEY')
|
34
|
+
pp cand.summary({:cid => 'N00007360'})["response"]
|
35
|
+
|
36
|
+
com = OpenSecrets::Committee.new('YOUR OPEN SECRETS API KEY')
|
37
|
+
pp com.by_industry({:cmte => 'HARM', :congno => '110', :indus => 'F10'})["response"]
|
38
|
+
|
39
|
+
## Bug Reporting & Pull Requests
|
40
|
+
|
41
|
+
[https://github.com/grempe/opensecrets/issues](https://github.com/grempe/opensecrets/issues)
|
42
|
+
|
43
|
+
## Legal
|
44
|
+
|
45
|
+
### Copyright
|
46
|
+
|
47
|
+
(c) 2009-2015 Glenn Rempe
|
48
|
+
|
49
|
+
### License
|
50
|
+
|
51
|
+
Licensed under the MIT License;
|
52
|
+
you may not use this file except in compliance with the License.
|
53
|
+
You may obtain a copy of the License at
|
54
|
+
|
55
|
+
[http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)
|
56
|
+
|
57
|
+
### Warranty
|
58
|
+
|
59
|
+
Unless required by applicable law or agreed to in writing,
|
60
|
+
software distributed under the License is distributed on an
|
61
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
62
|
+
either express or implied. See the LICENSE file for the
|
63
|
+
specific language governing permissions and limitations under
|
64
|
+
the License.
|
65
|
+
|
66
|
+
## Authors
|
67
|
+
|
68
|
+
***Glenn Rempe***</br>
|
69
|
+
<glenn@rempe.us></br>
|
70
|
+
<http://www.rempe.us></br>
|
71
|
+
@grempe on Twitter</br>
|
data/Rakefile
CHANGED
@@ -1,53 +1,14 @@
|
|
1
|
-
|
2
|
-
require 'rake'
|
1
|
+
# -*- encoding: utf-8 -*-
|
3
2
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "opensecrets"
|
8
|
-
gem.summary = %Q{OpenSecrets.org API Ruby Wrapper}
|
9
|
-
gem.description = %Q{OpenSecrets are the best kind. Created as a community service as requested by the Sunlight Foundation.}
|
10
|
-
gem.email = "glenn@rempe.us"
|
11
|
-
gem.homepage = "http://github.com/grempe/opensecrets"
|
12
|
-
gem.authors = ["Glenn Rempe"]
|
13
|
-
gem.add_dependency "httparty", ">= 0.4.5"
|
14
|
-
gem.add_dependency "crack", ">= 0.1.4"
|
15
|
-
gem.add_development_dependency "shoulda", ">= 0"
|
16
|
-
gem.add_development_dependency "yard", ">= 0"
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'rake/testtask'
|
25
|
-
Rake::TestTask.new(:test) do |test|
|
26
|
-
test.libs << 'lib' << 'test'
|
27
|
-
test.pattern = 'test/**/test_*.rb'
|
28
|
-
test.verbose = true
|
29
|
-
end
|
30
|
-
|
31
|
-
begin
|
32
|
-
require 'rcov/rcovtask'
|
33
|
-
Rcov::RcovTask.new do |test|
|
34
|
-
test.libs << 'test'
|
35
|
-
test.pattern = 'test/**/test_*.rb'
|
36
|
-
test.verbose = true
|
37
|
-
end
|
38
|
-
rescue LoadError
|
39
|
-
task :rcov do
|
40
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install rcov"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
task :test => :check_dependencies
|
45
|
-
|
46
|
-
task :default => :test
|
3
|
+
require 'bundler/gem_tasks'
|
47
4
|
|
48
5
|
begin
|
49
6
|
require 'yard'
|
50
|
-
YARD::Rake::YardocTask.new
|
7
|
+
YARD::Rake::YardocTask.new do |t|
|
8
|
+
#t.files = ['lib/**/*.rb']
|
9
|
+
#t.options = ['--any', '--extra', '--opts']
|
10
|
+
#t.stats_options = ['--list-undoc']
|
11
|
+
end
|
51
12
|
rescue LoadError
|
52
13
|
task :yardoc do
|
53
14
|
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
data/SIGNED.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
##### Signed by https://keybase.io/grempe
|
2
|
+
```
|
3
|
+
-----BEGIN PGP SIGNATURE-----
|
4
|
+
|
5
|
+
iQIcBAABCgAGBQJVUYG9AAoJEOcWanfPl9CRG28QAJPwi8OuI1NAGoLS2c1T+oBE
|
6
|
+
VkFUO8L6/1bjgk90H/x9AS9h1BBVIeYT99aom/on2TmrIuP7PlnbN3d1QDYPSOK+
|
7
|
+
zjwamJrT4AS1RD95+cJKQfj5Bn7h/7Hz3J625tDN+gIRu0cm7SfQQqggPPA4i0H1
|
8
|
+
CyP1Dom3aZ+typ0N6Ihe7dXFL8eLpwuw/aljRgy3HFjMInWeAQlhRNvxlvg46V0w
|
9
|
+
d6Pj0z+A6eybzF4HyUz9ALvbtboXzyEsF32Rz8p2OwnXH89Nu9NciP9up89Ckfcw
|
10
|
+
gOJUfjOb0vkJ7IXqX6W8N8Jzulz/eEiYy/t7awOpHUJ12e5MERvidAcLfRTwZIQR
|
11
|
+
yT51tO/TcxaHOzL0KZz1dBAjubBioZoYumgWpZP6eHPD12wXYGpjb7oqXYgyJUCb
|
12
|
+
lb89970VNTo3uLiioIGpBImfK3WH4ODniiV8w1Bz7Jdy6SWhXE5T3VcuKLFOJdKC
|
13
|
+
2mP2j3vYWslSwX5R9W2xfqvisag8lCSzi2t//IWrFf1q9RpYrWHWOzOMXr+uvJHy
|
14
|
+
Npur3MVkpFF0TUwEEPc++bcYnwaeWPIBY/fpz6zg8gWGORUdnOZEltyHxbUzL/KE
|
15
|
+
3Kx62NGqzOtjBGAHaOqT6SwoLG2XJJSE6r8a/vJkMdb//RYnNruMx9k6ArsNrFD7
|
16
|
+
5Mb+Cy5CI0u10KGofsdK
|
17
|
+
=FpLR
|
18
|
+
-----END PGP SIGNATURE-----
|
19
|
+
|
20
|
+
```
|
21
|
+
|
22
|
+
<!-- END SIGNATURES -->
|
23
|
+
|
24
|
+
### Begin signed statement
|
25
|
+
|
26
|
+
#### Expect
|
27
|
+
|
28
|
+
```
|
29
|
+
size exec file contents
|
30
|
+
./
|
31
|
+
41 .document b43fbabc03d467142d83363d875bcab81a9fef72d3293ea8d85682e71d35b9ae
|
32
|
+
168 .gitignore cbf96ae3fecba78c775adf62469ecb1161fabf7cd336d166f2b695c02ec105de
|
33
|
+
40 .yardopts 4b8537d119d3f36003a39d17ad72f1084da2d904925a9eca4e1b8a9258716dc2
|
34
|
+
98 Gemfile 5184edc7cae42cd49ced95779a2035fa6b04edc686450034b7ed731ef2941037
|
35
|
+
1083 LICENSE 2ef4af99e0989630c65ad9ed28748e3219fba0796ab1f7ea7490bdebb5212fa4
|
36
|
+
2255 README.md 09c2b474541c1609894fb4d56726023ff8bef3c109e63b5f7fdf696388c02ddc
|
37
|
+
378 Rakefile 066bb53e4cc76b03705b6efc3630c6dc5e960a5df6d256dc3cd537ea80cc2abe
|
38
|
+
6 VERSION ae86e790678acc7fc14f18e559c2f8c4972634d5b1b74a2a297565b8c90f804a
|
39
|
+
examples/
|
40
|
+
1442 x example.rb a441ac6ad0fc56eca8ded4d38b936b1cd580a1676b8552d8856872a45f6f3f22
|
41
|
+
lib/
|
42
|
+
opensecrets/
|
43
|
+
70 version.rb d69ea2f4cebbfd6103b0a925b4e32a9e86e15b067c94423505e537a7ce90e874
|
44
|
+
7201 opensecrets.rb 5e25d0c3abe9a74389be3d59a4f3603cd348fbf7cf5cf0a459f38184b2d6aaea
|
45
|
+
1091 opensecrets.gemspec 35fe425b57b486fc4500833726e3e6b97dc9fda5490b1efb02cd900a10bb1575
|
46
|
+
```
|
47
|
+
|
48
|
+
#### Ignore
|
49
|
+
|
50
|
+
```
|
51
|
+
/SIGNED.md
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Presets
|
55
|
+
|
56
|
+
```
|
57
|
+
git # ignore .git and anything as described by .gitignore files
|
58
|
+
```
|
59
|
+
|
60
|
+
<!-- summarize version = 0.0.9 -->
|
61
|
+
|
62
|
+
### End signed statement
|
63
|
+
|
64
|
+
<hr>
|
65
|
+
|
66
|
+
#### Notes
|
67
|
+
|
68
|
+
With keybase you can sign any directory's contents, whether it's a git repo,
|
69
|
+
source code distribution, or a personal documents folder. It aims to replace the drudgery of:
|
70
|
+
|
71
|
+
1. comparing a zipped file to a detached statement
|
72
|
+
2. downloading a public key
|
73
|
+
3. confirming it is in fact the author's by reviewing public statements they've made, using it
|
74
|
+
|
75
|
+
All in one simple command:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
keybase dir verify
|
79
|
+
```
|
80
|
+
|
81
|
+
There are lots of options, including assertions for automating your checks.
|
82
|
+
|
83
|
+
For more info, check out https://keybase.io/docs/command_line/code_signing
|
data/examples/example.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) # only when running from gem source dir
|
5
5
|
require 'opensecrets'
|
6
|
-
require 'crack'
|
7
6
|
require 'pp'
|
8
7
|
|
9
8
|
|
@@ -17,11 +16,11 @@ CID = 'N00007360' # Nancy Pelosi
|
|
17
16
|
|
18
17
|
member = OpenSecrets::Member.new
|
19
18
|
|
20
|
-
puts "\n\nMEMBER :
|
21
|
-
pp member.
|
19
|
+
puts "\n\nMEMBER : GET LEGISLATORS\n\n"
|
20
|
+
pp member.get_legislators({:id => "CA"})["response"]
|
22
21
|
|
23
|
-
puts "\n\nMEMBER :
|
24
|
-
pp member.
|
22
|
+
puts "\n\nMEMBER : PFD PROFILE\n\n"
|
23
|
+
pp member.pfd({:cid => CID, :year => '2014'})["response"]
|
25
24
|
|
26
25
|
|
27
26
|
cand = OpenSecrets::Candidate.new
|
@@ -36,7 +35,7 @@ puts "\n\nCANDIDATE : INDUSTRIES\n\n"
|
|
36
35
|
pp cand.industries({:cid => CID})["response"]
|
37
36
|
|
38
37
|
puts "\n\nCANDIDATE : CONTRIBUTIONS BY SPECIFIC INDUSTRY\n\n"
|
39
|
-
pp cand.contributions_by_industry({:cid => CID, :
|
38
|
+
pp cand.contributions_by_industry({:cid => CID, :ind => 'K02'})["response"]
|
40
39
|
|
41
40
|
puts "\n\nCANDIDATE : SECTOR\n\n"
|
42
41
|
pp cand.sector({:cid => CID})["response"]
|
@@ -45,5 +44,12 @@ pp cand.sector({:cid => CID})["response"]
|
|
45
44
|
com = OpenSecrets::Committee.new
|
46
45
|
|
47
46
|
puts "\n\nCOMMITTEE\n\n"
|
48
|
-
pp com.by_industry({:cmte => 'HARM', :congno => '
|
47
|
+
pp com.by_industry({:cmte => 'HARM', :congno => '113', :indus => 'F10'})["response"]
|
48
|
+
|
49
|
+
org = OpenSecrets::Organization.new
|
50
|
+
|
51
|
+
puts "\n\nORGANIZATION : GET ORGANIZATIONS\n\n"
|
52
|
+
pp org.get_orgs({:org => 'people'})["response"]
|
49
53
|
|
54
|
+
puts "\n\nORGANIZATION : ORGANIZATION SUMMARY\n\n"
|
55
|
+
pp org.org_summary({:id => 'D000023248'})["response"]
|
data/lib/opensecrets.rb
CHANGED
@@ -18,7 +18,7 @@ module OpenSecrets
|
|
18
18
|
#
|
19
19
|
def initialize(apikey = nil)
|
20
20
|
key = apikey ||= ENV['OPENSECRETS_API_KEY']
|
21
|
-
raise ArgumentError, 'You must provide an API Key' if key.
|
21
|
+
raise ArgumentError, 'You must provide an API Key' if key.nil? || key.empty?
|
22
22
|
self.class.default_params :apikey => key
|
23
23
|
end
|
24
24
|
|
@@ -26,31 +26,29 @@ module OpenSecrets
|
|
26
26
|
|
27
27
|
class Member < OpenSecrets::Base
|
28
28
|
|
29
|
-
#
|
29
|
+
# Provides a list of Congressional legislators and associated attributes for specified subset (state, district or specific CID).
|
30
30
|
#
|
31
|
-
# See :
|
31
|
+
# See : https://www.opensecrets.org/api/?method=getLegislators&output=doc
|
32
32
|
#
|
33
|
-
# @option options [String] :
|
34
|
-
# @option options [String] :year ("") Get data for specified year.
|
33
|
+
# @option options [String] :id ("") two character state code, or 4 character district or specific CID
|
35
34
|
#
|
36
|
-
def
|
37
|
-
raise ArgumentError, 'You must provide a :
|
38
|
-
|
39
|
-
options.merge!({:method => 'memPFDprofile'})
|
35
|
+
def get_legislators(options = {})
|
36
|
+
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
|
37
|
+
options.merge!({:method => 'getLegislators'})
|
40
38
|
self.class.get("/", :query => options)
|
41
39
|
end
|
42
40
|
|
43
|
-
#
|
41
|
+
# Returns Personal Financial Disclosure (PFD) information for a member of Congress.
|
44
42
|
#
|
45
|
-
# See : http://www.opensecrets.org/api/?method=
|
43
|
+
# See : http://www.opensecrets.org/api/?method=memPFDprofile&output=doc
|
46
44
|
#
|
47
45
|
# @option options [String] :cid ("") a CRP CandidateID
|
48
46
|
# @option options [String] :year ("") Get data for specified year.
|
49
47
|
#
|
50
|
-
def
|
51
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
52
|
-
raise ArgumentError, 'You must provide a :year option' if options[:year].
|
53
|
-
options.merge!({:method => '
|
48
|
+
def pfd(options = {})
|
49
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
50
|
+
raise ArgumentError, 'You must provide a :year option' if options[:year].nil? || options[:year].empty?
|
51
|
+
options.merge!({:method => 'memPFDprofile'})
|
54
52
|
self.class.get("/", :query => options)
|
55
53
|
end
|
56
54
|
|
@@ -66,7 +64,7 @@ module OpenSecrets
|
|
66
64
|
# @option options [optional, String] :cycle ("") blank values returns current cycle.
|
67
65
|
#
|
68
66
|
def summary(options = {})
|
69
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
67
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
70
68
|
options.merge!({:method => 'candSummary'})
|
71
69
|
self.class.get("/", :query => options)
|
72
70
|
end
|
@@ -79,7 +77,7 @@ module OpenSecrets
|
|
79
77
|
# @option options [optional, String] :cycle ("") 2008 or 2010.
|
80
78
|
#
|
81
79
|
def contributors(options = {})
|
82
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
80
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
83
81
|
options.merge!({:method => 'candContrib'})
|
84
82
|
self.class.get("/", :query => options)
|
85
83
|
end
|
@@ -92,7 +90,7 @@ module OpenSecrets
|
|
92
90
|
# @option options [optional, String] :cycle ("") blank values returns current cycle.
|
93
91
|
#
|
94
92
|
def industries(options = {})
|
95
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
93
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
96
94
|
options.merge!({:method => 'candIndustry'})
|
97
95
|
self.class.get("/", :query => options)
|
98
96
|
end
|
@@ -102,13 +100,13 @@ module OpenSecrets
|
|
102
100
|
# See : http://www.opensecrets.org/api/?method=candIndByInd&output=doc
|
103
101
|
#
|
104
102
|
# @option options [String] :cid ("") a CRP CandidateID
|
105
|
-
# @option options [String] :
|
106
|
-
# @option options [optional, String] :cycle ("")
|
103
|
+
# @option options [String] :ind ("") a a 3-character industry code
|
104
|
+
# @option options [optional, String] :cycle ("") 2012, 2014 available. leave blank for latest cycle
|
107
105
|
#
|
108
106
|
def contributions_by_industry(options = {})
|
109
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
110
|
-
raise ArgumentError, 'You must provide a :
|
111
|
-
options.merge!({:method => '
|
107
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
108
|
+
raise ArgumentError, 'You must provide a :ind option' if options[:ind].nil? || options[:ind].empty?
|
109
|
+
options.merge!({:method => 'CandIndByInd'})
|
112
110
|
self.class.get("/", :query => options)
|
113
111
|
end
|
114
112
|
|
@@ -120,7 +118,7 @@ module OpenSecrets
|
|
120
118
|
# @option options [optional, String] :cycle ("") blank values returns current cycle.
|
121
119
|
#
|
122
120
|
def sector(options = {})
|
123
|
-
raise ArgumentError, 'You must provide a :cid option' if options[:cid].
|
121
|
+
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
|
124
122
|
options.merge!({:method => 'candSector'})
|
125
123
|
self.class.get("/", :query => options)
|
126
124
|
end
|
@@ -138,14 +136,41 @@ module OpenSecrets
|
|
138
136
|
# @option options [String] :indus ("") Industry code
|
139
137
|
#
|
140
138
|
def by_industry(options = {})
|
141
|
-
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].
|
142
|
-
raise ArgumentError, 'You must provide a :congno option' if options[:congno].
|
143
|
-
raise ArgumentError, 'You must provide a :indus option' if options[:indus].
|
139
|
+
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].nil? || options[:cmte].empty?
|
140
|
+
raise ArgumentError, 'You must provide a :congno option' if options[:congno].nil? || options[:congno].empty?
|
141
|
+
raise ArgumentError, 'You must provide a :indus option' if options[:indus].nil? || options[:indus].empty?
|
144
142
|
options.merge!({:method => 'congCmteIndus'})
|
145
143
|
self.class.get("/", :query => options)
|
146
144
|
end
|
147
145
|
|
148
146
|
end # committee
|
149
147
|
|
150
|
-
|
148
|
+
class Organization < OpenSecrets::Base
|
151
149
|
|
150
|
+
# Look up an organization by name.
|
151
|
+
#
|
152
|
+
# See : https://www.opensecrets.org/api/?method=getOrgs&output=doc
|
153
|
+
#
|
154
|
+
# @option options [String] :org ("") name or partial name of organization requested
|
155
|
+
#
|
156
|
+
def get_orgs(options = {})
|
157
|
+
raise ArgumentError, 'You must provide a :org option' if options[:org].nil? || options[:org].empty?
|
158
|
+
options.merge!({:method => 'getOrgs'})
|
159
|
+
self.class.get("/", :query => options)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Provides summary fundraising information for the specified organization id.
|
163
|
+
#
|
164
|
+
# See : https://www.opensecrets.org/api/?method=orgSummary&output=doc
|
165
|
+
#
|
166
|
+
# @option options [String] :org ("") CRP orgid (available via 'get_orgs' method)
|
167
|
+
#
|
168
|
+
def org_summary(options = {})
|
169
|
+
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
|
170
|
+
options.merge!({:method => 'orgSummary'})
|
171
|
+
self.class.get("/", :query => options)
|
172
|
+
end
|
173
|
+
|
174
|
+
end # organization
|
175
|
+
|
176
|
+
end
|
data/opensecrets.gemspec
CHANGED
@@ -1,66 +1,32 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'opensecrets/version'
|
6
|
+
|
6
7
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
8
|
+
s.name = "opensecrets"
|
9
|
+
s.version = OpenSecrets::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ["Glenn Rempe"]
|
12
|
+
s.email = ["glenn@rempe.us"]
|
13
|
+
s.homepage = "http://github.com/grempe/opensecrets"
|
14
|
+
s.summary = %q{OpenSecrets.org API Ruby Wrapper}
|
15
|
+
s.license = "MIT"
|
9
16
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = %q{2009-11-05}
|
13
|
-
s.description = %q{OpenSecrets are the best kind. Created as a community service as requested by the Sunlight Foundation.}
|
14
|
-
s.email = %q{glenn@rempe.us}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
".yardopts",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"examples/example.rb",
|
28
|
-
"lib/opensecrets.rb",
|
29
|
-
"opensecrets.gemspec",
|
30
|
-
"test/helper.rb",
|
31
|
-
"test/test_opensecrets.rb"
|
32
|
-
]
|
33
|
-
s.homepage = %q{http://github.com/grempe/opensecrets}
|
34
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
-
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.3.5}
|
37
|
-
s.summary = %q{OpenSecrets.org API Ruby Wrapper}
|
38
|
-
s.test_files = [
|
39
|
-
"test/helper.rb",
|
40
|
-
"test/test_opensecrets.rb",
|
41
|
-
"examples/example.rb"
|
42
|
-
]
|
17
|
+
s.has_rdoc = 'true'
|
18
|
+
s.extra_rdoc_files = ['README.md']
|
43
19
|
|
44
|
-
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
20
|
+
s.rubyforge_project = "opensecrets"
|
47
21
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
s.add_dependency(%q<crack>, [">= 0.1.4"])
|
56
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
57
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
58
|
-
end
|
59
|
-
else
|
60
|
-
s.add_dependency(%q<httparty>, [">= 0.4.5"])
|
61
|
-
s.add_dependency(%q<crack>, [">= 0.1.4"])
|
62
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
63
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
64
|
-
end
|
65
|
-
end
|
22
|
+
s.files = `git ls-files`.split($/)
|
23
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
|
27
|
+
s.add_dependency 'httparty', '~> 0.13.3'
|
28
|
+
s.add_development_dependency 'yard'
|
66
29
|
|
30
|
+
s.description = "OpenSecrets are the best kind. Created as a community service as requested by the Sunlight Foundation."
|
31
|
+
|
32
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensecrets
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Glenn Rempe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.3
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: crack
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.4
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: shoulda
|
37
|
-
type: :development
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: "0"
|
44
|
-
version:
|
45
|
-
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
46
28
|
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
47
34
|
type: :development
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
51
38
|
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version:
|
54
|
-
|
55
|
-
|
56
|
-
email:
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: OpenSecrets are the best kind. Created as a community service as requested
|
42
|
+
by the Sunlight Foundation.
|
43
|
+
email:
|
44
|
+
- glenn@rempe.us
|
57
45
|
executables: []
|
58
|
-
|
59
46
|
extensions: []
|
60
|
-
|
61
|
-
|
47
|
+
extra_rdoc_files:
|
48
|
+
- README.md
|
49
|
+
files:
|
50
|
+
- ".document"
|
51
|
+
- ".gitignore"
|
52
|
+
- ".yardopts"
|
53
|
+
- Gemfile
|
62
54
|
- LICENSE
|
63
|
-
- README.
|
64
|
-
files:
|
65
|
-
- .document
|
66
|
-
- .gitignore
|
67
|
-
- .yardopts
|
68
|
-
- LICENSE
|
69
|
-
- README.rdoc
|
55
|
+
- README.md
|
70
56
|
- Rakefile
|
57
|
+
- SIGNED.md
|
71
58
|
- VERSION
|
72
59
|
- examples/example.rb
|
73
60
|
- lib/opensecrets.rb
|
61
|
+
- lib/opensecrets/version.rb
|
74
62
|
- opensecrets.gemspec
|
75
|
-
- test/helper.rb
|
76
|
-
- test/test_opensecrets.rb
|
77
|
-
has_rdoc: true
|
78
63
|
homepage: http://github.com/grempe/opensecrets
|
79
|
-
licenses:
|
80
|
-
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
81
67
|
post_install_message:
|
82
|
-
rdoc_options:
|
83
|
-
|
84
|
-
require_paths:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
85
70
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
88
73
|
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
-
|
92
|
-
|
93
|
-
requirements:
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
94
78
|
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
version:
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
98
81
|
requirements: []
|
99
|
-
|
100
|
-
|
101
|
-
rubygems_version: 1.3.5
|
82
|
+
rubyforge_project: opensecrets
|
83
|
+
rubygems_version: 2.4.5
|
102
84
|
signing_key:
|
103
|
-
specification_version:
|
85
|
+
specification_version: 4
|
104
86
|
summary: OpenSecrets.org API Ruby Wrapper
|
105
|
-
test_files:
|
106
|
-
|
107
|
-
- test/test_opensecrets.rb
|
108
|
-
- examples/example.rb
|
87
|
+
test_files: []
|
88
|
+
has_rdoc: 'true'
|
data/README.rdoc
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
= opensecrets
|
2
|
-
|
3
|
-
A Ruby wrapper around the OpenSecrets.org API.
|
4
|
-
|
5
|
-
You will need to have an OpenSecrets.org API key before you can use this library.
|
6
|
-
|
7
|
-
See the OpenSecrets API documentation at : http://www.opensecrets.org/action/api_doc.php
|
8
|
-
|
9
|
-
This project was inspired by a project suggestion on the SunlightLabs.com website. If you would
|
10
|
-
like to contribute please see : http://sunlightlabs.com/projects/opensecrets-ruby/
|
11
|
-
|
12
|
-
== Installation
|
13
|
-
|
14
|
-
[sudo] gem install opensecrets
|
15
|
-
|
16
|
-
== Usage
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
require 'opensecrets'
|
20
|
-
require 'crack'
|
21
|
-
require 'pp'
|
22
|
-
|
23
|
-
# Note, you can also provide your API key in an environment variable for security and convenience.
|
24
|
-
# export OPENSECRETS_API_KEY=YOUR_API_KEY
|
25
|
-
# If you provide your key this way you do not have to provide a key in the OpenSecrets::*.new constructors.
|
26
|
-
# A key provided to the constructor overrides any environment variable that is set.
|
27
|
-
|
28
|
-
member = OpenSecrets::Member.new('YOUR OPEN SECRETS API KEY')
|
29
|
-
pp member.pfd({:cid => 'N00007360', :year => '2008'})["response"]
|
30
|
-
|
31
|
-
cand = OpenSecrets::Candidate.new('YOUR OPEN SECRETS API KEY')
|
32
|
-
pp cand.summary({:cid => 'N00007360'})["response"]
|
33
|
-
|
34
|
-
com = OpenSecrets::Committee.new('YOUR OPEN SECRETS API KEY')
|
35
|
-
pp com.by_industry({:cmte => 'HARM', :congno => '110', :indus => 'F10'})["response"]
|
36
|
-
|
37
|
-
|
38
|
-
== Project Websites
|
39
|
-
|
40
|
-
* Project Home : http://github.com/grempe/opensecrets/tree/master
|
41
|
-
* API Documentation : http://rdoc.info/projects/grempe/opensecrets
|
42
|
-
* Report Bugs / Request Features : http://github.com/grempe/opensecrets/issues
|
43
|
-
|
44
|
-
|
45
|
-
== TODO
|
46
|
-
|
47
|
-
* Shoulda Tests. As there are currently none.
|
48
|
-
|
49
|
-
== Note on Patches/Pull Requests
|
50
|
-
|
51
|
-
* Fork the project.
|
52
|
-
* Make your feature addition or bug fix.
|
53
|
-
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
54
|
-
* Commit, do not mess with rakefile, version, or history.
|
55
|
-
* Send me a pull request. Bonus points for topic branches.
|
56
|
-
|
57
|
-
== Copyright
|
58
|
-
|
59
|
-
Copyright (c) 2009 Glenn Rempe. See LICENSE for details.
|
60
|
-
|
data/test/helper.rb
DELETED