gold-price 0.1.14 → 0.1.15
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 +4 -4
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gold-price-0.1.0.gem +0 -0
- data/gold_price.gemspec +32 -0
- data/lib/gold_price.rb +7 -0
- data/lib/gold_price/cli.rb +71 -0
- data/lib/gold_price/price.rb +22 -0
- data/lib/gold_price/version.rb +3 -0
- data/spec.md +10 -0
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d834445dcd04a044c4aa2e806952b0660033fc47
|
|
4
|
+
data.tar.gz: e279c5985059406431f8c3242184d00900ccc0f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acdde59b8f236bedf750933319a45d87541731ad96f88fa90dda414d1013cb31331b7018a32303a5340272b1768630e505cac3ab57256c9f85c5a53df40b0da9
|
|
7
|
+
data.tar.gz: b288e78de9b99726d178fab4c8106aa512872280ac19ca88da049ec66a2999b1b25c3c09da012f6cafc91d9d049dce28205b411fccd5ce30d0a52ec74de42f92
|
data/.gitignore
ADDED
data/Gemfile
ADDED
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,45 @@
|
|
|
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
|
+
Download this file, run in terminal using ./bin/gold-price
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
---No functionality---
|
|
15
|
+
Add this line to your application's Gemfile:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'gold_price'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
$ bundle
|
|
24
|
+
|
|
25
|
+
Or install it yourself as:
|
|
26
|
+
|
|
27
|
+
$ gem install gold_price
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Select gold or silver in either ounces or grams to receive the most up to date ask price.
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
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).
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lilithlotus/Jessica-Bensch-CLI-app.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
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/setup
ADDED
|
Binary file
|
data/gold_price.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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 "./lib/gold_price/version.rb"
|
|
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"]
|
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
+
spec.add_development_dependency "pry"
|
|
30
|
+
spec.add_dependency "nokogiri"
|
|
31
|
+
|
|
32
|
+
end
|
data/lib/gold_price.rb
ADDED
|
@@ -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
|
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
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gold-price
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jessica Bensch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-11-
|
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -75,7 +75,21 @@ executables:
|
|
|
75
75
|
extensions: []
|
|
76
76
|
extra_rdoc_files: []
|
|
77
77
|
files:
|
|
78
|
+
- ".gitignore"
|
|
79
|
+
- Gemfile
|
|
80
|
+
- LICENSE.txt
|
|
81
|
+
- README.md
|
|
82
|
+
- Rakefile
|
|
83
|
+
- bin/console
|
|
78
84
|
- bin/gold-price
|
|
85
|
+
- bin/setup
|
|
86
|
+
- gold-price-0.1.0.gem
|
|
87
|
+
- gold_price.gemspec
|
|
88
|
+
- lib/gold_price.rb
|
|
89
|
+
- lib/gold_price/cli.rb
|
|
90
|
+
- lib/gold_price/price.rb
|
|
91
|
+
- lib/gold_price/version.rb
|
|
92
|
+
- spec.md
|
|
79
93
|
homepage: https://github.com/lilithlotus/Jessica-Bensch-CLI-app
|
|
80
94
|
licenses:
|
|
81
95
|
- MIT
|
|
@@ -83,7 +97,7 @@ metadata: {}
|
|
|
83
97
|
post_install_message:
|
|
84
98
|
rdoc_options: []
|
|
85
99
|
require_paths:
|
|
86
|
-
-
|
|
100
|
+
- lib
|
|
87
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
102
|
requirements:
|
|
89
103
|
- - ">="
|