gold-price 0.1.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: 2b54fe9cc7bbdf82bf04755fec1ae1b2241ea569
4
+ data.tar.gz: 8f8b16da3a1f5041690c0e26314cd5e0cf3dc5dd
5
+ SHA512:
6
+ metadata.gz: 9d3fbee5c3a618baedb663770c663be230b7b297851d852156f096e4c5a9cb1b7a3aa0b1ada6e21b6cc52cc9ce4b233b2c9b0f46f4aa1b0db17ddfd76c29a7d8
7
+ data.tar.gz: 34a3da13b6c9c9a2c929720b4df3cfc54dc77bbedda868f682630789a0fb26792bfdbb1aee682e66558763c682d485b8433bde218b063c37aa9430bcd784d568
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gold_price.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
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
+ # GoldPrice
2
+
3
+ GoldPrice will give you the current ask price for gold and silver both in grams and in ounces from ampex.com
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gold_price'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gold_price
20
+
21
+ ## Usage
22
+
23
+ Select gold or silver in either ounces or grams to receive the most up to date ask price.
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lilithlotus/Jessica-Bensch-CLI-app.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://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 "gold_price"
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/gold-price ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './lib/gold_price.rb'
4
+
5
+ GoldPrice::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,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib","gold_price.rb")
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gold_price/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gold-price"
8
+ spec.version = GoldPrice::VERSION
9
+ spec.authors = ["Jessica Bensch"]
10
+ spec.email = ["jessica.bensch11@gmail.com"]
11
+
12
+ spec.summary = %q{Retrieves gold and silver prices.}
13
+ spec.description = %q{Allows you to retrieve the current price of gold or silver in grams or ounces.}
14
+ spec.homepage = "https://github.com/lilithlotus/Jessica-Bensch-CLI-app"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+
25
+ spec.executables = "gold-price"
26
+ spec.require_paths = ["lib" "lib/gold_price"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.15"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "pry"
31
+ spec.add_dependency "nokogiri"
32
+
33
+ end
@@ -0,0 +1,71 @@
1
+ # CLI Controller
2
+ class GoldPrice::CLI
3
+
4
+ attr_accessor :metal, :measurement
5
+
6
+ def call
7
+ puts "Welcome to Gold Price!"
8
+ puts "__*__"
9
+ metal_menu
10
+ end
11
+
12
+ def metal_menu
13
+ puts "Please enter the number of the metal you would like to see the price of and press enter:"
14
+ puts "1. Gold"
15
+ puts "2. Silver"
16
+ @metal = gets.strip.to_i
17
+
18
+ if @metal < 1 || @metal > 2
19
+ puts "Please enter a valid selection."
20
+ metal_menu
21
+ end
22
+ measurement_menu
23
+ end
24
+
25
+ def measurement_menu
26
+ puts "Please enter the number of the measurement you would like to use and press enter:"
27
+ puts "1. Grams"
28
+ puts "2. Ounces"
29
+ @measurement = gets.strip.to_i
30
+
31
+ if @measurement < 1 || @measurement > 2
32
+ puts "Please enter a valid selection."
33
+ measurement_menu
34
+ end
35
+ price
36
+ end
37
+
38
+ def price
39
+ @silver_prices = GoldPrice::Price.silver_prices
40
+ @gold_prices = GoldPrice::Price.gold_prices
41
+ silver_price = @silver_prices[0]
42
+ gold_price = @gold_prices[0]
43
+ if @metal == 1 && @measurement == 1
44
+ puts "Today the price of gold per gram is $#{gold_price.gold_by_gram} USD."
45
+ puts "__*__"
46
+ elsif @metal == 1 && @measurement == 2
47
+ puts "Today the price of gold per ounce is $#{gold_price.gold_by_ounce} USD."
48
+ puts "__*__"
49
+ elsif @metal == 2 && @measurement == 1
50
+ puts "Today the price of silver per gram is $#{silver_price.silver_by_gram} USD."
51
+ puts "__*__"
52
+ elsif @metal == 2 && @measurement == 2
53
+ puts "Today the price of silver per ounce is $#{silver_price.silver_by_ounce} USD."
54
+ puts "__*__"
55
+ end
56
+
57
+
58
+ puts "Would you like to see another price?"
59
+ input = gets.strip.upcase
60
+ if input == "Y" || input == "YES"
61
+ metal_menu
62
+ else
63
+ goodbye
64
+ end
65
+ end
66
+
67
+ def goodbye
68
+ puts "See you tomorrow! Stay Golden."
69
+ end
70
+
71
+ end
@@ -0,0 +1,22 @@
1
+ class GoldPrice::Price
2
+
3
+ attr_accessor :gold_by_gram, :gold_by_ounce, :silver_by_gram, :silver_by_ounce
4
+
5
+ def self.silver_prices
6
+ doc = Nokogiri::HTML(open("https://www.apmex.com/spotprices/silver-prices"))
7
+ silver_price_array = doc.css(".item-ask").text.split("$")
8
+ todays_silver_prices = self.new
9
+ todays_silver_prices.silver_by_gram = silver_price_array[2]
10
+ todays_silver_prices.silver_by_ounce = silver_price_array[1]
11
+ [todays_silver_prices]
12
+ end
13
+
14
+ def self.gold_prices
15
+ doc = Nokogiri::HTML(open("https://www.apmex.com/spotprices/gold-price"))
16
+ gold_price_array = doc.css(".item-ask").text.split("$")
17
+ todays_gold_prices = self.new
18
+ todays_gold_prices.gold_by_gram = gold_price_array[2]
19
+ todays_gold_prices.gold_by_ounce = gold_price_array[1]
20
+ [todays_gold_prices]
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module GoldPrice
2
+ VERSION = "0.1.0"
3
+ end
data/lib/gold_price.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ require_relative "./gold_price/version"
6
+ require_relative"./gold_price/cli.rb"
7
+ require_relative "./gold_price/price.rb"
data/spec.md ADDED
@@ -0,0 +1,10 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application- app works on command line,
5
+ user interacts by typing in number for choices
6
+ - [x] Pull data from an external source- use ampex.com to pull live current metal
7
+ prices for both gold and silver
8
+ - [x] Implement both list and detail views- gives user lists of metals and list of
9
+ measurements to choose from and then provides them with the information based on
10
+ their selection
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gold-price
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jessica Bensch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-08 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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: pry
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: nokogiri
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
+ description: Allows you to retrieve the current price of gold or silver in grams or
70
+ ounces.
71
+ email:
72
+ - jessica.bensch11@gmail.com
73
+ executables:
74
+ - gold-price
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/gold-price
85
+ - bin/setup
86
+ - gold_price.gemspec
87
+ - lib/gold_price.rb
88
+ - lib/gold_price/cli.rb
89
+ - lib/gold_price/price.rb
90
+ - lib/gold_price/version.rb
91
+ - spec.md
92
+ homepage: https://github.com/lilithlotus/Jessica-Bensch-CLI-app
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - liblib/gold_price
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.5.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Retrieves gold and silver prices.
116
+ test_files: []