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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjRmNGY5ZTA0ZTA5ODAzZmVmOWI0ZGM5YTEzZGRiOGM1MDlhMzNhZQ==
4
+ YTZlYzNiMTUzYzhhYjdmODVlNzZmOWZhNjMxOGRkYjNlZmNkNTg2Mw==
5
5
  data.tar.gz: !binary |-
6
- NGVjOGM5YjlmMGNhMTc4MDM5NDY3ZjQxYjgzODMyOTc3YWZkZDQzYQ==
6
+ ZmM2NWMyYjMxNDMwMjFhNmI1YTNmOTAzY2MxMDhhMjUyODNkNWNjNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NmI4NDQ4OWZjMjljNTc1NDQwNDZjMTk1NjA2NjY5ZDcyZGFiZWM5ZWI4YWQz
10
- OGZkNGM1YWNkMGU2ZjA5ZDRiNmRjODEwOGNmOGQ2ODgzOWUwZDRmZDE5Y2Yw
11
- NGM3MTI0MTg4NDJhOWJlNjUzZWRmY2EyMzEyOGM0MDVlZjIwMjU=
9
+ Zjk1M2U4NjA0ODFmZjNjM2YxMjk2NTJhZjI4ZjNlMjUxMTI5YzRiYzQ1ZDZk
10
+ NGNkOWJhNjg4ZjAxNjNiMjE4M2I0YzQ2NzEzYTNmOTY0YTUwNjI2YWI4YTFk
11
+ MTVmNWEwYWYyOGI3ZmIwNGFmNzIwYjNiZjlkZDM2ODFhZjdjMWE=
12
12
  data.tar.gz: !binary |-
13
- YWE1ODQ1YTAzOWZmYzRkNDI4MjIxMWJhZmI1ZTIyYjA2Y2Y1MWRkY2QwMzBj
14
- YTI4ZjgwNTdmMmQ3Zjg2ZjY2OGQ1MjMxN2ZlYzhlMzA1ZDU2MGRhYWY0YjVj
15
- YzkzNzE2N2ExNDlhMzA4MTRjMGZjZDJlNmUwYTFmMGUyMWI5ZDA=
13
+ MTc0ZTI4NDI1MmNlZmRlMDE4ZDRhNWM5MjIzYzY4NjNkYTczMmIyNTMwYzE1
14
+ NzZiYjI5ZTJkODgyMWE1ZGE1MDI0OThlNzllMGFkMDFjNDNmMWM5NzU1OGE5
15
+ NTRlODNkMzZjMjBkNjVhYmMzNmE0N2IwYTQwMjY2NDk0ZjJkMjc=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/*
@@ -1,73 +1,71 @@
1
1
  module Sec
2
- class Entity
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
- attr_accessor :first, :middle, :last, :name, :symbol, :cik, :url, :type, :sic, :location, :state_of_inc, :formerly, :mailing_address, :business_address, :relationships, :transactions, :filings
5
-
6
- def self.find(entity_args, *options)
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
- 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)
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
- 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(/[(,?!\''"":.)]/, '')
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
- def self.cik(url, entity)
51
- response = Entity.query(url+"&output=atom")
52
- # puts response
53
- entries = []
54
- Nokogiri::HTML(response).xpath('//feed/entry').each do |e|
55
- # e.remove_namespaces!('link')
56
- if e.xpath('//content/company-info').to_s.length > 0
57
- doc = Hashie::Mash.new(Crack::XML.parse(e.xpath('//content/company-info').to_s)['company_info'])
58
- end
59
- if e.xpath('//company-info').to_s.length > 0
60
- doc = Hashie::Mash.new(Crack::XML.parse(e.xpath('//company-info').to_s)['company_info'])
61
- end
62
- if e.xpath('//content/accession-nunber').to_s.length > 0
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
- end
68
+ return doc
69
+ end
70
+ end
73
71
  end
@@ -1,3 +1,3 @@
1
1
  module SecQuery
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
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.6
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
Binary file
Binary file