cik 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0235e9a80f3c3421a119d34ba0d9c2bca9d658e4
4
- data.tar.gz: 9d09de49176462ee21f217d112af3a7e3ce2f671
3
+ metadata.gz: 64ee71ff81ed6397be64de20cc6a7fa22e6fc37e
4
+ data.tar.gz: 1677df5928aeeb4997e806c91e169d5c2306df9e
5
5
  SHA512:
6
- metadata.gz: 57f5590480367c5d3c8d2e393b3e0b2a87f1a5111731a5ca3a00792f20768b766f9d6244f3b9a3b93bfb51ff7c757c773fec99c9e7507ff3249ee84771034b0c
7
- data.tar.gz: 011a56babedb5131b8885e90d7149d0471d709004a160fc0c63d7acd54cd4b99ec434b9f64ca60c4222362bf04927ffcf1f13b17f893b7e51286090cdfbd565b
6
+ metadata.gz: 71459c5054dd662f15ae4bf9e6c2292e17da1fb17fbf5fe243eaf3d568250d6f3724a76ad027f90cddb2e7b827447ec9a74b95fe85815f614960b27af6b1a700
7
+ data.tar.gz: 3be2e1b8cd39aa5aea846463cbb7e720263dace9e8a146d605dbc9f3c234c0553704e1bde5f594b1d05b7105852bfe9c51d4fa8d3b50bb6a9899a9adbbd69ad6
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.1.3"
4
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Cik
2
2
 
3
- TODO: Write a gem description
3
+ A Central Index Key or CIK number is a number given to an individual or company by the [United States Securities and
4
+ Exchange Commission (SEC)](http://www.sec.gov). The number is used to identify the filings of a company in the [EDGAR
5
+ database](http://www.sec.gov/edgar/searchedgar/companysearch.html).
6
+
7
+ This gem allows to look up the EDGAR database by symbol to get the company CIK.
4
8
 
5
9
  ## Installation
6
10
 
@@ -18,12 +22,47 @@ Or install it yourself as:
18
22
 
19
23
  ## Usage
20
24
 
21
- TODO: Write usage instructions here
25
+ Usage is pretty simple:
26
+
27
+ ```ruby
28
+ Cik.lookup('CSCO')
29
+ ```
30
+
31
+ The response is a Hash with this format:
32
+
33
+ ```ruby
34
+ {
35
+ :cik => "0000858877",
36
+ :name => "CISCO SYSTEMS, INC.",
37
+ :sic => "3576"
38
+ }
39
+ ```
40
+
41
+ | Key | Description |
42
+ | ----------| ----------- |
43
+ | cik | CIK number |
44
+ | name | Entity name |
45
+ | sic | SIC (Standard Industrial Classification) code |
22
46
 
23
47
  ## Contributing
24
48
 
25
- 1. Fork it ( http://github.com/<my-github-username>/cik/fork )
49
+ 1. Fork it ( http://github.com/javiervidal/cik/fork )
26
50
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
51
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
52
  4. Push to the branch (`git push origin my-new-feature`)
29
53
  5. Create new Pull Request
54
+
55
+ ## Code Status
56
+
57
+ [![Gem Version](https://badge.fury.io/rb/cik.svg)](http://badge.fury.io/rb/cik)
58
+ [![Build Status](https://travis-ci.org/javiervidal/cik.svg?branch=master)](https://travis-ci.org/javiervidal/cik)
59
+ [![Coverage Status](https://coveralls.io/repos/javiervidal/cik/badge.png?branch=master)](https://coveralls.io/r/javiervidal/cik?branch=master)
60
+ [![Code Climate](https://codeclimate.com/github/javiervidal/cik/badges/gpa.svg)](https://codeclimate.com/github/javiervidal/cik)
61
+
62
+ ## Copyright
63
+
64
+ Copyright (c) 2014 – ∞ Javier Vidal
65
+
66
+ ## License
67
+
68
+ This gem is released under the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :console do
4
+ require "awesome_print"
5
+ require "irb"
6
+ require "irb/completion"
7
+ require "cik"
8
+ ARGV.clear
9
+ IRB.start
10
+ end
data/cik.gemspec CHANGED
@@ -20,4 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "awesome_print"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "webmock"
27
+ spec.add_development_dependency "coveralls"
28
+ spec.add_runtime_dependency "nokogiri"
23
29
  end
data/lib/cik.rb CHANGED
@@ -1,5 +1,2 @@
1
- require "cik/version"
2
-
3
- module Cik
4
- # Your code goes here...
5
- end
1
+ require 'cik/version'
2
+ require 'cik/cik'
data/lib/cik/cik.rb ADDED
@@ -0,0 +1,38 @@
1
+ class Cik
2
+
3
+ require 'open-uri'
4
+ require 'nokogiri'
5
+
6
+ class << self
7
+
8
+ def lookup(symbol)
9
+ doc = Nokogiri::HTML(open(edgar_lookup_url(symbol)))
10
+ md = /(.+)\sCIK#:\s(\d{10})/.match(company_info(doc))
11
+ if md
12
+ {
13
+ cik: md[2],
14
+ name: md[1],
15
+ sic: sic(doc)
16
+ }
17
+ else
18
+ nil
19
+ end
20
+ end
21
+
22
+ def edgar_lookup_url(symbol)
23
+ "http://www.sec.gov/cgi-bin/browse-edgar?CIK=#{symbol}&action=getcompany"
24
+ end
25
+
26
+ def company_info(doc)
27
+ doc.css("div.companyInfo").css("span.companyName").text
28
+ end
29
+
30
+ def sic(doc)
31
+ doc.css("p.identInfo a")[0].text
32
+ end
33
+
34
+ end
35
+
36
+ private_class_method :edgar_lookup_url, :edgar_lookup_url, :sic
37
+
38
+ end
data/lib/cik/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Cik
2
- VERSION = "0.0.1"
3
- end
1
+ class Cik
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cik do
4
+
5
+ describe '.lookup' do
6
+
7
+ context 'when a valid symbol is looked up' do
8
+
9
+ let(:entity) { Cik.lookup('CSCO') }
10
+
11
+ it 'returns a cik' do
12
+ expect(entity[:cik]).to eq('0000858877')
13
+ end
14
+
15
+ it 'returns an entity name' do
16
+ expect(entity[:name]).to eq('CISCO SYSTEMS, INC.')
17
+ end
18
+
19
+ it 'returns a sic' do
20
+ expect(entity[:sic]).to eq('3576')
21
+ end
22
+
23
+ end
24
+
25
+ context 'when an invalid symbol is looked up' do
26
+
27
+ let(:entity) { Cik.lookup('ZZZZ') }
28
+
29
+ it 'returns nil' do
30
+ expect(entity).to be_nil
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,6 @@
1
+ <div class="companyInfo">
2
+ <span class="companyName">CISCO SYSTEMS, INC. <acronym title="Central Index Key">CIK</acronym>#: <a href="/cgi-bin/browse-edgar?action=getcompany&amp;CIK=0000858877&amp;owner=include&amp;count=40">0000858877 (see all company filings)</a></span>
3
+ <p class="identInfo"><acronym title="Standard Industrial Code">SIC</acronym>: <a href="/cgi-bin/browse-edgar?action=getcompany&amp;SIC=3576&amp;owner=include&amp;count=40">3576</a> - COMPUTER COMMUNICATIONS EQUIPMENT<br />State location: <a href="/cgi-bin/browse-edgar?action=getcompany&amp;State=CA&amp;owner=include&amp;count=40">CA</a> | State of Inc.: <strong>CA</strong> | Fiscal Year End: 0728<br />formerly: CISCO SYSTEMS INC (filings through 2011-11-22)<br />(Assistant Director Office: 3)<br />Get <a href="/cgi-bin/own-disp?action=getissuer&amp;CIK=0000858877"><b>insider transactions</b></a> for this <b>issuer</b>.
4
+ <br />Get <a href="/cgi-bin/own-disp?action=getowner&amp;CIK=0000858877"><b>insider transactions</b></a> for this <b>reporting owner</b>.
5
+ </p>
6
+ </div>
@@ -0,0 +1,44 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+
8
+ require 'cik'
9
+ require 'webmock/rspec'
10
+
11
+ # This file was generated by the `rspec --init` command. Conventionally, all
12
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
13
+ # Require this file using `require "spec_helper"` to ensure that it is only
14
+ # loaded once.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ config.run_all_when_everything_filtered = true
19
+ config.filter_run :focus
20
+
21
+ # Run specs in random order to surface order dependencies. If you find an
22
+ # order dependency and want to debug it, you can fix the order by providing
23
+ # the seed, which is printed after each run.
24
+ # --seed 1234
25
+ config.order = 'random'
26
+
27
+ config.before(:each) do
28
+ stub_request(:get, "http://www.sec.gov/cgi-bin/browse-edgar?CIK=CSCO&action=getcompany").
29
+ with(:headers => {'Accept' => '*/*'}).
30
+ to_return(:status => 200, :body => fixture('csco.html'), :headers => {})
31
+ stub_request(:get, "http://www.sec.gov/cgi-bin/browse-edgar?CIK=ZZZZ&action=getcompany").
32
+ with(:headers => {'Accept' => '*/*'}).
33
+ to_return(:status => 200, :body => "", :headers => {})
34
+ end
35
+
36
+ end
37
+
38
+ def fixture_path
39
+ File.expand_path('../fixtures', __FILE__)
40
+ end
41
+
42
+ def fixture(file)
43
+ File.new(fixture_path + '/' + file)
44
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Vidal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,90 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
41
125
  description: CIK lookup in EDGAR database
42
126
  email:
43
127
  - javier@javiervidal.net
@@ -46,13 +130,19 @@ extensions: []
46
130
  extra_rdoc_files: []
47
131
  files:
48
132
  - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
49
135
  - Gemfile
50
136
  - LICENSE.txt
51
137
  - README.md
52
138
  - Rakefile
53
139
  - cik.gemspec
54
140
  - lib/cik.rb
141
+ - lib/cik/cik.rb
55
142
  - lib/cik/version.rb
143
+ - spec/cik/cik_spec.rb
144
+ - spec/fixtures/csco.html
145
+ - spec/spec_helper.rb
56
146
  homepage: ''
57
147
  licenses:
58
148
  - MIT
@@ -77,4 +167,7 @@ rubygems_version: 2.2.2
77
167
  signing_key:
78
168
  specification_version: 4
79
169
  summary: CIK lookup in EDGAR database
80
- test_files: []
170
+ test_files:
171
+ - spec/cik/cik_spec.rb
172
+ - spec/fixtures/csco.html
173
+ - spec/spec_helper.rb