sec_entities 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWJmZWEyMTkwOGJjMjdmNzFjYTU0NTI5YzlhZDRhOTBmMmE4ZTBhOA==
5
+ data.tar.gz: !binary |-
6
+ NzBiZWQ4Y2U3YmEwNDAxOTJiNmUxZWI5YmQzZmVmYWJlZjhkMTBkNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTg3NWJmMDNlNTgyNDMzOGU0ODJhNzQ4MjQ3YWEzMmQ3ZmFkYTFhNzNlYzIy
10
+ NDI0N2RlNTU1YzlkOTAyZDI5YWQ0MWUyYWY4NWVlMGFjNjAxM2QzZjUwMGYz
11
+ NDYwNTU5NWUzYjI1NDU2NGNjMzUxZTE1N2UzZDY2OGU3ZTYyODg=
12
+ data.tar.gz: !binary |-
13
+ YTE0ZWFiMmQwZGY3MjJlOWQyNDBiMTVkN2VlZDZhOTk1ZGNmMGIyY2I1NWFj
14
+ NzZkMmViODViOWNlNGI5ZDk5MGQyOGUxZWUwYWUyNTg4MTM0MzhlYmRhNWM1
15
+ NzMzMjkzYThlNGRlNTQ1Y2IxNGQ0ZjRhZDliZGJmYWFmMzBiNzE=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sec_query.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sec_query (1.0.3)
5
+ crack
6
+ hashie
7
+ hpricot
8
+ nokogiri
9
+ rest-client
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ crack (0.4.1)
15
+ safe_yaml (~> 0.9.0)
16
+ diff-lcs (1.1.3)
17
+ hashie (2.0.5)
18
+ hpricot (0.8.6)
19
+ mime-types (1.25)
20
+ mini_portile (0.5.1)
21
+ nokogiri (1.6.0)
22
+ mini_portile (~> 0.5.0)
23
+ rest-client (1.6.7)
24
+ mime-types (>= 1.16)
25
+ rspec (2.7.0)
26
+ rspec-core (~> 2.7.0)
27
+ rspec-expectations (~> 2.7.0)
28
+ rspec-mocks (~> 2.7.0)
29
+ rspec-core (2.7.1)
30
+ rspec-expectations (2.7.0)
31
+ diff-lcs (~> 1.1.2)
32
+ rspec-mocks (2.7.0)
33
+ safe_yaml (0.9.7)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ rspec
40
+ sec_query!
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # sec_entities
2
+
3
+ A ruby gem for searching and retrieving data from the Security and Exchange Commission's Edgar web system.
4
+
5
+ This gem was originally made by Ty Rauber and had more functions, but I couldn't get to work and I didn't need all of the functions so I made it work for what I needed.
6
+ If I can get the other one to work eventually, I'll retire this one.
7
+
8
+
9
+ ## Installation
10
+
11
+ To install the 'sec_query' Ruby Gem run the following command at the terminal prompt.
12
+
13
+ `gem install sec_entities`
14
+
15
+ For an example of what type of information 'sec_query' can retrieve, run the following command:
16
+
17
+ `bundle exec rspec spec`
18
+
19
+ If running 'sec_query' from the command prompt in irb:
20
+
21
+ `irb -rubygems`
22
+
23
+ `require "sec_entities"`
24
+
25
+ ## Functionality
26
+
27
+ ### FIND COMPANY:
28
+
29
+ #### By Name:
30
+
31
+ Sec::Entity.find("WEYEHAUSER")
32
+
33
+
34
+ ## License
35
+
36
+ Copyright (c) 2011 Ty Rauber
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,73 @@
1
+ module Sec
2
+ class Entity
3
+
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
9
+
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
+ }
20
+ end
21
+
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
48
+ end
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))
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))
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| v }
64
+ end
65
+
66
+ entries << doc
67
+ end
68
+
69
+ return entries
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ module SecQuery
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "rubygems"
2
+ require "rest-client"
3
+ require "hpricot"
4
+ require 'nokogiri'
5
+ require 'hashie'
6
+ require 'crack'
7
+
8
+ require "sec_entities/version"
9
+ require "sec_entities/entity"
10
+
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "sec_entities/version"
5
+ require "sec_entities"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "sec_entities"
9
+ s.version = SecQuery::VERSION
10
+ s.authors = ["Ty Rauber"]
11
+ s.email = ["tyrauber@mac.com"]
12
+ s.homepage = "https://github.com/ballantyne/sec_entities"
13
+ s.summary = "A ruby gem for querying the United States Securities and Exchange Commission Edgar System."
14
+ s.description = "This gem was originally made by Ty Rauber and had more functions, but I couldn't get to work and I didn't need all of the functions so I made it work for what I needed."
15
+
16
+ s.rubyforge_project = "sec_query"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ s.add_development_dependency "rspec"
25
+ s.add_runtime_dependency "rest-client"
26
+ s.add_runtime_dependency "nokogiri"
27
+ s.add_runtime_dependency "hashie"
28
+ s.add_runtime_dependency "crack"
29
+
30
+ end
@@ -0,0 +1,109 @@
1
+ include SecQuery
2
+
3
+ describe SecQuery::Entity do
4
+ puts "SecQuery Tests for all methods listed in the readme"
5
+
6
+ describe "Company Queries" do
7
+
8
+ let(:apple){{name: "APPLE INC",sic: "3571", symbol: "aapl", cik:"0000320193"}}
9
+
10
+ context "when quering by stock symbol" do
11
+ it "lazely" do
12
+ entity = SecQuery::Entity.find(apple[:symbol])
13
+ entity.cik.should eql(apple[:cik])
14
+ end
15
+ it "explicitly" do
16
+ entity = SecQuery::Entity.find({:symbol=> apple[:symbol]})
17
+ entity.cik.should eql(apple[:cik])
18
+ end
19
+ end
20
+
21
+ context "when querying by entity name" do
22
+ it "lazely" do
23
+ entity = SecQuery::Entity.find(apple[:name])
24
+ entity.cik.should eql(apple[:cik])
25
+ end
26
+ it "explicitly" do
27
+ entity = SecQuery::Entity.find({:name=> apple[:name]})
28
+ entity.cik.should eql(apple[:cik])
29
+ end
30
+ end
31
+
32
+ context "when querying by cik" do
33
+ it "lazely" do
34
+ entity = SecQuery::Entity.find(apple[:cik])
35
+ entity.name.should match(apple[:name])
36
+ end
37
+ it "explicitly" do
38
+ entity = SecQuery::Entity.find({:cik=> apple[:cik]})
39
+ entity.name.should match(apple[:name])
40
+ end
41
+ end
42
+ end
43
+
44
+ describe "People Queries" do
45
+
46
+ let(:jobs){{first: "Steve", middle: "P", last: "Jobs", :cik => "0001007844"}}
47
+
48
+ context "when querying by name" do
49
+ it "first, middle and last name" do
50
+ entity = SecQuery::Entity.find({:first=> jobs[:first], :middle=> jobs[:middle], :last=> jobs[:last]})
51
+ entity.cik.should eql(jobs[:cik])
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "Relationships, Transactions and Filings" do
57
+
58
+ ## Using Steve, because data should not change in the future. RIP.
59
+
60
+ let(:jobs){{
61
+ first: "Steve", middle: "P", last: "Jobs", :cik => "0001007844",
62
+ relationships:[
63
+ {cik: "0000320193", name: "APPLE INC"},
64
+ {cik: "0001001039", name: "WALT DISNEY CO/"},
65
+ {cik: "0001002114", name: "PIXAR \\CA\\"}
66
+ ],
67
+ transactions:[
68
+ {filing_number: "0001181431-07-052839", reporting_owner: "APPLE INC", shares:120000.0},
69
+ {filing_number: "0001181431-07-052839", reporting_owner: "APPLE INC", shares: 40000.0},
70
+ {filing_number: "0001181431-07-052839", reporting_owner: "APPLE INC", shares: 40000.0},
71
+ {filing_number: "0001181431-07-052839", reporting_owner: "APPLE INC", shares: 40000.0},
72
+ {filing_number: "0001181431-06-028746", reporting_owner: "WALT DISNEY CO/", shares: 138000004.0},
73
+ {filing_number: "0001356184-06-000008", reporting_owner: "PIXAR \\CA\\", shares: 60000002.0},
74
+ {filing_number: "0001181431-06-019230", reporting_owner: "APPLE COMPUTER INC", shares: 4573553.0},
75
+ {filing_number: "0001181431-06-028747", reporting_owner: "WALT DISNEY CO/", shares: 0.0}
76
+ ],
77
+ filings:[
78
+ {cik: "0001007844", file_id: "0001181431-07-052839"},
79
+ {cik: "0001007844", file_id: "0001356184-06-000008"},
80
+ {cik: "0001007844", file_id: "0001193125-06-103741"},
81
+ {cik: "0001007844", file_id: "0001181431-06-028747"},
82
+ {cik: "0001007844", file_id: "0001181431-06-028746"},
83
+ {cik: "0001007844", file_id: "0001181431-06-019230"},
84
+ {cik: "0001007844", file_id: "0001193125-06-019727"},
85
+ {cik: "0001007844", file_id: "0001104659-03-004723"}
86
+ ]
87
+ }}
88
+
89
+ let(:entity) {SecQuery::Entity.find({:first=> "Steve", middle: "P", last: "Jobs", :cik => "0001007844"}, true)}
90
+
91
+ context "when quering entities with option 'true'" do
92
+ it "should provide relationships" do
93
+ entity.relationships.each_with_index do |r, i|
94
+ r.cik.should eql(jobs[:relationships][i][:cik])
95
+ end
96
+ end
97
+ it "should provide transactions" do
98
+ entity.transactions.each_with_index do |t, i|
99
+ t.filing_number.should eql(jobs[:transactions][i][:filing_number])
100
+ end
101
+ end
102
+ it "should provide filings" do
103
+ entity.filings.each_with_index do |f, i|
104
+ f.file_id.should eql(jobs[:filings][i][:file_id])
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1 @@
1
+ require "sec_query"
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sec_entities
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ty Rauber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: crack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: This gem was originally made by Ty Rauber and had more functions, but
84
+ I couldn't get to work and I didn't need all of the functions so I made it work
85
+ for what I needed.
86
+ email:
87
+ - tyrauber@mac.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - README.md
95
+ - Rakefile
96
+ - lib/.DS_Store
97
+ - lib/sec_entities.rb
98
+ - lib/sec_entities/.DS_Store
99
+ - lib/sec_entities/entity.rb
100
+ - lib/sec_entities/version.rb
101
+ - sec_entities.gemspec
102
+ - spec/sec_query_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/ballantyne/sec_entities
105
+ licenses: []
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project: sec_query
123
+ rubygems_version: 2.0.6
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: A ruby gem for querying the United States Securities and Exchange Commission
127
+ Edgar System.
128
+ test_files:
129
+ - spec/sec_query_spec.rb
130
+ - spec/spec_helper.rb