kitco 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/kitco +2 -3
- data/lib/kitco.rb +8 -6
- metadata +3 -3
data/bin/kitco
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'kitco'
|
3
2
|
require 'optparse'
|
4
3
|
|
5
4
|
options = { :color => true }
|
@@ -34,9 +33,9 @@ if Kitco.public_methods.include? symbol
|
|
34
33
|
puts "High #{body[:high]}\tLow #{body[:low]}"
|
35
34
|
puts "Bid #{body[:bid]}\tAsk #{body[:ask]}"
|
36
35
|
|
37
|
-
change = "#{body[:change]
|
36
|
+
change = "#{body[:change]} (#{(body[:percentage] * 100.0).round(4)}%)"
|
38
37
|
if options[:color]
|
39
|
-
puts "Change: \e[#{change}\e[0m"
|
38
|
+
puts "Change: \e[#{body[:change] >= 0 ? '32m+' : '31m'}#{change}\e[0m"
|
40
39
|
else
|
41
40
|
puts "Change #{change}"
|
42
41
|
end
|
data/lib/kitco.rb
CHANGED
@@ -6,7 +6,7 @@ class Kitco
|
|
6
6
|
include HTTParty
|
7
7
|
|
8
8
|
base_uri "charts.kitco.com/KitcoCharts"
|
9
|
-
parser
|
9
|
+
parser lambda { |body, format|
|
10
10
|
# they don't send an XML content-type if its a bad request
|
11
11
|
return Crack::XML.parse(body) if body.include?('xml')
|
12
12
|
|
@@ -18,7 +18,7 @@ class Kitco
|
|
18
18
|
|
19
19
|
data.collect! { |n| n.to_f }
|
20
20
|
results.merge! Hash[ [:bid, :ask, :change, :low, :high].zip(data) ]
|
21
|
-
}
|
21
|
+
}
|
22
22
|
|
23
23
|
def self.gold
|
24
24
|
request :gold
|
@@ -36,9 +36,11 @@ class Kitco
|
|
36
36
|
request :rhodium
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
class << self
|
40
|
+
def request symbol
|
41
|
+
get '/RequestHandler', :query => {:requestName => 'getSymbolSnapshot', :Symbol => symbol.upcase }
|
42
|
+
end
|
43
|
+
|
44
|
+
protected :request
|
43
45
|
end
|
44
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
17
|
-
requirement: &
|
17
|
+
requirement: &22942580 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: 0.7.8
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *22942580
|
26
26
|
description: An API for accessing data from Kitco Charts. Also includes a command
|
27
27
|
line utility
|
28
28
|
email: mikeycgto@gmail.com
|