sec_edgar_ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -0
- data/lib/sec_edgar_ruby/submission.rb +36 -6
- data/lib/sec_edgar_ruby/version.rb +1 -1
- data/pkg/sec_edgar_ruby-0.1.1.gem +0 -0
- metadata +2 -2
- data/sig/sec_edgar_ruby.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9bb05fa37127b8e9c21af85244ada60b40e2ea6f036a98e13374a5a1a11eb67
|
4
|
+
data.tar.gz: 14fa10c980fcb19b429b4c42cf7c4a3b1e2cd53220bdf8d14e23ff361f6cd9a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec0c903191272ac79836f656f9563c92105072960bdc5013b4fc81dacc96fa0eef8847a7876ed2cf33e46af1b016c190c68e19bffde5864125fd5ab6e040ba5
|
7
|
+
data.tar.gz: 5bf3d916dbbcb775c1295c9197555f7375def795591a92b14befad258ebb74f277d34e74df92d5fe531b1d9fd9d21e6552b7e48a7d65f70405ddff2ca3f4a7b4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -31,3 +31,11 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
31
31
|
## Code of Conduct
|
32
32
|
|
33
33
|
Everyone interacting in the SecEdgarRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nnhansg/sec-edgar-ruby/blob/master/CODE_OF_CONDUCT.md).
|
34
|
+
|
35
|
+
## Notes
|
36
|
+
|
37
|
+
### Fair Access
|
38
|
+
|
39
|
+
To ensure that everyone has equitable access to SEC EDGAR content, please use efficient scripting, downloading only what you need and please moderate requests to minimize server load. Current guidelines limit each user to a total of no more than 10 requests per second, regardless of the number of machines used to submit requests.
|
40
|
+
|
41
|
+
To ensure that SEC.gov remains available to all users, we reserve the right to block IP addresses that submit excessive requests. The SEC does not allow "unclassified" bots or automated tools to crawl the site. Any request that has been identified as part of an unclassified bot or an automated tool outside of the acceptable policy will be managed to ensure fair access for all users. See the Developer FAQ on how to comply with SEC's Web Site Privacy and Security Policy.
|
@@ -9,24 +9,54 @@ module SecEdgarRuby
|
|
9
9
|
"https://data.sec.gov/submissions/CIK#{cik}.json"
|
10
10
|
end
|
11
11
|
|
12
|
-
# @options: { cik: 'xxx' }
|
12
|
+
# @options: { cik: 'xxx', user_agent: 'Name (email)', attempts: 0 }
|
13
13
|
def self.find(options = {})
|
14
14
|
result = {}
|
15
|
+
options[:user_agent] ||= "#{SecEdgarRuby.name}/#{SecEdgarRuby::VERSION}"
|
16
|
+
options[:attempts] = options[:attempts].to_i
|
15
17
|
return result if options.blank? || options[:cik].blank?
|
16
18
|
|
17
19
|
url = cik_api_url(options[:cik])
|
18
20
|
return result if url.blank?
|
19
21
|
|
22
|
+
puts "GET: #{url}"
|
23
|
+
|
20
24
|
response = Faraday.get(url) do |request|
|
21
25
|
request.headers['Accept'] = '*/*'
|
22
26
|
request.headers['Content-Type'] = 'application/json'
|
23
|
-
request.headers['User-Agent'] =
|
27
|
+
request.headers['User-Agent'] = options[:user_agent]
|
28
|
+
end
|
29
|
+
|
30
|
+
content_type = response.headers['content-type']
|
31
|
+
puts "Headers: #{response.headers}"
|
32
|
+
|
33
|
+
case content_type
|
34
|
+
when 'application/json'
|
35
|
+
result = JSON.parse(response.body)
|
36
|
+
when 'application/xml'
|
37
|
+
result = Hash.from_xml(response.body).as_json
|
38
|
+
when 'text/html'
|
39
|
+
options[:attempts] = options[:attempts].to_i + 1
|
40
|
+
return find(options) if options[:attempts].to_i > 2
|
41
|
+
|
42
|
+
result = {
|
43
|
+
error: {
|
44
|
+
message: 'Your Request reached to limit or is rejected.',
|
45
|
+
details: response.body
|
46
|
+
}
|
47
|
+
}
|
48
|
+
else
|
49
|
+
options[:attempts] = options[:attempts].to_i + 1
|
50
|
+
return find(options) if options[:attempts].to_i > 2
|
51
|
+
|
52
|
+
result = {
|
53
|
+
error: {
|
54
|
+
message: 'Your Request is unknown or rejected.',
|
55
|
+
details: response.body
|
56
|
+
}
|
57
|
+
}
|
24
58
|
end
|
25
59
|
|
26
|
-
result = JSON.parse(response.body)
|
27
|
-
Util.deep_snake_case_keys(result)
|
28
|
-
rescue JSON::ParserError => e
|
29
|
-
result = Hash.from_xml(response.body).as_json
|
30
60
|
Util.deep_snake_case_keys(result)
|
31
61
|
end
|
32
62
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sec_edgar_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nhan Nguyen
|
@@ -86,8 +86,8 @@ files:
|
|
86
86
|
- lib/sec_edgar_ruby/submission.rb
|
87
87
|
- lib/sec_edgar_ruby/util.rb
|
88
88
|
- lib/sec_edgar_ruby/version.rb
|
89
|
+
- pkg/sec_edgar_ruby-0.1.1.gem
|
89
90
|
- sec_edgar_ruby.gemspec
|
90
|
-
- sig/sec_edgar_ruby.rbs
|
91
91
|
- spec/sec_edgar_ruby_spec.rb
|
92
92
|
- spec/spec_helper.rb
|
93
93
|
homepage: http://www.nhansg.com
|
data/sig/sec_edgar_ruby.rbs
DELETED