quotemedia 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.rdoc +4 -1
- data/lib/quotemedia.rb +3 -4
- data/lib/quotemedia/chart.rb +75 -0
- data/lib/quotemedia/version.rb +2 -2
- data/quotemedia.gemspec +1 -1
- data/spec/lib/chart_spec.rb +18 -18
- data/spec/lib/quotemedia_spec.rb +4 -5
- metadata +34 -40
- data/lib/chart.rb +0 -75
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -2,9 +2,12 @@
|
|
2
2
|
|
3
3
|
QuoteMedia is a thin wrapper for the api of http://www.quotemedia.com.
|
4
4
|
|
5
|
+
http://stillmaintained.com/cowmanifestation/quotemedia.png
|
6
|
+
http://travis-ci.org/cowmanifestation/quotemedia.png ({More info}[http://travis-ci.org/cowmanifestation/quotemedia])
|
7
|
+
|
5
8
|
== Charts
|
6
9
|
|
7
|
-
Custom charts can be obtained from quotemedia.com from a url containing all of the desired parameters. Use
|
10
|
+
Custom charts can be obtained from quotemedia.com from a url containing all of the desired parameters. Use <tt>QuoteMedia.create_chart_url(params)</tt> to create a custom url. The only required parameter is +:symbol+ (the symbol for a stock or stock exchange). The others will be filled in with the default values unless specified. Refer to +lib/chart.rb+ for a list of all parameters.
|
8
11
|
|
9
12
|
== Contributing
|
10
13
|
|
data/lib/quotemedia.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module QuoteMedia
|
1
|
+
module Quotemedia
|
2
|
+
autoload :VERSION, "quotemedia/version"
|
3
|
+
autoload :Chart, "quotemedia/chart"
|
5
4
|
def self.create_chart_url(params)
|
6
5
|
chart = Chart.new(params)
|
7
6
|
chart.url
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Quotemedia
|
2
|
+
class Chart
|
3
|
+
# QuoteMedia chart parameters reference:
|
4
|
+
# http://www.quotemedia.com/content_solutions/module_resources.php
|
5
|
+
# QuoteMedia Chart Builder: http://www.quotemedia.com/demoarea/chartbuilder-cookiebased.php
|
6
|
+
|
7
|
+
CHART_DEFAULTS = {
|
8
|
+
:webmasterId => "500",
|
9
|
+
|
10
|
+
# There is no default symbol - each chart should have its own.
|
11
|
+
# symbol: nil, # i.e. ^DOW
|
12
|
+
|
13
|
+
# This is the chart title; you can specify whatever you want, or leave it empty.
|
14
|
+
# QuoteMedia makes suggestions based on the symbol which can be seen when using the QuoteMedia Chart Builder - http://www.quotemedia.com/demoarea/chartbuilder-cookiebased.php
|
15
|
+
# Or it can be left empty, in which case the symbol will be used as the title, unless the title (chton) is off.
|
16
|
+
#chsym: nil,
|
17
|
+
# date range - for example, 1d, 5d, 1y etc.
|
18
|
+
:chscale => '5d',
|
19
|
+
# previous close is on/off
|
20
|
+
:chpcon => 'on',
|
21
|
+
# Chart type - Options: bar, candle, compare, dot, hlc, line, mountain, ohlc, LineChart, BarChart, CandleStickChart, AreaChart, FinancialLine, FinancialBar, FinancialCandleStick
|
22
|
+
:chtype => 'AreaChart',
|
23
|
+
# The frame around the image canvas on/off
|
24
|
+
:chfrmon => 'off',
|
25
|
+
# frame color
|
26
|
+
:chfrm => '',
|
27
|
+
# border around plot area on/off
|
28
|
+
:chbdron => 'off',
|
29
|
+
# border color around plot area
|
30
|
+
:chbdr => '',
|
31
|
+
# background color
|
32
|
+
:chbg => 'ffffff00', # transparent
|
33
|
+
# background color of chart plot area
|
34
|
+
:chbgch => 'ffffff00', # transparent
|
35
|
+
# line color
|
36
|
+
:chln => '465665',
|
37
|
+
# primary fill color for area charts, and candlestick (and volume bars)
|
38
|
+
:chfill => '1B57AA',
|
39
|
+
# gradient fill color turns on gradient-fill area charts
|
40
|
+
:chfill2 => 'c0c9d2',
|
41
|
+
# plot area grid on/of
|
42
|
+
:chgrdon => 'on',
|
43
|
+
# grid color
|
44
|
+
:chgrd => 'cccccc',
|
45
|
+
# chart title is visible on/off
|
46
|
+
:chton => 'on',
|
47
|
+
# chart title color
|
48
|
+
:chtcol => '000000',
|
49
|
+
# xy label and tick color
|
50
|
+
:chxyc => '111111',
|
51
|
+
# previous close line color
|
52
|
+
:chpccol => 'ee0000',
|
53
|
+
# margin padding
|
54
|
+
:chmrg => '2',
|
55
|
+
# chart height
|
56
|
+
:chhig => '250',
|
57
|
+
# chart width
|
58
|
+
:chwid => '380',
|
59
|
+
}
|
60
|
+
|
61
|
+
def initialize(params)
|
62
|
+
unless params[:symbol]
|
63
|
+
raise ArgumentError, "No symbol specified."
|
64
|
+
end
|
65
|
+
|
66
|
+
@chart_params = CHART_DEFAULTS.merge(params)
|
67
|
+
end
|
68
|
+
|
69
|
+
def url
|
70
|
+
url = 'http://app.quotemedia.com/quotetools/getChart.go?'
|
71
|
+
|
72
|
+
url << @chart_params.to_a.map {|a| a.join("=")}.join("&")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/quotemedia/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.0.
|
1
|
+
module QuoteMedia
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
data/quotemedia.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "quotemedia/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "quotemedia"
|
7
|
-
s.version =
|
7
|
+
s.version = QuoteMedia::VERSION
|
8
8
|
s.authors = ["Chenoa Siegenthaler"]
|
9
9
|
s.email = ["cowmanifestation@gmail.com"]
|
10
10
|
s.homepage = "https://github.com/cowmanifestation/quotemedia"
|
data/spec/lib/chart_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chart do
|
3
|
+
describe Quotemedia::Chart do
|
4
4
|
describe "#new" do
|
5
5
|
it "should raise an error when no symbol is given" do
|
6
|
-
lambda { Chart.new }.should raise_error
|
6
|
+
lambda { Quotemedia::Chart.new }.should raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#url' do
|
11
11
|
it "should return a url with all the default parameters if given no others" do
|
12
|
-
url = Chart.new(symbol
|
12
|
+
url = Quotemedia::Chart.new(:symbol => 'abc').url
|
13
13
|
|
14
14
|
some_defaults = {
|
15
|
-
webmasterId
|
16
|
-
chscale
|
17
|
-
chtype
|
18
|
-
chfrm
|
19
|
-
chbdron
|
20
|
-
chhig
|
15
|
+
:webmasterId => "500",
|
16
|
+
:chscale => '5d',
|
17
|
+
:chtype => 'AreaChart',
|
18
|
+
:chfrm => 'ffffff',
|
19
|
+
:chbdron => 'on',
|
20
|
+
:chhig => '250',
|
21
21
|
}
|
22
22
|
|
23
23
|
some_defaults.each do |k,v|
|
@@ -26,17 +26,17 @@ describe Chart do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should give a url containing all the given parameters" do
|
29
|
-
custom_params = { symbol
|
30
|
-
webmasterId
|
31
|
-
chscale
|
32
|
-
chpcon
|
33
|
-
chtype
|
34
|
-
chmrg
|
35
|
-
chhig
|
36
|
-
chwid
|
29
|
+
custom_params = { :symbol => 'abc',
|
30
|
+
:webmasterId => '321',
|
31
|
+
:chscale => '2d',
|
32
|
+
:chpcon => 'off',
|
33
|
+
:chtype => 'candle',
|
34
|
+
:chmrg => '7',
|
35
|
+
:chhig => '100',
|
36
|
+
:chwid => '150'
|
37
37
|
}
|
38
38
|
|
39
|
-
url = Chart.new(custom_params).url
|
39
|
+
url = Quotemedia::Chart.new(custom_params).url
|
40
40
|
custom_params.each do |k,v|
|
41
41
|
url.should match(/#{k}=#{v}/)
|
42
42
|
end
|
data/spec/lib/quotemedia_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Quotemedia do
|
4
4
|
before(:all) do
|
5
|
-
@url =
|
5
|
+
@url = Quotemedia.create_chart_url(:symbol => 'abc')
|
6
6
|
end
|
7
7
|
|
8
|
-
# TODO These tests are redundant.
|
9
8
|
describe '#create_chart_url' do
|
10
9
|
it "should give a url string" do
|
11
10
|
@url.class.should == String
|
@@ -14,7 +13,7 @@ describe QuoteMedia do
|
|
14
13
|
|
15
14
|
it "should raise an error if not given a symbol" do
|
16
15
|
lambda do
|
17
|
-
|
16
|
+
Quotemedia.create_chart_url
|
18
17
|
end.should raise_error
|
19
18
|
end
|
20
19
|
|
@@ -24,7 +23,7 @@ describe QuoteMedia do
|
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should replace default parameters with given parameters" do
|
27
|
-
|
26
|
+
Quotemedia.create_chart_url(:symbol => 'abc', :webmasterId => '321', :chgrdon => 'off').should match(/webmasterId=321.+chgrdon=off/)
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
metadata
CHANGED
@@ -1,60 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: quotemedia
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Chenoa Siegenthaler
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-11-28 00:00:00 -05:00
|
12
|
+
date: 2011-12-15 00:00:00.000000000 -05:00
|
14
13
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: rake
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2161357520 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
|
-
requirements:
|
19
|
+
requirements:
|
22
20
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
21
|
+
- !ruby/object:Gem::Version
|
24
22
|
version: 0.9.2.2
|
25
23
|
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
24
|
prerelease: false
|
30
|
-
|
25
|
+
version_requirements: *2161357520
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &2161357020 !ruby/object:Gem::Requirement
|
31
29
|
none: false
|
32
|
-
requirements:
|
30
|
+
requirements:
|
33
31
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
32
|
+
- !ruby/object:Gem::Version
|
35
33
|
version: 2.5.0
|
36
34
|
type: :development
|
37
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2161357020
|
38
37
|
description: A thin wrapper to Quotemedia apis
|
39
|
-
email:
|
38
|
+
email:
|
40
39
|
- cowmanifestation@gmail.com
|
41
40
|
executables: []
|
42
|
-
|
43
41
|
extensions: []
|
44
|
-
|
45
42
|
extra_rdoc_files: []
|
46
|
-
|
47
|
-
files:
|
43
|
+
files:
|
48
44
|
- .gitignore
|
49
45
|
- .rspec
|
50
46
|
- .rvmrc
|
47
|
+
- .travis.yml
|
51
48
|
- Gemfile
|
52
49
|
- LICENSE
|
53
50
|
- README.rdoc
|
54
51
|
- Rakefile
|
55
52
|
- configure
|
56
|
-
- lib/chart.rb
|
57
53
|
- lib/quotemedia.rb
|
54
|
+
- lib/quotemedia/chart.rb
|
58
55
|
- lib/quotemedia/version.rb
|
59
56
|
- quotemedia.gemspec
|
60
57
|
- spec/lib/chart_spec.rb
|
@@ -63,32 +60,29 @@ files:
|
|
63
60
|
has_rdoc: true
|
64
61
|
homepage: https://github.com/cowmanifestation/quotemedia
|
65
62
|
licenses: []
|
66
|
-
|
67
63
|
post_install_message:
|
68
64
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
65
|
+
require_paths:
|
71
66
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
68
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
74
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version:
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
84
79
|
requirements: []
|
85
|
-
|
86
80
|
rubyforge_project: quotemedia
|
87
81
|
rubygems_version: 1.6.2
|
88
82
|
signing_key:
|
89
83
|
specification_version: 3
|
90
84
|
summary: Quotemedia api wrapper
|
91
|
-
test_files:
|
85
|
+
test_files:
|
92
86
|
- spec/lib/chart_spec.rb
|
93
87
|
- spec/lib/quotemedia_spec.rb
|
94
88
|
- spec/spec_helper.rb
|
data/lib/chart.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
class Chart
|
2
|
-
# QuoteMedia chart parameters reference:
|
3
|
-
# http://www.quotemedia.com/content_solutions/module_resources.php
|
4
|
-
# QuoteMedia Chart Builder: http://www.quotemedia.com/demoarea/chartbuilder-cookiebased.php
|
5
|
-
|
6
|
-
# TODO put default styling here that Chris selects
|
7
|
-
CHART_DEFAULTS = {
|
8
|
-
webmasterId: "500",
|
9
|
-
|
10
|
-
# We don't want a default symbol - each chart should have its own.
|
11
|
-
# symbol: nil, # i.e. ^DOW
|
12
|
-
|
13
|
-
# This is the chart title; you can specify whatever you want, or leave it empty.
|
14
|
-
# QuoteMedia makes suggestions based on the symbol which can be seen when using the QuoteMedia Chart Builder - http://www.quotemedia.com/demoarea/chartbuilder-cookiebased.php
|
15
|
-
# Or it can be left empty, in which case the symbol will be used as the title, unless the title (chton) is off.
|
16
|
-
#chsym: nil,
|
17
|
-
# date range - for example, 1d, 5d, 1y etc.
|
18
|
-
chscale: '5d',
|
19
|
-
# previous close is on/off
|
20
|
-
chpcon: 'on',
|
21
|
-
# Chart type - Options: bar, candle, compare, dot, hlc, line, mountain, ohlc, LineChart, BarChart, CandleStickChart, AreaChart, FinancialLine, FinancialBar, FinancialCandleStick
|
22
|
-
chtype: 'AreaChart',
|
23
|
-
# The frame around the image canvas on/off
|
24
|
-
chfrmon: 'on',
|
25
|
-
# frame color
|
26
|
-
chfrm: 'ffffff',
|
27
|
-
# border around plot area on/off
|
28
|
-
chbdron: 'on',
|
29
|
-
# border color around plot area
|
30
|
-
chbdr: 'cccccc',
|
31
|
-
# background color
|
32
|
-
chbg: 'ffffff',
|
33
|
-
# background color of chart plot area
|
34
|
-
chbgch: 'ffffff',
|
35
|
-
# line color
|
36
|
-
chln: '465665',
|
37
|
-
# primary fill color for area charts, and candlestick (and volume bars)
|
38
|
-
chfill: '1B57AA',
|
39
|
-
# gradient fill color turns on gradient-fill area charts
|
40
|
-
chfill2: 'c0c9d2',
|
41
|
-
# plot area grid on/of
|
42
|
-
chgrdon: 'on',
|
43
|
-
# grid color
|
44
|
-
chgrd: 'cccccc',
|
45
|
-
# chart title is visible on/off
|
46
|
-
chton: 'on',
|
47
|
-
# chart title color
|
48
|
-
chtcol: '000000',
|
49
|
-
# xy label and tick color
|
50
|
-
chxyc: '111111',
|
51
|
-
# previous close line color
|
52
|
-
chpccol: 'ee0000',
|
53
|
-
# margin padding
|
54
|
-
chmrg: '2',
|
55
|
-
# chart height
|
56
|
-
chhig: '250',
|
57
|
-
# chart width
|
58
|
-
chwid: '380',
|
59
|
-
}
|
60
|
-
|
61
|
-
def initialize(params)
|
62
|
-
# TODO: Raise error for parameters that don't exist, i.e. misspelled things
|
63
|
-
unless params[:symbol]
|
64
|
-
raise ArgumentError, "No symbol specified."
|
65
|
-
end
|
66
|
-
|
67
|
-
@chart_params = CHART_DEFAULTS.merge(params)
|
68
|
-
end
|
69
|
-
|
70
|
-
def url
|
71
|
-
url = 'http://app.quotemedia.com/quotetools/getChart.go?'
|
72
|
-
|
73
|
-
url << @chart_params.to_a.map {|a| a.join("=")}.join("&")
|
74
|
-
end
|
75
|
-
end
|