sec_entities 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/lib/sec_entities/entity.rb +59 -61
- data/lib/sec_entities/version.rb +1 -1
- metadata +2 -3
- data/pkg/sec_entities-0.0.1.gem +0 -0
- data/pkg/sec_entities-0.0.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTZlYzNiMTUzYzhhYjdmODVlNzZmOWZhNjMxOGRkYjNlZmNkNTg2Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmM2NWMyYjMxNDMwMjFhNmI1YTNmOTAzY2MxMDhhMjUyODNkNWNjNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Zjk1M2U4NjA0ODFmZjNjM2YxMjk2NTJhZjI4ZjNlMjUxMTI5YzRiYzQ1ZDZk
|
10
|
+
NGNkOWJhNjg4ZjAxNjNiMjE4M2I0YzQ2NzEzYTNmOTY0YTUwNjI2YWI4YTFk
|
11
|
+
MTVmNWEwYWYyOGI3ZmIwNGFmNzIwYjNiZjlkZDM2ODFhZjdjMWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTc0ZTI4NDI1MmNlZmRlMDE4ZDRhNWM5MjIzYzY4NjNkYTczMmIyNTMwYzE1
|
14
|
+
NzZiYjI5ZTJkODgyMWE1ZGE1MDI0OThlNzllMGFkMDFjNDNmMWM5NzU1OGE5
|
15
|
+
NTRlODNkMzZjMjBkNjVhYmMzNmE0N2IwYTQwMjY2NDk0ZjJkMjc=
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/lib/sec_entities/entity.rb
CHANGED
@@ -1,73 +1,71 @@
|
|
1
1
|
module Sec
|
2
|
-
|
2
|
+
class Entity
|
3
|
+
attr_accessor :first, :middle, :last, :name, :symbol, :cik, :url, :type, :sic, :location, :state_of_inc,
|
4
|
+
:formerly, :mailing_address, :business_address, :relationships, :transactions, :filings
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Entity.cik(Entity.url(entity_args), entity_args)
|
8
|
-
end
|
6
|
+
def self.find(entity_args, *options)
|
7
|
+
Entity.lookup(Entity.url(entity_args), entity_args)
|
8
|
+
end
|
9
9
|
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
}
|
11
|
+
def self.query(url)
|
12
|
+
RestClient.get(url){ |response, request, result, &block|
|
13
|
+
case response.code
|
14
|
+
when 200
|
15
|
+
return response
|
16
|
+
else
|
17
|
+
response.return!(request, result, &block)
|
20
18
|
end
|
19
|
+
}
|
20
|
+
end
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
elsif args.is_a?(String)
|
35
|
-
begin Float(args)
|
36
|
-
string = "CIK="+args
|
37
|
-
rescue
|
38
|
-
if args.length <= 4
|
39
|
-
string = "CIK="+args
|
40
|
-
else
|
41
|
-
string = "company="+args.gsub(/[(,?!\''"":.)]/, '')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
string = string.to_s.gsub(" ", "+")
|
46
|
-
url = "http://www.sec.gov/cgi-bin/browse-edgar?"+string+"&action=getcompany"
|
47
|
-
return url
|
23
|
+
def self.url(args)
|
24
|
+
if args.is_a?(Hash)
|
25
|
+
if args[:symbol] != nil
|
26
|
+
string = "CIK="+args[:symbol]
|
27
|
+
elsif args[:cik] != nil
|
28
|
+
string = "CIK="+args[:cik]
|
29
|
+
elsif args[:first] != nil and args[:last]
|
30
|
+
string = "company="+args[:last]+" "+args[:first]
|
31
|
+
elsif args[:name] != nil
|
32
|
+
string = "company="+args[:name].gsub(/[(,?!\''"":.)]/, '')
|
48
33
|
end
|
34
|
+
elsif args.is_a?(String)
|
35
|
+
begin Float(args)
|
36
|
+
string = "CIK="+args
|
37
|
+
rescue
|
38
|
+
if args.length <= 4
|
39
|
+
string = "CIK="+args
|
40
|
+
else
|
41
|
+
string = "company="+args.gsub(/[(,?!\''"":.)]/, '')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
string = string.to_s.gsub(" ", "+")
|
46
|
+
url = "http://www.sec.gov/cgi-bin/browse-edgar?"+string+"&action=getcompany"
|
47
|
+
return url
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
doc = Crack::XML.parse(e.xpath('//content').to_s).collect {|k, v| Hashie::Mash.new(v) }
|
64
|
-
end
|
65
|
-
|
66
|
-
entries << doc
|
67
|
-
end
|
68
|
-
|
69
|
-
return entries
|
50
|
+
def self.lookup(url, entity)
|
51
|
+
response = Entity.query(url+"&output=atom")
|
52
|
+
# puts response.to_s
|
53
|
+
entries = []
|
54
|
+
doc = Hashie::Mash.new
|
55
|
+
content = []
|
56
|
+
document = Nokogiri::HTML(response)
|
57
|
+
company_info = Crack::XML.parse(document.xpath('//feed/company-info').to_s)['company_info'] if document.xpath('//feed/company-info').to_s.length > 0
|
58
|
+
company_info = Crack::XML.parse(document.xpath('//content/company-info').to_s)['company_info'] if document.xpath('//feed/entry/content/company-info').to_s.length > 0
|
59
|
+
doc.company_info = company_info
|
60
|
+
if document.xpath('//feed/entry').to_s.length > 0
|
61
|
+
document.xpath('//feed/entry/content').each do |e|
|
62
|
+
content << Crack::XML.parse(e.to_s)['content'] if e.xpath('//content/accession-nunber').to_s.length > 0
|
70
63
|
end
|
64
|
+
end
|
65
|
+
|
66
|
+
doc.filings = content if content.size > 0
|
71
67
|
|
72
|
-
|
68
|
+
return doc
|
69
|
+
end
|
70
|
+
end
|
73
71
|
end
|
data/lib/sec_entities/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sec_entities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Rauber
|
@@ -89,6 +89,7 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
+
- .gitignore
|
92
93
|
- Gemfile
|
93
94
|
- Gemfile.lock
|
94
95
|
- README.md
|
@@ -98,8 +99,6 @@ files:
|
|
98
99
|
- lib/sec_entities/.DS_Store
|
99
100
|
- lib/sec_entities/entity.rb
|
100
101
|
- lib/sec_entities/version.rb
|
101
|
-
- pkg/sec_entities-0.0.1.gem
|
102
|
-
- pkg/sec_entities-0.0.2.gem
|
103
102
|
- sec_entities.gemspec
|
104
103
|
- spec/sec_query_spec.rb
|
105
104
|
- spec/spec_helper.rb
|
data/pkg/sec_entities-0.0.1.gem
DELETED
Binary file
|
data/pkg/sec_entities-0.0.2.gem
DELETED
Binary file
|