stockticker_cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd8cd084b418a98723b9de29f8a0dfa10d708dc8402753e7d2c55e6bf8a99a36
4
+ data.tar.gz: 0f7a88f0c654dfafb452c17780dbc16bdc372429a5550875dda63fcebdec89cb
5
+ SHA512:
6
+ metadata.gz: 98741371019935c5b46421c2ea82415d149adaf696a47df46c69ecbbba3cfda4230e96904a8d0ee58329b1662c81597ea5a42543a13de0e58c35f88601e8ad9d
7
+ data.tar.gz: 1b48c32b4f6cd9f7216cc1c841adf3b752f0e83f7e9e9b649b1651338ccde18a915e726a7baedccbeaa118c9024d8ce9a3cf554efcf088e941630d890152a2fb
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.env/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .env
11
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in stockticker_cli.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stockticker_cli (0.1.0)
5
+ dotenv
6
+ json
7
+ pry
8
+ rest-client
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ coderay (1.1.2)
14
+ domain_name (0.5.20190701)
15
+ unf (>= 0.0.5, < 1.0.0)
16
+ dotenv (2.7.5)
17
+ gem-release (2.1.1)
18
+ http-accept (1.7.0)
19
+ http-cookie (1.0.3)
20
+ domain_name (~> 0.5)
21
+ json (2.3.0)
22
+ method_source (1.0.0)
23
+ mime-types (3.3.1)
24
+ mime-types-data (~> 3.2015)
25
+ mime-types-data (3.2019.1009)
26
+ netrc (0.11.0)
27
+ pry (0.13.0)
28
+ coderay (~> 1.1)
29
+ method_source (~> 1.0)
30
+ rake (12.3.3)
31
+ rest-client (2.1.0)
32
+ http-accept (>= 1.7.0, < 2.0)
33
+ http-cookie (>= 1.0.2, < 2.0)
34
+ mime-types (>= 1.16, < 4.0)
35
+ netrc (~> 0.8)
36
+ unf (0.1.4)
37
+ unf_ext
38
+ unf_ext (0.0.7.7)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ gem-release
45
+ rake (~> 12.0)
46
+ stockticker_cli!
47
+
48
+ BUNDLED WITH
49
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TerryThreatt
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,39 @@
1
+ # StocktickerCli
2
+
3
+ Welcome to the Stock Ticker CLI app! This gem will allow you to find real-time stock quotes and gain additional company information for each stock.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'stockticker_cli'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install stockticker_cli
20
+
21
+ ## Usage
22
+
23
+ 1. Choose to receive the top gainers in the stock market today.
24
+ 2. You will have a option to receive additional information about company.
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ 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](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<github username>/stockticker_cli.
35
+
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stockticker_cli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
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
data/bin/stockticker ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stockticker_cli"
5
+
6
+ StocktickerCli::CLI.new.call
@@ -0,0 +1,25 @@
1
+ class StocktickerCli::API
2
+ BASE_URL = 'https://fmpcloud.io/api/v3/'
3
+ KEY = ENV["API_KEY"]
4
+
5
+
6
+
7
+ # Api call
8
+ def self.query
9
+ # https://fmpcloud.io/api/v3/actives?apikey=4b31fc84cd3248a0f61868b96f531bde
10
+ results = RestClient.get("#{BASE_URL}actives?apikey=#{KEY}")
11
+ json = JSON.parse(results)
12
+
13
+
14
+ # iterating through results and creating stock instances
15
+ json.each do |stock_hash|
16
+ StocktickerCli::STOCK.new(stock_hash)
17
+ end
18
+ end
19
+
20
+ def self.info_query(stock_obj)
21
+ results = RestClient.get("#{BASE_URL}profile/#{stock_obj.ticker}?apikey=#{KEY}")
22
+ json = JSON.parse(results)
23
+ stock_obj.set_attributes(json[0])
24
+ end
25
+ end
@@ -0,0 +1,81 @@
1
+
2
+ class StocktickerCli::CLI
3
+
4
+ def call
5
+ welcome
6
+ end
7
+
8
+ def welcome
9
+ puts "Welcome to the stock ticker cli app!"
10
+ puts ""
11
+ sleep(1)
12
+ menu
13
+ end
14
+
15
+ def menu
16
+ puts "Would you like to view the top gainers in the stock market today?"
17
+ sleep(1)
18
+ puts ""
19
+ puts "Type 'yes' to view gainers or type 'exit' to quit the cli app"
20
+ puts ""
21
+
22
+ input = gets.strip.downcase
23
+
24
+ if input == 'exit'
25
+ goodbye
26
+ elsif input == 'yes'
27
+ # API call
28
+ puts ""
29
+ stock_query = StocktickerCli::API.query
30
+
31
+ # Return
32
+ puts "Pick a stock from the list"
33
+ puts ""
34
+ puts "Gainers List:"
35
+ StocktickerCli::STOCK.all.each.with_index(1) do |s, i|
36
+ puts "#{i}. #{s.ticker} - #{s.companyName} - $#{s.price} - #{s.changesPercentage}"
37
+ end
38
+
39
+ puts ""
40
+ submenu
41
+ else
42
+ puts "Try again"
43
+ puts ""
44
+ menu
45
+ end
46
+ end
47
+
48
+ def submenu
49
+ puts "Type a number between '1 - 10' on gainers list for more information on the stock."
50
+ sleep(1)
51
+
52
+ input = gets.strip.to_i
53
+
54
+ if (input.between?(0, 10))
55
+ s = StocktickerCli::STOCK.all[input - 1]
56
+ StocktickerCli::API.info_query(s)
57
+ puts ""
58
+ puts "#{s.symbol} - #{s.companyName} - $#{s.price}"
59
+ puts ""
60
+ puts "Change: $ #{s.changes}"
61
+ puts "Sector: #{s.sector}"
62
+ puts "Industry: #{s.industry}"
63
+ puts "Website: #{s.website}"
64
+ puts ""
65
+ puts "Description: #{s.description}"
66
+ puts ""
67
+ sleep(1.5)
68
+ StocktickerCli::STOCK.reset
69
+ menu
70
+ else
71
+ puts "Please try again"
72
+ submenu
73
+ end
74
+ end
75
+
76
+ def goodbye
77
+ puts "Happy Trading"
78
+ sleep(1)
79
+ puts "Goodbye!"
80
+ end
81
+ end
@@ -0,0 +1,28 @@
1
+
2
+ # "symbol"=>"PAYX", "name"=>"Paychex, Inc.", "price"=>60.17
3
+
4
+ class StocktickerCli::STOCK
5
+ attr_accessor :ticker, :symbol, :changesPercentage, :name, :price, :changes, :companyName, :industry, :website, :description, :sector
6
+
7
+ @@all = []
8
+ def initialize(args)
9
+ set_attributes(args)
10
+ @@all << self
11
+ end
12
+
13
+ def set_attributes(hash)
14
+ hash.each do |k, v|
15
+ # checks if method exists for instance of stock
16
+ self.send("#{k}=", v) if self.respond_to?(k)
17
+ end
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ def self.reset
25
+ @@all.clear
26
+ end
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module StocktickerCli
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ require 'pry'
2
+ require 'json'
3
+ require 'rest-client'
4
+ require 'dotenv'
5
+ Dotenv.load
6
+
7
+
8
+
9
+ require_relative "./stockticker_cli/version"
10
+ require_relative "./stockticker_cli/cli"
11
+ require_relative "./stockticker_cli/stock"
12
+ require_relative "./stockticker_cli/api"
13
+
14
+
15
+
16
+
17
+
18
+
19
+
data/notes.md ADDED
@@ -0,0 +1,7 @@
1
+ - A command line interface for getting daily stock quotes
2
+ - welcome user
3
+ - show menu
4
+ - Users type name/ticker symbol
5
+ - Show company names
6
+ - List selected company stock prices
7
+ - Give option to receive more info
@@ -0,0 +1,35 @@
1
+ require_relative 'lib/stockticker_cli/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "stockticker_cli"
5
+ spec.version = StocktickerCli::VERSION
6
+ spec.authors = ["TerryThreatt"]
7
+ spec.email = ["terry.threatt@gmail.com"]
8
+
9
+ spec.summary = %q{This application will use the command-line to query any stock ticker symbol and return the current price.}
10
+ spec.description = %q{Real-time stock quote app.}
11
+ spec.homepage = "https://github.com/TerryThreatt/stockticker_cli/"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/TerryThreatt/stockticker_cli/"
19
+ spec.metadata["changelog_uri"] = "https://github.com/TerryThreatt/stockticker_cli/"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "bin"
27
+ spec.executables = ["stockticker"]
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency('gem-release')
31
+ spec.add_dependency('pry')
32
+ spec.add_dependency('json')
33
+ spec.add_dependency('rest-client')
34
+ spec.add_dependency('dotenv')
35
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stockticker_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TerryThreatt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem-release
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: pry
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: json
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: rest-client
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: dotenv
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: Real-time stock quote app.
84
+ email:
85
+ - terry.threatt@gmail.com
86
+ executables:
87
+ - stockticker
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - bin/stockticker
100
+ - lib/stockticker_cli.rb
101
+ - lib/stockticker_cli/api.rb
102
+ - lib/stockticker_cli/cli.rb
103
+ - lib/stockticker_cli/stock.rb
104
+ - lib/stockticker_cli/version.rb
105
+ - notes.md
106
+ - stockticker_cli.gemspec
107
+ homepage: https://github.com/TerryThreatt/stockticker_cli/
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org/
112
+ homepage_uri: https://github.com/TerryThreatt/stockticker_cli/
113
+ source_code_uri: https://github.com/TerryThreatt/stockticker_cli/
114
+ changelog_uri: https://github.com/TerryThreatt/stockticker_cli/
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 2.3.0
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.1.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: This application will use the command-line to query any stock ticker symbol
134
+ and return the current price.
135
+ test_files: []