financial_data_pull 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19e7abb1a192884559fa00619957d15480acee69
4
+ data.tar.gz: a961a4233b2538bfde68127cccc9eaecc6bc3f4a
5
+ SHA512:
6
+ metadata.gz: 467b966cd4ef6e456d9cce377442a6e2c781952bfcbf40914743ee2e578496304f6de07e6ad9e013a5695d3e808e1a29f390f440cfd42215847816c20f9aa3ba
7
+ data.tar.gz: ddb36e0e74f2a791daa7bc1012fceee9ecfc7efaaeed6f60371d6b259454055da2b6396463aee7710bdcd23d62eab5591886b85033bc8d0b184f180303e2caa8
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at tylor.balson@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in financial_data_pull.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ financial_data_pull (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.1)
10
+ diff-lcs (1.2.5)
11
+ method_source (0.8.2)
12
+ pry (0.10.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.8.1)
15
+ slop (~> 3.4)
16
+ rake (10.5.0)
17
+ rspec (3.4.0)
18
+ rspec-core (~> 3.4.0)
19
+ rspec-expectations (~> 3.4.0)
20
+ rspec-mocks (~> 3.4.0)
21
+ rspec-core (3.4.4)
22
+ rspec-support (~> 3.4.0)
23
+ rspec-expectations (3.4.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-mocks (3.4.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-support (3.4.1)
30
+ slop (3.6.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.11)
37
+ financial_data_pull!
38
+ pry
39
+ rake (~> 10.0)
40
+ rspec (~> 3.0)
41
+
42
+ BUNDLED WITH
43
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 tmb41
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # FinancialDataPull
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'financial_data_pull'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install financial_data_pull
18
+
19
+ Usage
20
+
21
+ Run: financial_data_pull after installing the gem.
22
+
23
+ You will be greeted with a list of the most popular stocks which you can select and print immediately, or, you can select to input your own ticker for whichever stock you would like. Keep printing more stocks, or select 6 or type EXIT to exit the program.
24
+
25
+ Development
26
+
27
+ To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
28
+
29
+ To run the development version of the CLI run bundle exec bin/now-playing.
30
+
31
+ Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tmb41/tylor-cli-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
34
+
35
+ License
36
+
37
+ The gem is available as open source under the terms of the MIT License.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ #Bundler.require(:default, :development, :production)
5
+ require "financial_data_pull"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require_relative "../lib/financial_data_pull"
5
+
6
+ FinancialDataPull::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ require_relative '../lib/financial_data_pull/scraper'
6
+ require_relative '../lib/financial_data_pull/stock'
7
+ require_relative '../lib/financial_data_pull/cli'
8
+ require_relative "../lib/financial_data_pull/version"
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'financial_data_pull/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "financial_data_pull"
8
+ spec.version = FinancialDataPull::VERSION
9
+ spec.authors = ["tmb41"]
10
+ spec.email = ["tylor.balson@gmail.com"]
11
+
12
+ spec.summary = %q{Displays simple CLI to quickly pull important financial metrics for some
13
+ of the most popular stocks, or also allows for any ticker to be inputted and pulled.}
14
+ spec.homepage = "https://github.com/tmb41/tylor-cli-gem"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "pry"
34
+
35
+ end
@@ -0,0 +1,5 @@
1
+ module FinancialDataPull
2
+ end
3
+
4
+
5
+ require_relative "../config/environment"
@@ -0,0 +1,61 @@
1
+
2
+
3
+ class FinancialDataPull::CLI
4
+ attr_accessor :ticker
5
+
6
+ def call
7
+
8
+ initialprint
9
+ start
10
+ end
11
+
12
+ def initialprint
13
+ puts "~~~ Welcome to Tylor's CLI GEM ~~~\n"
14
+ end
15
+
16
+ def start
17
+
18
+ input = nil
19
+ while input != "exit"
20
+
21
+ puts "Please select your desired option:"
22
+ puts "1. GOOG - Alphabet, Inc."
23
+ puts "2. TSLA - Tesla Motors, Inc."
24
+ puts "3. AAPL - Apple, Inc."
25
+ puts "4. FB - Facebook, Inc."
26
+ puts "5. Type in ticker manually"
27
+ puts "6. EXIT\n"
28
+ input = gets.strip.downcase
29
+
30
+ case input
31
+ when "1"
32
+ puts "Google was selected, printing Google:"
33
+ @ticker = "goog"
34
+ FinancialDataPull::Scraper.scrape(ticker)
35
+ when "2"
36
+ puts "Tesla was slected, printing Tesla:"
37
+ @ticker = "tsla"
38
+ FinancialDataPull::Scraper.scrape(ticker)
39
+ when "3"
40
+ puts "Apple was selected, printing Apple:"
41
+ @ticker = "aapl"
42
+ FinancialDataPull::Scraper.scrape(ticker)
43
+ when "4"
44
+ puts "Facebook was selected, printing Facebook:"
45
+ @ticker = "fb"
46
+ FinancialDataPull::Scraper.scrape(ticker)
47
+ when "5"
48
+ puts "Enter your ticker:"
49
+ @ticker = gets.strip.downcase
50
+ FinancialDataPull::Scraper.scrape(ticker)
51
+ when "6"
52
+ puts "Exiting the program..."
53
+ input = "exit"
54
+ else
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+
61
+ end
@@ -0,0 +1,11 @@
1
+
2
+ class FinancialDataPull::Scraper
3
+
4
+ def self.scrape(ticker)
5
+
6
+ website = Nokogiri::HTML(open("http://finance.yahoo.com/q?s=#{ticker}&ql=1"))
7
+ FinancialDataPull::Stock.new_from_scrape(website)
8
+
9
+ end
10
+
11
+ end
@@ -0,0 +1,79 @@
1
+
2
+ class FinancialDataPull::Stock
3
+ attr_accessor :ticker, :title, :prevclose, :open, :bid, :ask, :oneyeartarget,
4
+ :beta, :nextearningdate, :daysrange, :fiftytwoweekrange, :volume, :avgvolume, :marketcap,
5
+ :pettm, :epsttm, :divyield
6
+
7
+
8
+ def self.new_from_scrape(website)
9
+
10
+ self.new(
11
+ # 0 - 14 from table
12
+ @prevclose = website.css("td.yfnc_tabledata1")[0].text,
13
+ @open = website.css("td.yfnc_tabledata1")[1].text,
14
+ @bid = website.css("td.yfnc_tabledata1")[2].text,
15
+ @ask = website.css("td.yfnc_tabledata1")[3].text,
16
+ @oneyeartarget = website.css("td.yfnc_tabledata1")[4].text,
17
+ @beta = website.css("td.yfnc_tabledata1")[5].text,
18
+ @nextearningdate = website.css("td.yfnc_tabledata1")[6].text,
19
+ @daysrange = website.css("td.yfnc_tabledata1")[7].text,
20
+ @fiftytwoweekrange = website.css("td.yfnc_tabledata1")[8].text,
21
+ @volume = website.css("td.yfnc_tabledata1")[9].text,
22
+ @avgvolume = website.css("td.yfnc_tabledata1")[10].text,
23
+ @marketcap = website.css("td.yfnc_tabledata1")[11].text,
24
+ @pettm = website.css("td.yfnc_tabledata1")[12].text,
25
+ @epsttm = website.css("td.yfnc_tabledata1")[13].text,
26
+ @divyield = website.css("td.yfnc_tabledata1")[14].text,
27
+ #title
28
+ @title = website.css(".title h2").text
29
+ )
30
+ printstock
31
+
32
+ end
33
+
34
+ def initialize(prevclose=nil, open=nil, bid=nil, ask=nil, oneyeartarget=nil, beta=nil, nextearningdate=nil, daysrange=nil, fiftytwoweekrange=nil, volume=nil, avgvolume=nil, marketcap=nil, pettm=nil, epsttm=nil, divyield=nil, title=nil)
35
+ @prevclose = prevclose
36
+ @open = open
37
+ @bid = bid
38
+ @ask = ask
39
+ @oneyeartarget = oneyeartarget
40
+ @beta = beta
41
+ @nextearningdate = nextearningdate
42
+ @daysrange = daysrange
43
+ @fiftytwoweekrange = fiftytwoweekrange
44
+ @volume = volume
45
+ @avgvolume = avgvolume
46
+ @marketcap = marketcap
47
+ @pettm = pettm
48
+ @epsttm = epsttm
49
+ @divyield = divyield
50
+ @title = title
51
+ end
52
+
53
+ def self.printstock
54
+ puts "......................................."
55
+ puts " --->#{@title}<---"
56
+ puts " Prev Close: #{@prevclose}"
57
+ puts " Open: #{@open}"
58
+ puts " Bid: #{@bid}"
59
+ puts " Ask: #{@ask}"
60
+ puts " 1y Target Est: #{@oneyeartarget}"
61
+ puts " Beta: #{@beta}"
62
+ puts " Next Earnings Date: #{@nextearningdate}"
63
+ puts " Day's Range: #{@daysrange}"
64
+ puts " 52wk Range: #{@fiftytwoweekrange}"
65
+ puts " Volume: #{@volume}"
66
+ puts " Avg Vol (3m): #{@avgvolume}"
67
+ puts " Market Cap: #{@marketcap}"
68
+ puts " P/E (ttm): #{@pettm}"
69
+ puts " EPS (ttm): #{@epsttm}"
70
+ puts " Div & Yield: #{@divyield}"
71
+ puts ".......................................\n\n"
72
+ end
73
+
74
+
75
+
76
+ end
77
+
78
+
79
+
@@ -0,0 +1,3 @@
1
+ module FinancialDataPull
2
+ VERSION = "0.2.0"
3
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: financial_data_pull
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - tmb41
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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
+ description:
70
+ email:
71
+ - tylor.balson@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/financial_data_pull
86
+ - bin/setup
87
+ - config/environment.rb
88
+ - financial_data_pull.gemspec
89
+ - lib/financial_data_pull.rb
90
+ - lib/financial_data_pull/cli.rb
91
+ - lib/financial_data_pull/scraper.rb
92
+ - lib/financial_data_pull/stock.rb
93
+ - lib/financial_data_pull/version.rb
94
+ homepage: https://github.com/tmb41/tylor-cli-gem
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.5.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Displays simple CLI to quickly pull important financial metrics for some of
118
+ the most popular stocks, or also allows for any ticker to be inputted and pulled.
119
+ test_files: []