quotemedia 0.0.1.a

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --profile
3
+ -fs
data/.rvmrc ADDED
@@ -0,0 +1,6 @@
1
+ # $ heroku console --app hedgeye-reader
2
+ # >> RUBY_VERSION
3
+ # => "1.9.2"
4
+ # >> RUBY_PATCHLEVEL
5
+ # => 180
6
+ rvm use 1.9.2-p180@quotemedia --create
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in quotemedia.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Chenoa Siegenthaler
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.
@@ -0,0 +1,21 @@
1
+ = QuoteMedia
2
+
3
+ QuoteMedia is a thin wrapper for the api of http://www.quotemedia.com.
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
+
8
+ == Charts
9
+
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.
11
+
12
+ == Contributing
13
+
14
+ Setting up the build environment is automated. Please run these commands to make sure you're able to run the code.
15
+
16
+ ./configure
17
+ rake
18
+
19
+ == License
20
+
21
+ The MIT License. See LICENSE for a copy.
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :default => :spec
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -o errexit
3
+ # Assumes rvm:
4
+ gem install bundler --version "~> 1.0" --no-rdoc --no-ri
5
+ bundle install
@@ -0,0 +1,75 @@
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
@@ -0,0 +1,9 @@
1
+ autoload :VERSION, "quotemedia/version"
2
+ autoload :Chart, "chart"
3
+
4
+ module QuoteMedia
5
+ def self.create_chart_url(params)
6
+ chart = Chart.new(params)
7
+ chart.url
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module QuoteMedia
2
+ VERSION = "0.0.1.a"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "quotemedia/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "quotemedia"
7
+ s.version = QuoteMedia::VERSION
8
+ s.authors = ["Chenoa Siegenthaler"]
9
+ s.email = ["cowmanifestation@gmail.com"]
10
+ s.homepage = "https://github.com/cowmanifestation/quotemedia"
11
+ s.summary = %q{Quotemedia api wrapper}
12
+ s.description = %q{A thin wrapper to Quotemedia apis}
13
+
14
+ s.rubyforge_project = "quotemedia"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency('rake', '~> 0.9.2.2')
22
+ s.add_development_dependency('rspec', '~> 2.5.0')
23
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chart do
4
+ describe "#new" do
5
+ it "should raise an error when no symbol is given" do
6
+ lambda { Chart.new }.should raise_error
7
+ end
8
+ end
9
+
10
+ describe '#url' do
11
+ it "should return a url with all the default parameters if given no others" do
12
+ url = Chart.new(:symbol => 'abc').url
13
+
14
+ some_defaults = {
15
+ :webmasterId => "500",
16
+ :chscale => '5d',
17
+ :chtype => 'AreaChart',
18
+ :chfrm => 'ffffff',
19
+ :chbdron => 'on',
20
+ :chhig => '250',
21
+ }
22
+
23
+ some_defaults.each do |k,v|
24
+ url.should match(/#{k}=#{v}/)
25
+ end
26
+ end
27
+
28
+ it "should give a url containing all the given parameters" do
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
+ }
38
+
39
+ url = Chart.new(custom_params).url
40
+ custom_params.each do |k,v|
41
+ url.should match(/#{k}=#{v}/)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe QuoteMedia do
4
+ before(:all) do
5
+ @url = QuoteMedia.create_chart_url(:symbol => 'abc')
6
+ end
7
+
8
+ describe '#create_chart_url' do
9
+ it "should give a url string" do
10
+ @url.class.should == String
11
+ @url.should match(/http:\/\/app\.quotemedia\.com\//)
12
+ end
13
+
14
+ it "should raise an error if not given a symbol" do
15
+ lambda do
16
+ QuoteMedia.create_chart_url
17
+ end.should raise_error
18
+ end
19
+
20
+ it "should return a url with all the default parameters if given no others" do
21
+ @url.should match(/webmasterId=500/)
22
+ # webmasterId=500 chscale=5d&chtype=AreaChart&chfrmon=on&chfrm=ffffff&chbdron=on&chbdr=cccccc&chbg=ffffff&chbgch=ffffff&chln=465665&chfill=1B57AA&chfill2=c0c9d2&chgrdon=on&chgrd=cccccc&chton=on&chtcol=000000&chxyc=111111&chpcon=on&chpccol=ee0000&chmrg=2&chhig=250&chwid=380
23
+ end
24
+
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/)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+
4
+ require 'quotemedia'
5
+
6
+ Rspec.configure do |c|
7
+ c.mock_with :rspec
8
+ end
9
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quotemedia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.a
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Chenoa Siegenthaler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-30 00:00:00.000000000 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: &2152992140 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.2.2
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *2152992140
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &2152991640 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.5.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *2152991640
37
+ description: A thin wrapper to Quotemedia apis
38
+ email:
39
+ - cowmanifestation@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - .rspec
46
+ - .rvmrc
47
+ - .travis.yml
48
+ - Gemfile
49
+ - LICENSE
50
+ - README.rdoc
51
+ - Rakefile
52
+ - configure
53
+ - lib/chart.rb
54
+ - lib/quotemedia.rb
55
+ - lib/quotemedia/version.rb
56
+ - quotemedia.gemspec
57
+ - spec/lib/chart_spec.rb
58
+ - spec/lib/quotemedia_spec.rb
59
+ - spec/spec_helper.rb
60
+ has_rdoc: true
61
+ homepage: https://github.com/cowmanifestation/quotemedia
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>'
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.1
79
+ requirements: []
80
+ rubyforge_project: quotemedia
81
+ rubygems_version: 1.6.2
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Quotemedia api wrapper
85
+ test_files:
86
+ - spec/lib/chart_spec.rb
87
+ - spec/lib/quotemedia_spec.rb
88
+ - spec/spec_helper.rb