sec_query 1.0.3 → 1.0.4
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.
- data/.gitignore +17 -0
- data/Rakefile +1 -1
- data/lib/sec_query.rb +14 -9
- data/lib/sec_query/entity.rb +285 -291
- data/lib/sec_query/filing.rb +45 -40
- data/lib/sec_query/relationship.rb +67 -58
- data/lib/sec_query/sec_uri.rb +98 -0
- data/lib/sec_query/transaction.rb +99 -82
- data/lib/sec_query/version.rb +3 -1
- data/sec_query.gemspec +17 -15
- data/spec/sec_query_spec.rb +84 -64
- data/spec/sec_uri_spec.rb +37 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/vcr.rb +10 -0
- metadata +58 -6
- data/Gemfile.lock +0 -30
- data/lib/.DS_Store +0 -0
- data/lib/sec_query/.DS_Store +0 -0
data/.gitignore
ADDED
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/sec_query.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
|
2
|
-
require "rest-client"
|
3
|
-
require "hpricot"
|
1
|
+
# encoding: UTF-8
|
4
2
|
|
3
|
+
# external
|
4
|
+
require 'active_support/all'
|
5
|
+
require 'addressable/uri'
|
6
|
+
require 'hpricot'
|
7
|
+
require 'rest-client'
|
8
|
+
require 'rubygems'
|
5
9
|
|
6
|
-
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
|
10
|
+
# internal
|
11
|
+
require 'sec_query/entity'
|
12
|
+
require 'sec_query/filing'
|
13
|
+
require 'sec_query/relationship'
|
14
|
+
require 'sec_query/sec_uri'
|
15
|
+
require 'sec_query/transaction'
|
16
|
+
require 'sec_query/version'
|
data/lib/sec_query/entity.rb
CHANGED
@@ -1,309 +1,303 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
module SecQuery
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
# => SecQuery::Entity
|
5
|
+
# SecQuery::Entity is the root class which is responsible for requesting,
|
6
|
+
# parsing and initializing SecQuery::Entity intances from SEC Edgar.
|
7
|
+
class Entity
|
8
|
+
COLUMNS = [:first, :middle, :last, :name, :symbol, :cik, :url, :type, :sic,
|
9
|
+
:location, :state_of_inc, :formerly, :mailing_address,
|
10
|
+
:business_address, :relationships, :transactions, :filings]
|
11
|
+
|
12
|
+
attr_accessor(*COLUMNS)
|
13
|
+
|
14
|
+
def initialize(entity)
|
15
|
+
COLUMNS.each do |column|
|
16
|
+
instance_variable_set("@#{ column }", entity[column])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(entity_args, *options)
|
21
|
+
temp = {}
|
22
|
+
temp[:url] = SecURI.browse_edgar_uri(entity_args)
|
23
|
+
temp[:url][:action] = :getcompany
|
24
|
+
temp[:cik] = Entity.cik(temp[:url], entity_args)
|
25
|
+
|
26
|
+
if !temp[:cik] || temp[:cik] == ''
|
27
|
+
puts "No Entity found for query: #{ temp[:url] }"
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
|
31
|
+
### Get Document and Entity Type
|
32
|
+
doc = Entity.document(temp[:cik])
|
33
|
+
temp = Entity.parse_document(temp, doc)
|
34
|
+
|
35
|
+
### Get Additional Arguments and Query Additional Details
|
36
|
+
unless options.empty?
|
37
|
+
temp[:transactions] = []
|
38
|
+
temp[:filings] = []
|
39
|
+
options = Entity.options(temp, options)
|
40
|
+
temp = Entity.details(temp, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
### Return entity Object
|
44
|
+
@entity = Entity.new(temp)
|
45
|
+
@entity
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.query(url)
|
49
|
+
RestClient.get(url.to_s) do |response, request, result, &block|
|
50
|
+
case response.code
|
51
|
+
when 200
|
52
|
+
return response
|
53
|
+
else
|
54
|
+
response.return!(request, result, &block)
|
24
55
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.cik(url, entity)
|
60
|
+
response = Entity.query(url.output_atom.to_s)
|
61
|
+
doc = Hpricot::XML(response)
|
62
|
+
data = doc.search('//feed/title')[0]
|
63
|
+
if data.inner_text == 'EDGAR Search Results'
|
64
|
+
tbl = doc.search("//span[@class='companyMatch']")
|
65
|
+
if tbl && tbl.innerHTML != ''
|
66
|
+
tbl = tbl[0].parent.search('table')[0].search('tr')
|
67
|
+
tbl.each do |tr|
|
68
|
+
td = tr.search('td')
|
69
|
+
if td[1] && entity[:middle] && td[1].innerHTML.downcase == ("#{entity[:last]} #{entity[:first]} #{entity[:middle]}").downcase || td[1] && td[1].innerHTML.downcase == ("#{ entity[:last] } #{ entity[:first] }").downcase
|
70
|
+
cik = td[0].search('a').innerHTML
|
71
|
+
return cik
|
36
72
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
temp = Entity.parse_document(temp, doc)
|
41
|
-
|
42
|
-
### Get Additional Arguments and Query Additional Details
|
43
|
-
if !options.empty?;
|
44
|
-
temp[:transactions]=[]
|
45
|
-
temp[:filings] =[]
|
46
|
-
options = Entity.options(temp, options);
|
47
|
-
temp = Entity.details(temp, options);
|
48
|
-
end
|
49
|
-
|
50
|
-
### Return entity Object
|
51
|
-
@entity = Entity.new(temp)
|
52
|
-
|
53
|
-
return @entity
|
54
|
-
|
73
|
+
end
|
74
|
+
else
|
75
|
+
return false
|
55
76
|
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
77
|
+
else
|
78
|
+
cik = data.inner_text.scan(/\(([^)]+)\)/).to_s
|
79
|
+
cik = cik.gsub('[["', '').gsub('"]]', '')
|
80
|
+
return cik
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.document(cik)
|
85
|
+
url = SecURI.ownership_display_uri(action: :getissuer, CIK: cik)
|
86
|
+
response = query(url)
|
87
|
+
doc = Hpricot(response)
|
88
|
+
text = 'Ownership Reports from:'
|
89
|
+
type = 'issuer'
|
90
|
+
entity = doc.search('//table').search('//td').search("b[text()*='#{text}']")
|
91
|
+
if entity.empty?
|
92
|
+
url = SecURI.ownership_display_uri(action: :getowner, CIK: cik)
|
93
|
+
response = query(url)
|
94
|
+
doc = Hpricot(response)
|
95
|
+
text = 'Ownership Reports for entitys:'
|
96
|
+
type = 'owner'
|
97
|
+
entity = doc.search('//table').search('//td').search("b[text()*='#{text}']")
|
98
|
+
end
|
99
|
+
[doc, type]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.parse_document(temp, doc)
|
103
|
+
info = Entity.info(doc[0])
|
104
|
+
temp[:type] = doc[1]
|
105
|
+
temp[:name] = info[:name]
|
106
|
+
temp[:location] = info[:location]
|
107
|
+
temp[:sic] = info[:sic]
|
108
|
+
temp[:state_of_inc] = info[:state_of_inc]
|
109
|
+
temp[:formerly] = info[:formerly]
|
110
|
+
|
111
|
+
### Get Mailing Address
|
112
|
+
temp[:mailing_address] = Entity.mailing_address(doc[0])
|
113
|
+
|
114
|
+
### Get Business Address
|
115
|
+
temp[:business_address] = Entity.business_address(doc[0])
|
116
|
+
|
117
|
+
temp
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.info(doc)
|
121
|
+
info = {}
|
122
|
+
lines = doc.search("//td[@bgcolor='#E6E6E6']")[0].parent.parent.search('//tr')
|
123
|
+
td = lines[0].search('//td//b').innerHTML
|
124
|
+
info[:name] = td.gsub(td.scan(/\(([^)]+)\)/).to_s, '').gsub('()', '').gsub('\n', '')
|
125
|
+
lines = lines[1].search('//table')[0].search('//tr//td')
|
126
|
+
|
127
|
+
if lines[0].search('a')[0]
|
128
|
+
info[:sic] = lines[0].search('a')[0].innerHTML
|
129
|
+
end
|
130
|
+
|
131
|
+
if lines[0].search('a')[1]
|
132
|
+
info[:location] = lines[0].search('a')[1].innerHTML
|
133
|
+
end
|
134
|
+
|
135
|
+
if lines[0].search('b')[0] && lines[0].search('b')[0].innerHTML.squeeze(' ') != ' '
|
136
|
+
info[:state_of_inc] = lines[0].search('b')[0].innerHTML
|
137
|
+
end
|
138
|
+
|
139
|
+
if lines[1] && lines[1].search('font')
|
140
|
+
info[:formerly] = lines[1].search('font').innerHTML
|
141
|
+
.gsub('formerly: ', '').gsub('<br />', '').gsub('\n', '; ')
|
142
|
+
end
|
143
|
+
|
144
|
+
info
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.business_address(doc)
|
148
|
+
addie = doc.search('//table').search('//td')
|
149
|
+
.search("b[text()*='Business Address']")
|
150
|
+
if !addie.empty?
|
151
|
+
business_address = addie[0].parent.innerHTML
|
152
|
+
.gsub('<b class="blue">Business Address</b>', '').gsub('<br />', ' ')
|
153
|
+
return business_address
|
154
|
+
else
|
155
|
+
return false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.mailing_address(doc)
|
160
|
+
addie = doc.search('//table').search('//td')
|
161
|
+
.search("b[text()*='Mailing Address']")
|
162
|
+
if !addie.empty?
|
163
|
+
mailing_address = addie[0].parent.innerHTML
|
164
|
+
.gsub('<b class="blue">Mailing Address</b>', '').gsub('<br />', ' ')
|
165
|
+
return mailing_address
|
166
|
+
else
|
167
|
+
return false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.options(temp, options)
|
172
|
+
args = {}
|
173
|
+
if options.is_a?(Array) && options.length == 1 && options[0] == true
|
174
|
+
args[:relationships] = true
|
175
|
+
args[:transactions] = true
|
176
|
+
args[:filings] = true
|
177
|
+
elsif options.is_a?(Array) && options.length > 1
|
178
|
+
args[:relationships] = options[0]
|
179
|
+
args[:transactions] = options[1]
|
180
|
+
args[:filings] = options[2]
|
181
|
+
elsif options[0].is_a?(Hash)
|
182
|
+
args[:relationships] = options[0][:relationships]
|
183
|
+
args[:transactions] = options[0][:transactions]
|
184
|
+
args[:filings] = options[0][:filings]
|
185
|
+
end
|
186
|
+
args
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.details(temp, options)
|
190
|
+
## Get Relationships for entity
|
191
|
+
if options[:relationships] == true
|
192
|
+
relationships = Relationship.find(temp)
|
193
|
+
temp[:relationships] = relationships
|
194
|
+
end
|
195
|
+
|
196
|
+
## Get Transactions for entity
|
197
|
+
if options[:transactions] && options[:transactions].is_a?(Hash)
|
198
|
+
temp = Transaction.find(
|
199
|
+
temp,
|
200
|
+
options[:transactions][:start],
|
201
|
+
options[:transactions][:count],
|
202
|
+
options[:transactions][:limit])
|
203
|
+
elsif options[:transactions] && options[:transactions] == true
|
204
|
+
temp = Transaction.find(temp, nil, nil, nil)
|
205
|
+
end
|
206
|
+
|
207
|
+
## Get Filings for entity
|
208
|
+
if options[:filings] && options[:filings].is_a?(Hash)
|
209
|
+
temp = Filing.find(
|
210
|
+
temp,
|
211
|
+
options[:filings][:start],
|
212
|
+
options[:filings][:count],
|
213
|
+
options[:filings][:limit])
|
214
|
+
elsif options[:filings] && options[:filings] == true
|
215
|
+
temp = Filing.find(temp, nil, nil, nil)
|
216
|
+
end
|
217
|
+
|
218
|
+
temp
|
219
|
+
end
|
220
|
+
|
221
|
+
def self.log(entity)
|
222
|
+
if entity
|
223
|
+
puts '\n\t# # # # # # # # # # # # # # # # # # # # # # # # #\n\n'
|
224
|
+
puts "\t#{ entity.name }"
|
225
|
+
puts "\t(#{ entity.cik })"
|
226
|
+
puts "\tSIC = #{ entity.sic }" if entity.sic
|
227
|
+
puts "\tLocation: #{ entity.location }, " if entity.location
|
228
|
+
|
229
|
+
if entity.formerly && entity.formerly != ''
|
230
|
+
puts "\tFormerly: #{ entity.formerly }"
|
67
231
|
end
|
68
232
|
|
69
|
-
|
70
|
-
|
71
|
-
if args.is_a?(Hash)
|
72
|
-
if args[:symbol] != nil
|
73
|
-
string = "CIK="+args[:symbol]
|
74
|
-
elsif args[:cik] != nil
|
75
|
-
string = "CIK="+args[:cik]
|
76
|
-
elsif args[:first] != nil and args[:last]
|
77
|
-
string = "company="+args[:last]+" "+args[:first]
|
78
|
-
elsif args[:name] != nil
|
79
|
-
string = "company="+args[:name].gsub(/[(,?!\''"":.)]/, '')
|
80
|
-
end
|
81
|
-
elsif args.is_a?(String)
|
82
|
-
begin Float(args)
|
83
|
-
string = "CIK="+args
|
84
|
-
rescue
|
85
|
-
if args.length <= 4
|
86
|
-
string = "CIK="+args
|
87
|
-
else
|
88
|
-
string = "company="+args.gsub(/[(,?!\''"":.)]/, '')
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
string = string.to_s.gsub(" ", "+")
|
93
|
-
url = "http://www.sec.gov/cgi-bin/browse-edgar?"+string+"&action=getcompany"
|
94
|
-
return url
|
233
|
+
if entity.state_of_inc
|
234
|
+
puts "\tState of Incorporation: #{ entity.state_of_inc }"
|
95
235
|
end
|
96
236
|
|
97
|
-
|
98
|
-
|
99
|
-
doc = Hpricot::XML(response)
|
100
|
-
data = doc.search("//feed/title")[0];
|
101
|
-
if data.inner_text == "EDGAR Search Results"
|
102
|
-
tbl = doc.search("//span[@class='companyMatch']")
|
103
|
-
if tbl && tbl.innerHTML != ""
|
104
|
-
tbl = tbl[0].parent.search("table")[0].search("tr")
|
105
|
-
for tr in tbl
|
106
|
-
td = tr.search("td")
|
107
|
-
if td[1] != nil && entity[:middle] != nil && td[1].innerHTML.downcase == (entity[:last]+" "+entity[:first]+" "+entity[:middle]).downcase or td[1] != nil && td[1].innerHTML.downcase == (entity[:last]+" "+entity[:first]).downcase
|
108
|
-
cik = td[0].search("a").innerHTML
|
109
|
-
return cik;
|
110
|
-
end
|
111
|
-
end
|
112
|
-
else
|
113
|
-
return false;
|
114
|
-
end
|
115
|
-
else
|
116
|
-
cik = data.inner_text.scan(/\(([^)]+)\)/).to_s
|
117
|
-
cik = cik.gsub('[["', '').gsub('"]]','')
|
118
|
-
return cik
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.document(cik)
|
123
|
-
url ="http://www.sec.gov/cgi-bin/own-disp?action=getissuer&CIK="+cik
|
124
|
-
response = query(url)
|
125
|
-
doc = Hpricot(response)
|
126
|
-
text = "Ownership Reports from:"
|
127
|
-
type = "issuer"
|
128
|
-
entity = doc.search("//table").search("//td").search("b[text()*='"+text+"']")
|
129
|
-
if entity.empty?
|
130
|
-
url= "http://www.sec.gov/cgi-bin/own-disp?action=getowner&CIK="+cik
|
131
|
-
response = query(url)
|
132
|
-
doc = Hpricot(response)
|
133
|
-
text = "Ownership Reports for entitys:"
|
134
|
-
type = "owner"
|
135
|
-
entity = doc.search("//table").search("//td").search("b[text()*='"+text+"']")
|
136
|
-
end
|
137
|
-
return [doc, type]
|
138
|
-
|
237
|
+
if entity.mailing_address
|
238
|
+
puts "\tMailing Address:\t#{ entity.mailing_address.inspect.gsub('\n', ' ').squeeze(" ") }"
|
139
239
|
end
|
140
240
|
|
141
|
-
|
142
|
-
|
143
|
-
temp[:type] = doc[1]
|
144
|
-
info = Entity.info(doc[0])
|
145
|
-
temp[:name] = info[:name]
|
146
|
-
temp[:location] = info[:location]
|
147
|
-
temp[:sic] = info[:sic]
|
148
|
-
temp[:state_of_inc] = info[:state_of_inc]
|
149
|
-
temp[:formerly] = info[:formerly]
|
150
|
-
|
151
|
-
### Get Mailing Address
|
152
|
-
temp[:mailing_address] = Entity.mailing_address(doc[0])
|
153
|
-
|
154
|
-
### Get Business Address
|
155
|
-
temp[:business_address] = Entity.business_address(doc[0])
|
156
|
-
|
157
|
-
return temp;
|
241
|
+
if entity.business_address
|
242
|
+
puts "\tBusiness Address:\t#{ entity.business_address.inspect.gsub('\n', ' ').squeeze(" ") }"
|
158
243
|
end
|
159
244
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
if lines[1] != nil and lines[1].search("font")
|
177
|
-
info[:formerly] = lines[1].search("font").innerHTML.gsub("formerly: ", "").gsub("<br />", "").gsub("\n", "; ")
|
178
|
-
end
|
179
|
-
return info
|
245
|
+
if !entity.relationships
|
246
|
+
puts '\n\tRELATIONSHIPS:\t0 Total'
|
247
|
+
else
|
248
|
+
puts "\n\tRELATIONSHIPS:\t#{ entity.relationships.count } Total"
|
249
|
+
printf("\t%-40s %-15s %-30s %-10s\n\n",
|
250
|
+
'Entity',
|
251
|
+
'CIK',
|
252
|
+
'Position',
|
253
|
+
'Date')
|
254
|
+
entity.relationships.each do |relationship|
|
255
|
+
printf("\t%-40s %-15s %-30s %-10s\n",
|
256
|
+
relationship.name,
|
257
|
+
relationship.cik,
|
258
|
+
relationship.position,
|
259
|
+
relationship.date)
|
260
|
+
end
|
180
261
|
end
|
181
262
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
263
|
+
if entity.transactions
|
264
|
+
puts "\n\tTRANSACTIONS:\t#{ entity.transactions.count } Total"
|
265
|
+
printf("\t%-20s %-10s %-5s %-10s %-10s %-10s %-15s %-10s\n\n",
|
266
|
+
'Owner',
|
267
|
+
'CIK',
|
268
|
+
'Modes',
|
269
|
+
'Type',
|
270
|
+
'Shares',
|
271
|
+
'Price',
|
272
|
+
'Owned',
|
273
|
+
'Date')
|
274
|
+
entity.transactions.each do |transaction|
|
275
|
+
printf("\t%-20s %-10s %-5s %-10s%-10s %-10s %-15s %-10s\n",
|
276
|
+
transaction.reporting_owner,
|
277
|
+
transaction.owner_cik,
|
278
|
+
transaction.modes,
|
279
|
+
transaction.type,
|
280
|
+
transaction.shares,
|
281
|
+
transaction.price,
|
282
|
+
transaction.owned,
|
283
|
+
transaction.date)
|
284
|
+
end
|
191
285
|
end
|
192
286
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
def self.options(temp, options)
|
205
|
-
|
206
|
-
args={}
|
207
|
-
if options.is_a?(Array) && options.length == 1 && options[0] == true;
|
208
|
-
args[:relationships] = true;
|
209
|
-
args[:transactions]= true;
|
210
|
-
args[:filings] = true;
|
211
|
-
elsif options.is_a?(Array) && options.length > 1
|
212
|
-
args[:relationships] = options[0];
|
213
|
-
args[:transactions]= options[1];
|
214
|
-
args[:filings] = options[2];
|
215
|
-
elsif options[0].is_a?(Hash)
|
216
|
-
args[:relationships] = options[0][:relationships];
|
217
|
-
args[:transactions]= options[0][:transactions];
|
218
|
-
args[:filings] = options[0][:filings];
|
219
|
-
end
|
220
|
-
return args;
|
221
|
-
end
|
222
|
-
|
223
|
-
def self.details(temp, options)
|
224
|
-
|
225
|
-
## Get Relationships for entity
|
226
|
-
if options[:relationships] == true
|
227
|
-
relationships = Relationship.find(temp)
|
228
|
-
temp[:relationships] =relationships
|
229
|
-
end
|
230
|
-
|
231
|
-
## Get Transactions for entity
|
232
|
-
if options[:transactions] != nil and options[:transactions].is_a?(Hash)
|
233
|
-
temp = Transaction.find(temp, options[:transactions][:start], options[:transactions][:count], options[:transactions][:limit])
|
234
|
-
elsif options[:transactions] != nil && options[:transactions] == true
|
235
|
-
temp = Transaction.find(temp, nil, nil, nil)
|
236
|
-
end
|
237
|
-
|
238
|
-
|
239
|
-
## Get Filings for entity
|
240
|
-
|
241
|
-
if options[:filings] != nil and options[:filings].is_a?(Hash)
|
242
|
-
temp = Filing.find(temp, options[:filings][:start], options[:filings][:count], options[:filings][:limit])
|
243
|
-
elsif options[:filings] != nil and options[:filings] == true
|
244
|
-
temp = Filing.find(temp, nil, nil, nil)
|
245
|
-
end
|
246
|
-
|
247
|
-
return temp;
|
248
|
-
end
|
249
|
-
|
250
|
-
|
251
|
-
def self.log(entity)
|
252
|
-
|
253
|
-
if entity != false
|
254
|
-
puts "\n\t# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n\n"
|
255
|
-
puts "\t"+entity.name
|
256
|
-
puts "\t("+entity.cik+")"
|
257
|
-
if entity.formerly && entity.formerly != ""
|
258
|
-
puts "\tFormerly: "+entity.formerly
|
259
|
-
end
|
260
|
-
if entity.sic
|
261
|
-
puts "\tSIC = "+entity.sic
|
262
|
-
end
|
263
|
-
if entity.location
|
264
|
-
puts "\tLocation: "+entity.location+", "
|
265
|
-
end
|
266
|
-
if entity.state_of_inc
|
267
|
-
puts "\tState of Incorporation: "+entity.state_of_inc
|
268
|
-
end
|
269
|
-
if entity.mailing_address
|
270
|
-
puts "\tMailing Address:\t"+ entity.mailing_address.inspect.gsub('\n', ' ').squeeze(" ")
|
271
|
-
end
|
272
|
-
|
273
|
-
if entity.business_address
|
274
|
-
puts "\tBusiness Address:\t"+ entity.business_address.inspect.gsub('\n', ' ').squeeze(" ")
|
275
|
-
end
|
276
|
-
|
277
|
-
|
278
|
-
if !entity.relationships
|
279
|
-
puts "\n\tRELATIONSHIPS:\t0 Total"
|
280
|
-
else
|
281
|
-
puts "\n\tRELATIONSHIPS:\t"+ entity.relationships.count.to_s+" Total"
|
282
|
-
printf("\t%-40s %-15s %-30s %-10s\n\n","Entity", "CIK", "Position", "Date")
|
283
|
-
for relationship in entity.relationships
|
284
|
-
printf("\t%-40s %-15s %-30s %-10s\n",relationship.name, relationship.cik, relationship.position, relationship.date)
|
285
|
-
end
|
286
|
-
end
|
287
|
-
if entity.transactions
|
288
|
-
puts "\n\tTRANSACTIONS:\t"+ entity.transactions.count.to_s+" Total"
|
289
|
-
printf("\t%-20s %-10s %-5s %-10s %-10s %-10s %-15s %-10s\n\n","Owner", "CIK", "Modes", "Type","Shares","Price","Owned","Date")
|
290
|
-
for transaction in entity.transactions
|
291
|
-
printf("\t%-20s %-10s %-5s %-10s%-10s %-10s %-15s %-10s\n", transaction.reporting_owner,transaction.owner_cik,transaction.modes, transaction.type,transaction.shares,transaction.price,transaction.owned,transaction.date)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
if entity.filings
|
295
|
-
puts "\n\tFILINGS:\t"+ entity.filings.count.to_s+" Total"
|
296
|
-
printf("\t%-10s %-30s %-20s\n\n","Type", "File ID", "Date")
|
297
|
-
for filing in entity.filings
|
298
|
-
printf("\t%-10s %-30s %-20s\n",filing.term, filing.file_id, filing.date)
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
302
|
-
puts "\t"+entity.url+"\n\n"
|
303
|
-
else
|
304
|
-
return "No Entity found."
|
305
|
-
end
|
306
|
-
|
287
|
+
if entity.filings
|
288
|
+
puts "\n\tFILINGS:\t#{ entity.filings.count } Total"
|
289
|
+
printf("\t%-10s %-30s %-20s\n\n", 'Type', 'File ID', 'Date')
|
290
|
+
entity.filings.each do |filing|
|
291
|
+
printf("\t%-10s %-30s %-20s\n",
|
292
|
+
filing.term,
|
293
|
+
filing.file_id,
|
294
|
+
filing.date)
|
295
|
+
end
|
307
296
|
end
|
308
|
-
|
297
|
+
puts "\t#{ entity.url }\n\n"
|
298
|
+
else
|
299
|
+
return 'No Entity found.'
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
309
303
|
end
|