kitco 0.0.6 → 0.0.7
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/bin/kitco +13 -10
- data/lib/kitco.rb +8 -14
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16a42c507c8d3c447a191df3a626e1a6bd2d744e
|
4
|
+
data.tar.gz: 651ad1d0884cb56147a1e478f9d054368927b35a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74b90cbf6fe25fd873e506204d8751a40b6dd77211a619a395ad15b44cc1c1743ae6d0e347b2a190d83379ffb2db067444f27b60cf2650665f276d84dadc28f7
|
7
|
+
data.tar.gz: 61ba4a68b78db48464a16d3f5608f7c3536c6fa09d2872ce4a316182a7ce43ec12a51b81227a791c5be5e09233ed5979834f6285ccbebf210b1c3c7a99b7af22
|
data/bin/kitco
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'optparse'
|
3
|
-
|
4
|
-
require File.expand_path('../../lib/kitco', __FILE__)
|
3
|
+
require 'kitco'
|
5
4
|
|
6
5
|
options = { :color => true }
|
7
|
-
|
6
|
+
strings = Kitco::SYMBOLS
|
8
7
|
|
9
8
|
optparse = OptionParser.new do |opts|
|
10
|
-
opts.banner
|
11
|
-
opts.banner << "
|
9
|
+
opts.banner << "usage: kitco [options] symbol\n"
|
10
|
+
opts.banner << "where symbol is #{ strings.map(&:upcase).join(' ') } (case-insensitive)\n\nOptions:"
|
12
11
|
|
13
12
|
opts.on '-h', '--help', 'Display this message' do |arg|
|
14
13
|
options[:help] = arg
|
@@ -24,18 +23,21 @@ optparse.parse!
|
|
24
23
|
at_exit { puts optparse unless $!.nil? }
|
25
24
|
exit(1) if options[:help] || ARGV.size < 1
|
26
25
|
|
27
|
-
|
28
|
-
exit(1) unless
|
26
|
+
input = ARGV.pop.downcase
|
27
|
+
exit(1) unless strings.include? input
|
29
28
|
|
30
|
-
|
29
|
+
method = input.to_sym
|
30
|
+
|
31
|
+
if Kitco.public_methods.include? method
|
31
32
|
begin
|
32
|
-
body = Kitco.send(
|
33
|
+
body = Kitco.send(method).parsed_response
|
33
34
|
|
34
|
-
puts "Results for #{
|
35
|
+
puts "Results for #{input.upcase} (#{body[:time].strftime('%H:%M %m/%d/%y')})"
|
35
36
|
puts "High #{body[:high]}\tLow #{body[:low]}"
|
36
37
|
puts "Bid #{body[:bid]}\tAsk #{body[:ask]}"
|
37
38
|
|
38
39
|
change = "#{body[:change]} (#{(body[:percentage] * 100.0).round(4)}%)"
|
40
|
+
|
39
41
|
if options[:color]
|
40
42
|
puts "Change: \e[#{body[:change] >= 0 ? '32m+' : '31m'}#{change}\e[0m"
|
41
43
|
else
|
@@ -44,5 +46,6 @@ if Kitco.public_methods.include? symbol
|
|
44
46
|
|
45
47
|
rescue Exception => e
|
46
48
|
puts "Failure: #{e}"
|
49
|
+
puts e.backtrace.join("\n")
|
47
50
|
end
|
48
51
|
end
|
data/lib/kitco.rb
CHANGED
@@ -3,6 +3,8 @@ require 'base64'
|
|
3
3
|
require 'time'
|
4
4
|
|
5
5
|
class Kitco
|
6
|
+
SYMBOLS = %w[gold silver palladium platinum rhodium].freeze
|
7
|
+
|
6
8
|
include HTTParty
|
7
9
|
|
8
10
|
base_uri "charts.kitco.com/KitcoCharts"
|
@@ -20,20 +22,12 @@ class Kitco
|
|
20
22
|
results.merge! Hash[ [:bid, :ask, :change, :low, :high].zip(data) ]
|
21
23
|
}
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.palladium
|
32
|
-
request :palladium
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.rhodium
|
36
|
-
request :rhodium
|
25
|
+
SYMBOLS.each do |symbol|
|
26
|
+
class_eval <<-RUBY_EVAL
|
27
|
+
def self.#{symbol}
|
28
|
+
request :#{symbol}
|
29
|
+
end
|
30
|
+
RUBY_EVAL
|
37
31
|
end
|
38
32
|
|
39
33
|
class << self
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mikeycgto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.13'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.13'
|
27
27
|
description: An API for accessing data from Kitco Charts. Also includes a command
|
28
28
|
line utility
|
29
29
|
email: mikeycgto@gmail.com
|
@@ -33,10 +33,11 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- README.md
|
36
|
-
- lib/kitco.rb
|
37
36
|
- bin/kitco
|
37
|
+
- lib/kitco.rb
|
38
38
|
homepage: https://github.com/mikeycgto/kitco
|
39
|
-
licenses:
|
39
|
+
licenses:
|
40
|
+
- MIT
|
40
41
|
metadata: {}
|
41
42
|
post_install_message:
|
42
43
|
rdoc_options: []
|
@@ -44,20 +45,19 @@ require_paths:
|
|
44
45
|
- lib
|
45
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
|
-
- -
|
48
|
+
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: '0'
|
50
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- -
|
53
|
+
- - ">="
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
requirements: []
|
56
57
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.5.2
|
58
59
|
signing_key:
|
59
60
|
specification_version: 4
|
60
61
|
summary: An API for accessing data from Kitco Charts. Also includes a command line
|
61
62
|
utility!
|
62
63
|
test_files: []
|
63
|
-
has_rdoc: false
|