ystock 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -1,14 +1,16 @@
1
1
  # Ystock
2
2
  This gem provides you with the latest market data avalable, pulling from both Google and Yahoo Finance.
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/ystock.png)](http://badge.fury.io/rb/ystock) [![Build Status](https://travis-ci.org/gregwinn/ystock.png?branch=master)](https://travis-ci.org/gregwinn/ystock) [![Code Climate](https://codeclimate.com/github/gregwinn/ystock.png)](https://codeclimate.com/github/gregwinn/ystock)
5
+
4
6
  ## Install
5
7
  Add the following to your Gemfile
6
8
  ```ruby
7
- gem "ystock", "~> 0.4.0"
8
- ```
9
+ gem "ystock", "~> 0.4.1"
9
10
 
10
- ### Dependancies
11
- Please note 'httparty' is required to run this gem.
11
+ # Or simply install it
12
+ gem install ystock -v=0.4.1
13
+ ```
12
14
 
13
15
  ## Bundle
14
16
  ```
@@ -19,16 +21,15 @@ bundle install
19
21
 
20
22
  # Google Usage
21
23
 
22
- This uses the Google Finance API to request the latest market information (up to 15 min delay). The Google Fincance API tends to return better and more usful information on the stock requested.
24
+ This uses the Google Finance API to request the latest market information (up to 15 min delay). The Google Finance API tends to return better and more useful information on the stock requested vs Yahoo.
23
25
 
24
- ### Single Stock
26
+ ## Quote Usage
25
27
  ```ruby
26
- Ystock::Google.get_quote("appl")
27
- ```
28
+ # Single Stock lookup {String}
29
+ Ystock::Google.quote("appl")
28
30
 
29
- ### Multiple Stocks
30
- ```ruby
31
- Ystock::Google.find(["aapl", "f", "ggog"])
31
+ # Multiple Stock lookup {Array}
32
+ Ystock::Google.quote(["aapl", "f", "goog"])
32
33
  ```
33
34
 
34
35
  #### Available data
@@ -83,7 +84,7 @@ Ystock::Yahoo.get_quote("appl")
83
84
 
84
85
  ### Multiple Stocks
85
86
  ```ruby
86
- Ystock::Yahoo.find(["aapl", "f", "ggog"])
87
+ Ystock::Yahoo.find(["aapl", "f", "goog"])
87
88
  ```
88
89
 
89
90
  #### Available data
@@ -94,3 +95,15 @@ volume
94
95
  symbol
95
96
  ```
96
97
 
98
+ ----
99
+
100
+ ### Tested with
101
+ This gem was tested with:
102
+
103
+ Ruby: 1.9.2
104
+
105
+ Ruby: 1.9.3
106
+
107
+ Ruby: 2.0.0
108
+
109
+
data/lib/ystock/google.rb CHANGED
@@ -1,10 +1,19 @@
1
1
  module Ystock
2
2
  class Google
3
3
  @@google_service = "http://www.google.com/ig/api"
4
- def self.find(args)
4
+
5
+ def self.quote(args)
6
+ if args.is_a? Array
7
+ many_stocks(args)
8
+ else
9
+ single_stock(args)
10
+ end
11
+ end
12
+
13
+ def self.many_stocks(stocks)
5
14
  stock_string = ""
6
- args.each do |stock|
7
- if args.first == stock
15
+ stocks.each do |stock|
16
+ if stocks.first == stock
8
17
  stock_string += "?stock=" + stock
9
18
  else
10
19
  stock_string += "&stock=" + stock
@@ -12,10 +21,10 @@ module Ystock
12
21
  end
13
22
  format(send_request(stock_string), true)
14
23
  end
15
-
16
- def self.get_quote(arg)
17
- arg = "?stock=" + arg
18
- format(send_request(arg), false)
24
+
25
+ def self.single_stock(stock)
26
+ stock = "?stock=" + stock
27
+ format(send_request(stock), false)
19
28
  end
20
29
 
21
30
  def self.format(results, is_many)
@@ -24,7 +33,7 @@ module Ystock
24
33
  results.each do |item|
25
34
 
26
35
  if is_many
27
-
36
+ # => Multiple Stocks
28
37
  item[1]["finance"].each do |stock|
29
38
  stock_data = Hash.new
30
39
  stock.each do |key, val|
@@ -34,11 +43,12 @@ module Ystock
34
43
  end
35
44
 
36
45
  else
46
+ # => Single Stock
37
47
  stock_data = Hash.new
38
48
  item[1]["finance"].each do |key, val|
39
49
  stock_data[:"#{key}"] = (!val["data"].nil?) ? val["data"] : val
40
50
  end
41
- output = [stock_data]
51
+ output = stock_data
42
52
  end
43
53
  end
44
54
 
data/lib/ystock/yahoo.rb CHANGED
@@ -58,8 +58,5 @@ module Ystock
58
58
  return Gem::VERSION
59
59
  end
60
60
 
61
- def self.test
62
- return "Test is working 2"
63
- end
64
61
  end
65
62
  end
data/ystock.gemspec CHANGED
@@ -1,18 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = %q{ystock}
3
- s.version = "0.4.0"
4
-
2
+ s.name = 'ystock'
3
+ s.version = "0.4.1"
5
4
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
5
  s.authors = ["Greg Winn"]
7
6
  s.date = %q{2012-06-09}
8
- s.description = %q{Grab stock information from Yahoo Finance and Google}
7
+ s.description = %q{Grab stock information from Yahoo and Google Finance}
9
8
  s.email = %q{greg@winn.ws}
10
9
  s.extra_rdoc_files = ["README.markdown", "lib/ystock.rb"]
11
10
  s.files = ["README.markdown", "lib/ystock.rb","lib/ystock/yahoo.rb", "lib/ystock/google.rb", "ystock.gemspec"]
12
11
  s.homepage = %q{http://github.com/gregwinn/ystock}
13
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ystock", "--main", "README.rdoc"]
14
12
  s.require_paths = ["lib"]
15
- s.rubyforge_project = %q{ystock}
16
- s.rubygems_version = %q{1.5.0}
17
- s.summary = %q{Grab stock information from Yahoo Finance and Google}
13
+ s.summary = %q{Grab stock information from Yahoo and Google Finance}
14
+
15
+ # => Other gem dependency
16
+ s.add_dependency("httparty", "~> 0.10.1")
18
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ystock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,8 +10,24 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-06-09 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Grab stock information from Yahoo Finance and Google
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.10.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.10.1
30
+ description: Grab stock information from Yahoo and Google Finance
15
31
  email: greg@winn.ws
16
32
  executables: []
17
33
  extensions: []
@@ -27,13 +43,7 @@ files:
27
43
  homepage: http://github.com/gregwinn/ystock
28
44
  licenses: []
29
45
  post_install_message:
30
- rdoc_options:
31
- - --line-numbers
32
- - --inline-source
33
- - --title
34
- - Ystock
35
- - --main
36
- - README.rdoc
46
+ rdoc_options: []
37
47
  require_paths:
38
48
  - lib
39
49
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -49,9 +59,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
59
  - !ruby/object:Gem::Version
50
60
  version: '1.2'
51
61
  requirements: []
52
- rubyforge_project: ystock
62
+ rubyforge_project:
53
63
  rubygems_version: 1.8.25
54
64
  signing_key:
55
65
  specification_version: 3
56
- summary: Grab stock information from Yahoo Finance and Google
66
+ summary: Grab stock information from Yahoo and Google Finance
57
67
  test_files: []