Permalink
Browse files

v0.2.4 bug fix from 0.2.2

  • Loading branch information...
1 parent 8545774 commit 457a4106b02212c6f98d0135c08197eb7bfe1636 @gregwinn committed Mar 4, 2011
View
@@ -2,7 +2,7 @@
require 'rubygems'
require 'rake'
require 'echoe'
-Echoe.new('ystock', '0.2.1') do |p|
+Echoe.new('ystock', '0.2.4') do |p|
p.description = "Get stock information from Yahoo Finance"
p.url = "http://github.com/gregwinn/ystock"
p.author = "Greg Winn"
View
@@ -18,7 +18,7 @@ def ensure_unique(name)
@@service_uri = "http://download.finance.yahoo.com/d/quotes.csv"
# Ystock.find(['stock', 'stock'])
- def find(args)
+ def self.find(args)
output = Array.new
args.each do |stock|
s = send_request(stock.to_s)
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,6 @@
+Manifest
+README.rdoc
+Rakefile
+init.rb
+lib/ystock.rb
+ystock.gemspec
@@ -0,0 +1,34 @@
+= Ystock
+
+Get stock information from Yahoo Finance
+
+== Install
+
+ gem install ystock
+
+Add it to your Gemfile
+
+ gem 'ystock'
+
+
+== Usage
+
+This gem uses Yahoo Finance (yahoo.finance.com) to get stock quotes. Remember the delay is up to 20 mins.
+
+ stock = 'aapl'
+ Ystock.get_stock(stock)
+ # Returns an array
+ ####
+ # :symbol
+ # :price
+ # :change
+ # :volume
+
+Get multiple stock information at once.
+
+ Ystock.find(['aapl', 'goog', 'lcre'])
+
+
+== Build by
+
+Greg Winn
View
@@ -0,0 +1,15 @@
+# Rakefile
+require 'rubygems'
+require 'rake'
+require 'echoe'
+Echoe.new('ystock', '0.2.4') do |p|
+ p.description = "Get stock information from Yahoo Finance"
+ p.url = "http://github.com/gregwinn/ystock"
+ p.author = "Greg Winn"
+ p.email = "greg@winn.ws"
+ p.ignore_pattern = ["tmp/*", "script/*"]
+ p.development_dependencies = []
+end
+
+Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
+
View
@@ -0,0 +1 @@
+require 'ystock'
@@ -0,0 +1,63 @@
+#
+# Yahoo Stock find
+# gem ystock
+#
+# by Greg Winn
+# winn.ws
+# http://github.com/gregwinn/ystock
+#
+require 'cgi'
+require 'net/http'
+module Ystock
+ def ensure_unique(name)
+ begin
+ self[name] = yield
+ end while self.class.exists?(name => self[name])
+ end
+
+ @@service_uri = "http://download.finance.yahoo.com/d/quotes.csv"
+
+ # Ystock.find(['stock', 'stock'])
+ def self.find(args)
+ output = Array.new
+ args.each do |stock|
+ s = send_request(stock.to_s)
+ a = s.chomp.split(",")
+ output << {:symbol => stock.to_s,
+ :price => a[0],
+ :change => a[1],
+ :volume => a[2]}
+
+ end
+ return output
+ end
+
+ def self.get_stock(stock)
+ output = Array.new
+ s = send_request(stock)
+ a = s.chomp.split(",")
+ output = {:symbol => stock,
+ :price => a[0],
+ :change => a[1],
+ :volume => a[2]
+ }
+ return output
+ end
+
+ def self.send_request(*args)
+ completed_path = @@service_uri + construct_args(*args)
+ uri = URI.parse(completed_path)
+ response = Net::HTTP.start(uri.host, uri.port) do |http|
+ http.get completed_path
+ end
+ return response.body
+ end
+
+ def self.construct_args(*args)
+ path = "?f=l1c1v&s=" + args.map{|x| CGI.escape(x)}.join(",")
+ end
+
+end
+class ActiveRecord::Base
+ include Ystock
+end
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{ystock}
+ s.version = "0.2.4"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Greg Winn"]
+ s.date = %q{2011-03-03}
+ s.description = %q{Get stock information from Yahoo Finance}
+ s.email = %q{greg@winn.ws}
+ s.extra_rdoc_files = ["README.rdoc", "lib/ystock.rb"]
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "init.rb", "lib/ystock.rb", "ystock.gemspec"]
+ s.homepage = %q{http://github.com/gregwinn/ystock}
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ystock", "--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{ystock}
+ s.rubygems_version = %q{1.5.0}
+ s.summary = %q{Get stock information from Yahoo Finance}
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
View
Binary file not shown.
View
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{ystock}
+ s.version = "0.2.4"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Greg Winn"]
+ s.date = %q{2011-03-03}
+ s.description = %q{Get stock information from Yahoo Finance}
+ s.email = %q{greg@winn.ws}
+ s.extra_rdoc_files = ["README.rdoc", "lib/ystock.rb"]
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "init.rb", "lib/ystock.rb", "ystock.gemspec"]
+ s.homepage = %q{http://github.com/gregwinn/ystock}
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ystock", "--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{ystock}
+ s.rubygems_version = %q{1.5.0}
+ s.summary = %q{Get stock information from Yahoo Finance}
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end

0 comments on commit 457a410

Please sign in to comment.