irs_pub78 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -2
- data/README.rdoc +30 -39
- data/{irs.gemspec → irs_pub78.gemspec} +1 -1
- data/lib/{irs → irs_pub78}/client.rb +15 -7
- data/lib/irs_pub78.rb +4 -0
- data/spec/irs_spec.rb +3 -3
- metadata +21 -21
- data/lib/irs.rb +0 -4
data/LICENSE
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
This project is subject to the Apache License 2.0
|
1
|
+
This project is subject to the Apache License 2.0 (dated 2004).
|
2
2
|
|
3
|
-
The full license is referenced here: http://www.apache.org/licenses/LICENSE-2.0.
|
3
|
+
The full license is referenced here: http://www.apache.org/licenses/LICENSE-2.0.txt.
|
data/README.rdoc
CHANGED
@@ -1,22 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
== About this IRS.gem
|
1
|
+
== About this .gem, IRS_Pub78
|
4
2
|
|
5
3
|
This IRS .gem is designed to allow improve the accessibility of public nonprofit information
|
6
|
-
provided by the IRS via Publication 78 online.
|
4
|
+
provided by the IRS via Publication 78 online. This .gem is not provided or maintained by the IRS. The information
|
5
|
+
available is publicly available.
|
7
6
|
|
8
|
-
==
|
7
|
+
== Usage
|
9
8
|
|
10
|
-
|
9
|
+
From the terminal:
|
11
10
|
|
12
|
-
|
11
|
+
gem install irs_pub78 # install the .gem
|
13
12
|
|
14
|
-
irb
|
15
|
-
|
16
|
-
i =
|
17
|
-
i.download
|
18
|
-
i.unzip
|
19
|
-
i.parse_txt_to_json => /data/irs.json
|
13
|
+
irb # start IRB
|
14
|
+
require 'irs_pub78' # require the IRS_Pub78 gem
|
15
|
+
i = IrsPub78::Client.new # create a new instance of the IRS::Client
|
16
|
+
i.download # tell the instance to download the file. downloads to /data/irs.zip
|
17
|
+
i.unzip # tell the instance to unzip the downloaded file to a txt file
|
18
|
+
i.parse_txt_to_json => /data/irs.json # tell the instance to parse the txt file to .json
|
19
|
+
|
20
|
+
i.find("Vacaville", "CA") # tell the instance to find the nonprofits* on the IRS Pub 78 online
|
21
|
+
# in a specific City and State. returns an easy-to-use array of hashes,
|
22
|
+
# each which has the attributes (Name, City, State, Code)
|
23
|
+
#
|
24
|
+
# * currently only supports the first 500 nonprofits in a city
|
20
25
|
|
21
26
|
== Notes
|
22
27
|
|
@@ -24,39 +29,25 @@ IRS Pub 78
|
|
24
29
|
The source is a .zip file.
|
25
30
|
There are 800,000+ records in the file.
|
26
31
|
|
27
|
-
|
32
|
+
== Known Issues
|
33
|
+
|
34
|
+
This .gem does not support more than 500 nonprofits on a given, which most large cities have.
|
28
35
|
support may be added in the future, if a Use Case requires it
|
29
36
|
|
30
|
-
==
|
37
|
+
== Development Environment
|
31
38
|
|
32
|
-
This wrapper is developed against Ruby 1.9.2
|
39
|
+
This wrapper is developed against Ruby 1.9.2.
|
33
40
|
|
34
41
|
= License
|
35
42
|
|
36
|
-
|
43
|
+
Apache 2.0.
|
44
|
+
See LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt
|
37
45
|
|
38
|
-
|
39
|
-
a copy of this software and associated documentation files (the
|
40
|
-
"Software"), to deal in the Software without restriction, including
|
41
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
42
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
43
|
-
permit persons to whom the Software is furnished to do so, subject to
|
44
|
-
the following conditions:
|
45
|
-
|
46
|
-
The above copyright notice and this permission notice shall be
|
47
|
-
included in all copies or substantial portions of the Software.
|
48
|
-
|
49
|
-
You will notify the author and give permission to have your software
|
50
|
-
listed on this and other websites of the author as using the Software.
|
46
|
+
= Credits
|
51
47
|
|
52
|
-
|
53
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
55
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
56
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
57
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
58
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
|
+
an open-source project by MoreQuality, a 501(c)(3) nonprofit based in Solano County, California.
|
59
49
|
|
60
|
-
|
50
|
+
== Support this work
|
61
51
|
|
62
|
-
|
52
|
+
Please consider making a donation (http://morequality.org/donate) to support
|
53
|
+
MoreQuality's technology and civic education initiatives.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module IrsPub78
|
2
2
|
class Client
|
3
3
|
|
4
4
|
require 'open-uri'
|
@@ -52,17 +52,25 @@ module Irs
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
#
|
56
|
-
|
57
|
-
|
55
|
+
# file = the file you want to unzip
|
56
|
+
# target = the relative directory you want to unzip to
|
57
|
+
def unzip(file, target = "unzipped")
|
58
|
+
Zip::ZipFile.open(file) { |zip|
|
59
|
+
zip.each { |file|
|
60
|
+
path = File.join(target, file.name)
|
61
|
+
FileUtils.mkdir_p(File.dirname(path))
|
62
|
+
zip.extract(file, path) unless File.exist?(path)
|
63
|
+
}
|
64
|
+
}
|
58
65
|
end
|
59
66
|
|
60
67
|
# Open the .txt file
|
61
68
|
# Read it and loop through it and write the data to a hash
|
62
69
|
def parse_txt_to_json
|
63
|
-
entities
|
64
|
-
i
|
65
|
-
|
70
|
+
entities = []
|
71
|
+
i = 0 # count
|
72
|
+
file_to_process = Dir.glob("data/eopub78/*.txt")[0]
|
73
|
+
lines = File.open(file_to_process, "r").readlines
|
66
74
|
lines[i..-1].each do |line| # ignore the first header line
|
67
75
|
i = i + 1
|
68
76
|
entities << {
|
data/lib/irs_pub78.rb
ADDED
data/spec/irs_spec.rb
CHANGED
@@ -3,10 +3,10 @@ require 'helper'
|
|
3
3
|
# fixtures = YAML.load(ERB.new(File.new(File.dirname(__FILE__) + '/fixtures/fixtures.yml').read).result)
|
4
4
|
|
5
5
|
# public methods
|
6
|
-
client =
|
6
|
+
client = IrsPub78::Client.new
|
7
7
|
|
8
8
|
# The projects method
|
9
|
-
describe
|
9
|
+
describe IrsPub78, "::Client.new" do
|
10
10
|
it "should download" do
|
11
11
|
#file = client.download
|
12
12
|
file.should be_kind_of(File)
|
@@ -22,7 +22,7 @@ describe Irs, "::Client.new" do
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe IrsPub78, "::Other Methods" do
|
26
26
|
before do
|
27
27
|
end
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irs_pub78
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-17 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &70354740358820 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '2.6'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70354740358820
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: simplecov
|
28
|
-
requirement: &
|
28
|
+
requirement: &70354740358320 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70354740358320
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: nokogiri
|
39
|
-
requirement: &
|
39
|
+
requirement: &70354740357860 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.5.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70354740357860
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: json
|
50
|
-
requirement: &
|
50
|
+
requirement: &70354740357400 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 1.5.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70354740357400
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rubyzip
|
61
|
-
requirement: &
|
61
|
+
requirement: &70354740384320 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.9.4
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70354740384320
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: nokogiri
|
72
|
-
requirement: &
|
72
|
+
requirement: &70354740383860 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 1.5.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70354740383860
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: json
|
83
|
-
requirement: &
|
83
|
+
requirement: &70354740383400 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 1.5.0
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70354740383400
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rubyzip
|
94
|
-
requirement: &
|
94
|
+
requirement: &70354740382940 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: 0.9.4
|
100
100
|
type: :runtime
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70354740382940
|
103
103
|
description: Wrapper for the IRS.gov's Publication 78
|
104
104
|
email: rwold@morequality.org
|
105
105
|
executables: []
|
@@ -111,9 +111,9 @@ files:
|
|
111
111
|
- Gemfile
|
112
112
|
- LICENSE
|
113
113
|
- README.rdoc
|
114
|
-
-
|
115
|
-
- lib/
|
116
|
-
- lib/
|
114
|
+
- irs_pub78.gemspec
|
115
|
+
- lib/irs_pub78.rb
|
116
|
+
- lib/irs_pub78/client.rb
|
117
117
|
- spec/fixtures/fixtures.yml
|
118
118
|
- spec/helper.rb
|
119
119
|
- spec/irs_spec.rb
|
data/lib/irs.rb
DELETED