propublica-nonprofits 0.1.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/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +104 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +6 -0
- data/lib/propublica/nonprofits.rb +33 -0
- data/lib/propublica/nonprofits/organization.rb +72 -0
- data/lib/propublica/nonprofits/organization/basic_parser.rb +11 -0
- data/lib/propublica/nonprofits/organization/details_parser.rb +17 -0
- data/lib/propublica/nonprofits/organization/dynamic_parser.rb +33 -0
- data/lib/propublica/nonprofits/organization/filings_with_data_parser.rb +27 -0
- data/lib/propublica/nonprofits/organization/filings_without_data_parser.rb +9 -0
- data/lib/propublica/nonprofits/version.rb +5 -0
- data/propublica-nonprofits.gemspec +35 -0
- metadata +176 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6f1548a6ab99d0cc5bc651916c1591c0339b0644531533e507f9a1395fd21aa1
|
|
4
|
+
data.tar.gz: f991cc23ad0289a3ff680f7be2bae80930b6e1777ca990917b4302e815674c73
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5fa50cbfdd4a595c2772a97080be6cf71e465e1263e7b902916b142f849e8cd38522c9ce42acce04ac28d20597a1b6196189ec4c8e3f27280b5703dab3954038
|
|
7
|
+
data.tar.gz: 6292726cce32f0e3a403c29dd5e7fca49accfa43c45e8d2a5bc2e978fc0774ffd3bc880d75d7580ca24c0e5838f34a75ddf4b638a1e4040b0e9053781a94ae12
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at ricky@rakefire.io. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
propublica-nonprofits (0.1.0)
|
|
5
|
+
faraday
|
|
6
|
+
json
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.5.2)
|
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
13
|
+
coderay (1.1.2)
|
|
14
|
+
crack (0.4.3)
|
|
15
|
+
safe_yaml (~> 1.0.0)
|
|
16
|
+
faraday (0.15.2)
|
|
17
|
+
multipart-post (>= 1.2, < 3)
|
|
18
|
+
hashdiff (0.3.7)
|
|
19
|
+
json (2.1.0)
|
|
20
|
+
method_source (0.9.0)
|
|
21
|
+
minitest (5.11.3)
|
|
22
|
+
multipart-post (2.0.0)
|
|
23
|
+
pry (0.11.3)
|
|
24
|
+
coderay (~> 1.1.0)
|
|
25
|
+
method_source (~> 0.9.0)
|
|
26
|
+
public_suffix (3.0.2)
|
|
27
|
+
rake (10.5.0)
|
|
28
|
+
safe_yaml (1.0.4)
|
|
29
|
+
vcr (4.0.0)
|
|
30
|
+
webmock (3.4.2)
|
|
31
|
+
addressable (>= 2.3.6)
|
|
32
|
+
crack (>= 0.3.2)
|
|
33
|
+
hashdiff
|
|
34
|
+
|
|
35
|
+
PLATFORMS
|
|
36
|
+
ruby
|
|
37
|
+
|
|
38
|
+
DEPENDENCIES
|
|
39
|
+
bundler (~> 1.16)
|
|
40
|
+
minitest (~> 5.0)
|
|
41
|
+
propublica-nonprofits!
|
|
42
|
+
pry
|
|
43
|
+
rake (~> 10.0)
|
|
44
|
+
vcr
|
|
45
|
+
webmock
|
|
46
|
+
|
|
47
|
+
BUNDLED WITH
|
|
48
|
+
1.16.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Rakefire LLC
|
|
4
|
+
|
|
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:
|
|
11
|
+
|
|
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,104 @@
|
|
|
1
|
+
[](https://travis-ci.org/Rakefire/propublica-nonprofits)
|
|
2
|
+
|
|
3
|
+
# Propublica::Nonprofits
|
|
4
|
+
|
|
5
|
+
Simple wrapper around the ProPublica Nonprofits API database API.
|
|
6
|
+
|
|
7
|
+
https://projects.propublica.org/nonprofits/api/
|
|
8
|
+
|
|
9
|
+
In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/propublica/nonprofits`. To experiment with that code, run `bin/console` for an interactive prompt. To test that code, run `bin/test` to run the test suite.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add this line to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'propublica-nonprofits'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
And then execute:
|
|
20
|
+
|
|
21
|
+
$ bundle
|
|
22
|
+
|
|
23
|
+
Or install it yourself as:
|
|
24
|
+
|
|
25
|
+
$ gem install propublica-nonprofits
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Search
|
|
30
|
+
To search the API and return an array of Propublica::Nonprofits::Objects, use the following:
|
|
31
|
+
|
|
32
|
+
results = Propublica::Nonprofits.search("rural action inc")
|
|
33
|
+
result = results.first
|
|
34
|
+
|
|
35
|
+
result.basic.ein # the basic parser is used by default for a search
|
|
36
|
+
|
|
37
|
+
# If desiring more details, you can call .details, .filings_with_data,
|
|
38
|
+
# .data_source, .api_version, or .error and another API call is triggered
|
|
39
|
+
# to fetch all data
|
|
40
|
+
result.details.deductibility_code
|
|
41
|
+
result.filings_with_data.first.totassetsend
|
|
42
|
+
|
|
43
|
+
*Note: This will currently only return the first 100 organizations*
|
|
44
|
+
*Note: This is returned as a Enumerator::Lazy, to be as memory efficient as possible, if you do something like `Propublica::Nonprofits.search("rural").first(10)`*
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### EIN Lookup - As Organization
|
|
48
|
+
To look up an organization by its ein and return all details, use the following:
|
|
49
|
+
|
|
50
|
+
ein = 311124220
|
|
51
|
+
org = Propublica::Nonprofits.find(ein)
|
|
52
|
+
|
|
53
|
+
org.details.name
|
|
54
|
+
org.details.activity_codes
|
|
55
|
+
org.details.income_amount
|
|
56
|
+
org.details.revenue_amount
|
|
57
|
+
|
|
58
|
+
org.filings_with_data
|
|
59
|
+
org.filings_without_data
|
|
60
|
+
|
|
61
|
+
org.data_source
|
|
62
|
+
org.api_version
|
|
63
|
+
org.error
|
|
64
|
+
|
|
65
|
+
# To explore what fields are returned
|
|
66
|
+
org.details.fields
|
|
67
|
+
org.filings_with_data.first.fields
|
|
68
|
+
org.filings_without_data.first.fields
|
|
69
|
+
|
|
70
|
+
*Note: This will return an organization, with details, filings_with_data, and filings_without_data*
|
|
71
|
+
|
|
72
|
+
### EIN Lookup - As Hash
|
|
73
|
+
|
|
74
|
+
If you need a more simplified data structure to pluck out just one or two fields,
|
|
75
|
+
consider using the `find_attributes` method.
|
|
76
|
+
|
|
77
|
+
ein = 311124220
|
|
78
|
+
attributes = Propublica::Nonprofits.find_attributes(ein)
|
|
79
|
+
|
|
80
|
+
attributes.dig("organization", "name")
|
|
81
|
+
attributes.dig("filings_without_data").first.dig("pdf_url")
|
|
82
|
+
|
|
83
|
+
## TODO
|
|
84
|
+
|
|
85
|
+
- Add more robust searching parameters https://projects.propublica.org/nonprofits/api/#endpoint-search-example
|
|
86
|
+
- Handle paginated search results (with Enumerator::Lazy)
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
91
|
+
|
|
92
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
93
|
+
|
|
94
|
+
## Contributing
|
|
95
|
+
|
|
96
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/propublica-nonprofits. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
101
|
+
|
|
102
|
+
## Code of Conduct
|
|
103
|
+
|
|
104
|
+
Everyone interacting in the Propublica::Nonprofits project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Rakefire/propublica-nonprofits/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "propublica/nonprofits"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/test
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "propublica/nonprofits/version"
|
|
2
|
+
require "propublica/nonprofits/organization"
|
|
3
|
+
|
|
4
|
+
require 'faraday'
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
API_BASE_URL = %(https://projects.propublica.org/nonprofits/api/v2)
|
|
8
|
+
|
|
9
|
+
module Propublica
|
|
10
|
+
module Nonprofits
|
|
11
|
+
def self.search(term)
|
|
12
|
+
response = Faraday.get("#{API_BASE_URL}/search.json?q='#{term}'")
|
|
13
|
+
attributes = JSON.parse(response.body)
|
|
14
|
+
organizations = attributes.dig("organizations")
|
|
15
|
+
organizations.lazy.map do |basic_attrs|
|
|
16
|
+
Propublica::Nonprofits::Organization.new("basic" => basic_attrs)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.find(ein)
|
|
21
|
+
attributes = self.find_attributes(ein)
|
|
22
|
+
Propublica::Nonprofits::Organization.new(attributes)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.find_attributes(ein)
|
|
26
|
+
response = Faraday.get("#{API_BASE_URL}/organizations/#{ein}.json")
|
|
27
|
+
JSON.parse(response.body)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Error < StandardError; end
|
|
31
|
+
class DataNotFetched < Error; end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module Propublica
|
|
2
|
+
module Nonprofits
|
|
3
|
+
class Organization
|
|
4
|
+
attr_reader :basic
|
|
5
|
+
|
|
6
|
+
def initialize(attributes)
|
|
7
|
+
@attributes = attributes
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def basic
|
|
11
|
+
@basic ||= BasicParser.new(attributes["basic"])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def details
|
|
15
|
+
ensure_full_request!
|
|
16
|
+
@details ||= DetailsParser.new(attributes["organization"])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def filings_with_data
|
|
20
|
+
ensure_full_request!
|
|
21
|
+
@filings_with_data ||= attributes["filings_with_data"].map { |f| FilingsWithDataParser.new(f) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def filings_without_data
|
|
25
|
+
ensure_full_request!
|
|
26
|
+
@filings_without_data ||= attributes["filings_without_data"].map { |f| FilingsWithoutDataParser.new(f) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def data_source
|
|
30
|
+
ensure_full_request!
|
|
31
|
+
@data_source ||= attributes["data_source"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def api_version
|
|
35
|
+
ensure_full_request!
|
|
36
|
+
@api_version ||= attributes["api_version"]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def error
|
|
40
|
+
ensure_full_request!
|
|
41
|
+
@error ||= attributes["error"]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
attr_reader :attributes
|
|
47
|
+
|
|
48
|
+
def ensure_full_request!
|
|
49
|
+
return if @full_request == true
|
|
50
|
+
|
|
51
|
+
required_keys = ["organization", "filings_with_data", "filings_without_data", "data_source", "api_version", "error"].freeze
|
|
52
|
+
@full_request = (attributes.keys & required_keys) == required_keys
|
|
53
|
+
return if @full_request == true
|
|
54
|
+
|
|
55
|
+
fetch_full_request!
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def fetch_full_request!
|
|
59
|
+
# Fetch all attributes and merge with what we have now
|
|
60
|
+
new_attrs = Propublica::Nonprofits.find_attributes(self.basic.ein)
|
|
61
|
+
attributes.merge!(new_attrs)
|
|
62
|
+
@full_request = true
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
require "propublica/nonprofits/organization/dynamic_parser"
|
|
69
|
+
require "propublica/nonprofits/organization/basic_parser"
|
|
70
|
+
require "propublica/nonprofits/organization/details_parser"
|
|
71
|
+
require "propublica/nonprofits/organization/filings_with_data_parser"
|
|
72
|
+
require "propublica/nonprofits/organization/filings_without_data_parser"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Propublica
|
|
2
|
+
module Nonprofits
|
|
3
|
+
class Organization
|
|
4
|
+
class BasicParser < DynamicParser
|
|
5
|
+
fields :ein, :strein, :name, :sub_name, :city, :state, :ntee_code,
|
|
6
|
+
:raw_ntee_code, :subseccd, :has_subseccd, :have_filings, :have_extracts,
|
|
7
|
+
:have_pdfs, :score
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Propublica
|
|
2
|
+
module Nonprofits
|
|
3
|
+
class Organization
|
|
4
|
+
class DetailsParser < DynamicParser
|
|
5
|
+
fields :id, :ein, :name, :careofname, :address, :city, :state,
|
|
6
|
+
:zipcode, :exemption_number, :subsection_code, :affiliation_code,
|
|
7
|
+
:classification_codes, :ruling_date, :deductibility_code,
|
|
8
|
+
:foundation_code, :activity_codes, :organization_code,
|
|
9
|
+
:exempt_organization_status_code, :tax_period, :asset_code,
|
|
10
|
+
:income_code, :filing_requirement_code, :pf_filing_requirement_code,
|
|
11
|
+
:accounting_period, :asset_amount, :income_amount, :revenue_amount,
|
|
12
|
+
:ntee_code, :sort_name, :created_at, :updated_at, :data_source,
|
|
13
|
+
:have_extracts, :have_pdfs
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Propublica
|
|
2
|
+
module Nonprofits
|
|
3
|
+
class Organization
|
|
4
|
+
class DynamicParser
|
|
5
|
+
def self.fields(*fields)
|
|
6
|
+
@fields = fields
|
|
7
|
+
fields.each do |field|
|
|
8
|
+
define_method field do
|
|
9
|
+
vars = self.instance_variable_get("@attributes")
|
|
10
|
+
vars.fetch(field.to_s) do
|
|
11
|
+
class_name = self.class.to_s.split("::").last
|
|
12
|
+
raise Propublica::Nonprofits::DataNotFetched,
|
|
13
|
+
"#{class_name}##{field} not fetched from API. This may be due to an API error or because you tried to access a Basic property on the full results"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize(attributes)
|
|
20
|
+
@attributes = attributes || {}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def fields
|
|
24
|
+
self.class.instance_variable_get("@fields")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
attr_reader :attributes
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Propublica
|
|
2
|
+
module Nonprofits
|
|
3
|
+
class Organization
|
|
4
|
+
class FilingsWithDataParser < DynamicParser
|
|
5
|
+
fields :tax_prd, :tax_prd_yr, :formtype, :pdf_url, :updated,
|
|
6
|
+
:totrevenue, :totfuncexpns, :totassetsend, :totliabend,
|
|
7
|
+
:pct_compnsatncurrofcr, :tax_pd, :subseccd, :unrelbusinccd,
|
|
8
|
+
:initiationfees, :grsrcptspublicuse, :grsincmembers,
|
|
9
|
+
:grsincother, :totcntrbgfts, :totprgmrevnue, :invstmntinc,
|
|
10
|
+
:txexmptbndsproceeds, :royaltsinc, :grsrntsreal,
|
|
11
|
+
:grsrntsprsnl, :rntlexpnsreal, :rntlexpnsprsnl, :rntlincreal,
|
|
12
|
+
:rntlincprsnl, :netrntlinc, :grsalesecur, :grsalesothr,
|
|
13
|
+
:cstbasisecur, :cstbasisothr, :gnlsecur, :gnlsothr, :netgnls,
|
|
14
|
+
:grsincfndrsng, :lessdirfndrsng, :netincfndrsng,
|
|
15
|
+
:grsincgaming, :lessdirgaming, :netincgaming,
|
|
16
|
+
:grsalesinvent, :lesscstofgoods, :netincsales,
|
|
17
|
+
:miscrevtot11e, :compnsatncurrofcr, :othrsalwages, :payrolltx,
|
|
18
|
+
:profndraising, :txexmptbndsend, :secrdmrtgsend, :unsecurednotesend,
|
|
19
|
+
:retainedearnend, :totnetassetend, :nonpfrea, :gftgrntsrcvd170,
|
|
20
|
+
:txrevnuelevied170, :srvcsval170, :grsinc170,
|
|
21
|
+
:grsrcptsrelated170, :totgftgrntrcvd509, :grsrcptsadmissn509,
|
|
22
|
+
:txrevnuelevied509, :srvcsval509, :subtotsuppinc509,
|
|
23
|
+
:totsupp509, :ein
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "propublica/nonprofits/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "propublica-nonprofits"
|
|
8
|
+
spec.version = Propublica::Nonprofits::VERSION
|
|
9
|
+
spec.authors = ["Ricky Chilcott"]
|
|
10
|
+
spec.email = ["ricky@rakefire.io"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Ruby wrapper for the Propublica Nonprofits API https://projects.propublica.org/nonprofits/api/v2}
|
|
13
|
+
spec.description = %q{Ruby wrapper for the Propublica Nonprofits API https://projects.propublica.org/nonprofits/api/v2}
|
|
14
|
+
spec.homepage = "https://github.com/Rakefire/propublica-nonprofits"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
29
|
+
spec.add_development_dependency "pry"
|
|
30
|
+
spec.add_development_dependency "vcr"
|
|
31
|
+
spec.add_development_dependency "webmock"
|
|
32
|
+
|
|
33
|
+
spec.add_dependency "faraday"
|
|
34
|
+
spec.add_dependency "json"
|
|
35
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: propublica-nonprofits
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ricky Chilcott
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: vcr
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: webmock
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: faraday
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: json
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
description: Ruby wrapper for the Propublica Nonprofits API https://projects.propublica.org/nonprofits/api/v2
|
|
126
|
+
email:
|
|
127
|
+
- ricky@rakefire.io
|
|
128
|
+
executables: []
|
|
129
|
+
extensions: []
|
|
130
|
+
extra_rdoc_files: []
|
|
131
|
+
files:
|
|
132
|
+
- ".gitignore"
|
|
133
|
+
- ".travis.yml"
|
|
134
|
+
- CODE_OF_CONDUCT.md
|
|
135
|
+
- Gemfile
|
|
136
|
+
- Gemfile.lock
|
|
137
|
+
- LICENSE.txt
|
|
138
|
+
- README.md
|
|
139
|
+
- Rakefile
|
|
140
|
+
- bin/console
|
|
141
|
+
- bin/setup
|
|
142
|
+
- bin/test
|
|
143
|
+
- lib/propublica/nonprofits.rb
|
|
144
|
+
- lib/propublica/nonprofits/organization.rb
|
|
145
|
+
- lib/propublica/nonprofits/organization/basic_parser.rb
|
|
146
|
+
- lib/propublica/nonprofits/organization/details_parser.rb
|
|
147
|
+
- lib/propublica/nonprofits/organization/dynamic_parser.rb
|
|
148
|
+
- lib/propublica/nonprofits/organization/filings_with_data_parser.rb
|
|
149
|
+
- lib/propublica/nonprofits/organization/filings_without_data_parser.rb
|
|
150
|
+
- lib/propublica/nonprofits/version.rb
|
|
151
|
+
- propublica-nonprofits.gemspec
|
|
152
|
+
homepage: https://github.com/Rakefire/propublica-nonprofits
|
|
153
|
+
licenses:
|
|
154
|
+
- MIT
|
|
155
|
+
metadata: {}
|
|
156
|
+
post_install_message:
|
|
157
|
+
rdoc_options: []
|
|
158
|
+
require_paths:
|
|
159
|
+
- lib
|
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
|
+
requirements:
|
|
162
|
+
- - ">="
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: '0'
|
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
|
+
requirements:
|
|
167
|
+
- - ">="
|
|
168
|
+
- !ruby/object:Gem::Version
|
|
169
|
+
version: '0'
|
|
170
|
+
requirements: []
|
|
171
|
+
rubyforge_project:
|
|
172
|
+
rubygems_version: 2.7.6
|
|
173
|
+
signing_key:
|
|
174
|
+
specification_version: 4
|
|
175
|
+
summary: Ruby wrapper for the Propublica Nonprofits API https://projects.propublica.org/nonprofits/api/v2
|
|
176
|
+
test_files: []
|