quotemedia 0.0.1.b → 0.0.1.c

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,6 @@
1
- autoload :VERSION, "quotemedia/version"
2
- autoload :Chart, "chart"
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,77 @@
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
+ # Default styling here that Chris (designer) selected
8
+ CHART_DEFAULTS = {
9
+ webmasterId: "500",
10
+
11
+ # We don't want a default symbol - each chart should have its own.
12
+ # symbol: nil, # i.e. ^DOW
13
+
14
+ # This is the chart title; you can specify whatever you want, or leave it empty.
15
+ # 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
16
+ # Or it can be left empty, in which case the symbol will be used as the title, unless the title (chton) is off.
17
+ #chsym: nil,
18
+ # date range - for example, 1d, 5d, 1y etc.
19
+ chscale: '5d',
20
+ # previous close is on/off
21
+ chpcon: 'on',
22
+ # Chart type - Options: bar, candle, compare, dot, hlc, line, mountain, ohlc, LineChart, BarChart, CandleStickChart, AreaChart, FinancialLine, FinancialBar, FinancialCandleStick
23
+ chtype: 'AreaChart',
24
+ # The frame around the image canvas on/off
25
+ chfrmon: 'on',
26
+ # frame color
27
+ chfrm: 'ffffff',
28
+ # border around plot area on/off
29
+ chbdron: 'on',
30
+ # border color around plot area
31
+ chbdr: 'cccccc',
32
+ # background color
33
+ chbg: '', # transparent
34
+ # background color of chart plot area
35
+ chbgch: '', # transparent
36
+ # line color
37
+ chln: '465665',
38
+ # primary fill color for area charts, and candlestick (and volume bars)
39
+ chfill: '1B57AA',
40
+ # gradient fill color turns on gradient-fill area charts
41
+ chfill2: 'c0c9d2',
42
+ # plot area grid on/of
43
+ chgrdon: 'on',
44
+ # grid color
45
+ chgrd: 'cccccc',
46
+ # chart title is visible on/off
47
+ chton: 'on',
48
+ # chart title color
49
+ chtcol: '000000',
50
+ # xy label and tick color
51
+ chxyc: '111111',
52
+ # previous close line color
53
+ chpccol: 'ee0000',
54
+ # margin padding
55
+ chmrg: '2',
56
+ # chart height
57
+ chhig: '250',
58
+ # chart width
59
+ chwid: '380',
60
+ }
61
+
62
+ def initialize(params)
63
+ # TODO: Raise error for parameters that don't exist, i.e. misspelled things
64
+ unless params[:symbol]
65
+ raise ArgumentError, "No symbol specified."
66
+ end
67
+
68
+ @chart_params = CHART_DEFAULTS.merge(params)
69
+ end
70
+
71
+ def url
72
+ url = 'http://app.quotemedia.com/quotetools/getChart.go?'
73
+
74
+ url << @chart_params.to_a.map {|a| a.join("=")}.join("&")
75
+ end
76
+ end
77
+ end
@@ -1,3 +1,3 @@
1
1
  module QuoteMedia
2
- VERSION = "0.0.1.b"
2
+ VERSION = "0.0.1.c"
3
3
  end
@@ -1,15 +1,15 @@
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 => 'abc').url
12
+ url = Quotemedia::Chart.new(:symbol => 'abc').url
13
13
 
14
14
  some_defaults = {
15
15
  :webmasterId => "500",
@@ -36,7 +36,7 @@ describe Chart do
36
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
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe QuoteMedia do
3
+ describe Quotemedia do
4
4
  before(:all) do
5
- @url = QuoteMedia.create_chart_url(:symbol => 'abc')
5
+ @url = Quotemedia.create_chart_url(:symbol => 'abc')
6
6
  end
7
7
 
8
8
  describe '#create_chart_url' do
@@ -13,7 +13,7 @@ describe QuoteMedia do
13
13
 
14
14
  it "should raise an error if not given a symbol" do
15
15
  lambda do
16
- QuoteMedia.create_chart_url
16
+ Quotemedia.create_chart_url
17
17
  end.should raise_error
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ describe QuoteMedia do
23
23
  end
24
24
 
25
25
  it "should replace default parameters with given parameters" do
26
- QuoteMedia.create_chart_url(:symbol => 'abc', :webmasterId => '321', :chgrdon => 'off').should match(/webmasterId=321.+chgrdon=off/)
26
+ Quotemedia.create_chart_url(:symbol => 'abc', :webmasterId => '321', :chgrdon => 'off').should match(/webmasterId=321.+chgrdon=off/)
27
27
  end
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quotemedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.b
4
+ version: 0.0.1.c
5
5
  prerelease: 6
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: rake
17
- requirement: &2157057080 !ruby/object:Gem::Requirement
17
+ requirement: &2152491380 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.9.2.2
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2157057080
25
+ version_requirements: *2152491380
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2157056580 !ruby/object:Gem::Requirement
28
+ requirement: &2152490880 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 2.5.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2157056580
36
+ version_requirements: *2152490880
37
37
  description: A thin wrapper to Quotemedia apis
38
38
  email:
39
39
  - cowmanifestation@gmail.com
@@ -50,8 +50,8 @@ files:
50
50
  - README.rdoc
51
51
  - Rakefile
52
52
  - configure
53
- - lib/chart.rb
54
53
  - lib/quotemedia.rb
54
+ - lib/quotemedia/chart.rb
55
55
  - lib/quotemedia/version.rb
56
56
  - quotemedia.gemspec
57
57
  - spec/lib/chart_spec.rb
@@ -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
- # Default styling here that Chris (designer) selected
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: '', # transparent
33
- # background color of chart plot area
34
- chbgch: '', # 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
- # 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