propublica-nonprofits 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c05c2a3977841806bac525c3c642db9a94bf0755c3d098c4852276b092b49168
4
- data.tar.gz: ecbbd8799e9d43592ea52d8e2ab4754f74fef539dec2a3eab0d7a415513acf1b
3
+ metadata.gz: baea7efcfc907f93a2765cfff5c3343fdf17e817a09ac15160f1025990ceee5a
4
+ data.tar.gz: 1da616c76aa6cc85b49176018db027e75f5a7a39f9518abcc3a114190883fefe
5
5
  SHA512:
6
- metadata.gz: 1e30af0a7b67f51505022bf3a6e8b63f91fff5bb702c5a531dbed24585194d8e9d0f966b4097d128c67d1a98bc26e44ca533acd64e4681fa6d7ab2ef17da55c3
7
- data.tar.gz: 9c34f58bc0c29ccabd62af0d62974f71f3557a907551e0f83521e657b20e5534f4afa9c78d1203dd83270be48cd3f7420059dba90069e263eb885c1e58628c30
6
+ metadata.gz: bf924b498d17cbea10dcf305ae1099359ebba0971d7f09cb6542d7c958be3e5309babd862be78e45674d93ec5d0d2c060374799f7daf9961c89b8aa441fd03fc
7
+ data.tar.gz: 93196885e1d02886c94e6b7e407b3ea552042dd348c3855fda889ad2a8c14992f681c115da932148934c731c9354844966f28c379c8f51a6135aad0d3811ed44
data/Gemfile.lock CHANGED
@@ -1,52 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- propublica-nonprofits (1.0.0)
5
- faraday
4
+ propublica-nonprofits (1.1.0)
5
+ faraday (> 1.0, < 3.0)
6
6
  json
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.0)
12
- public_suffix (>= 2.0.2, < 5.0)
11
+ addressable (2.8.1)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
13
  coderay (1.1.2)
14
- crack (0.4.3)
15
- safe_yaml (~> 1.0.0)
16
- faraday (1.5.1)
17
- faraday-em_http (~> 1.0)
18
- faraday-em_synchrony (~> 1.0)
19
- faraday-excon (~> 1.1)
20
- faraday-httpclient (~> 1.0.1)
21
- faraday-net_http (~> 1.0)
22
- faraday-net_http_persistent (~> 1.1)
23
- faraday-patron (~> 1.0)
24
- multipart-post (>= 1.2, < 3)
14
+ crack (0.4.5)
15
+ rexml
16
+ faraday (2.7.2)
17
+ faraday-net_http (>= 2.0, < 3.1)
25
18
  ruby2_keywords (>= 0.0.4)
26
- faraday-em_http (1.0.0)
27
- faraday-em_synchrony (1.0.0)
28
- faraday-excon (1.1.0)
29
- faraday-httpclient (1.0.1)
30
- faraday-net_http (1.0.1)
31
- faraday-net_http_persistent (1.2.0)
32
- faraday-patron (1.0.0)
33
- hashdiff (1.0.0)
19
+ faraday-net_http (3.0.2)
20
+ hashdiff (1.0.1)
34
21
  json (2.5.1)
35
22
  method_source (0.9.0)
36
23
  minitest (5.11.3)
37
24
  minitest-line (0.6.5)
38
25
  minitest (~> 5.0)
39
- multipart-post (2.1.1)
40
26
  pry (0.11.3)
41
27
  coderay (~> 1.1.0)
42
28
  method_source (~> 0.9.0)
43
- public_suffix (4.0.6)
29
+ public_suffix (5.0.1)
44
30
  rake (13.0.1)
45
- ruby2_keywords (0.0.4)
46
- safe_yaml (1.0.5)
47
- vcr (4.0.0)
48
- webmock (3.7.6)
49
- addressable (>= 2.3.6)
31
+ rexml (3.2.5)
32
+ ruby2_keywords (0.0.5)
33
+ vcr (6.1.0)
34
+ webmock (3.18.1)
35
+ addressable (>= 2.8.0)
50
36
  crack (>= 0.3.2)
51
37
  hashdiff (>= 0.4.0, < 2.0.0)
52
38
 
@@ -60,8 +46,9 @@ DEPENDENCIES
60
46
  propublica-nonprofits!
61
47
  pry
62
48
  rake (~> 13.0)
49
+ rexml
63
50
  vcr
64
51
  webmock
65
52
 
66
53
  BUNDLED WITH
67
- 2.2.23
54
+ 2.3.10
@@ -1,5 +1,5 @@
1
1
  module Propublica
2
2
  module Nonprofits
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -48,22 +48,12 @@ module Propublica
48
48
  params["ntee[id]"] = ntee if ntee
49
49
  params["page"] = page if page
50
50
 
51
- response = Faraday.default_connection.get("#{API_BASE_URL}/#{API_SEARCH_PATH}", params)
52
- parsed_response =
53
- if response.body.is_a?(Hash)
54
- response.body
55
- else
56
- begin
57
- JSON.parse(response.body)
58
- rescue JSON::ParserError => e
59
- raise JSON::ParserError.new("Propublica API Parsing Error: #{e.message}")
60
- end
61
- end
62
-
63
- max_pages = parsed_response.dig("num_pages") || max_pages
51
+ response = connection.get("/#{API_SEARCH_PATH}", params)
52
+ max_pages = response.body.dig("num_pages") || max_pages
64
53
 
65
54
  yielder <<
66
- parsed_response
55
+ response
56
+ .body
67
57
  .fetch("organizations", [])
68
58
  .map { |basic_attrs| Propublica::Nonprofits::Organization.new("basic" => basic_attrs) }
69
59
 
@@ -74,24 +64,31 @@ module Propublica
74
64
  end
75
65
  end
76
66
  end
67
+
68
+ rescue JSON::ParserError => e
69
+ raise JSON::ParserError.new("Propublica API Parsing Error: #{e.message}")
77
70
  end
78
71
 
79
72
  def self.find(ein)
80
- attributes = self.find_attributes(ein)
81
- Propublica::Nonprofits::Organization.new(attributes)
73
+ Propublica::Nonprofits::Organization.new(
74
+ self.find_attributes(ein)
75
+ )
82
76
  end
83
77
 
84
- def self.find_attributes(ein)
85
- response = Faraday.get("#{API_BASE_URL}/nonprofits/api/v2/organizations/#{ein}.json")
86
- if response.body.is_a?(Hash)
87
- response.body
88
- else
89
- begin
90
- JSON.parse(response.body)
91
- rescue JSON::ParserError => e
92
- raise JSON::ParserError.new("Propublica API Parsing Error: #{e.message}")
78
+ def self.connection
79
+ Faraday
80
+ .new(API_BASE_URL) do |f|
81
+ f.response :json
93
82
  end
94
- end
83
+ end
84
+
85
+ def self.find_attributes(ein)
86
+ connection
87
+ .get("/nonprofits/api/v2/organizations/#{ein}.json")
88
+ .body
89
+
90
+ rescue JSON::ParserError => e
91
+ raise JSON::ParserError.new("Propublica API Parsing Error: #{e.message}")
95
92
  end
96
93
  end
97
94
  end
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "vcr"
31
31
  spec.add_development_dependency "webmock"
32
+ spec.add_development_dependency "rexml"
32
33
 
33
- spec.add_dependency "faraday"
34
+ spec.add_dependency "faraday", "> 1.0", "< 3.0"
34
35
  spec.add_dependency "json"
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propublica-nonprofits
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricky Chilcott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-13 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,19 +109,39 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: faraday
112
+ name: rexml
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
- type: :runtime
118
+ type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '3.0'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">"
140
+ - !ruby/object:Gem::Version
141
+ version: '1.0'
142
+ - - "<"
143
+ - !ruby/object:Gem::Version
144
+ version: '3.0'
125
145
  - !ruby/object:Gem::Dependency
126
146
  name: json
127
147
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
203
  - !ruby/object:Gem::Version
184
204
  version: '0'
185
205
  requirements: []
186
- rubygems_version: 3.1.2
206
+ rubygems_version: 3.2.32
187
207
  signing_key:
188
208
  specification_version: 4
189
209
  summary: Ruby wrapper for the Propublica Nonprofits API https://projects.propublica.org/nonprofits/api/v2