yahoo_stock 1.0.2

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.
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe YahooStock::Result do
4
+ before(:each) do
5
+ @string_result = 'some string result'
6
+ @result = YahooStock::Result.new(@string_result)
7
+ end
8
+
9
+ describe "output" do
10
+ it "should return the string" do
11
+ @result.output.should eql(@string_result)
12
+ end
13
+
14
+ it "should not call the output method if the parameter passed is string" do
15
+ @string_result.should_receive(:output).never
16
+ @result.output
17
+ end
18
+
19
+ it "should call the output method if the parameter passed is not string" do
20
+ other_result_obj = YahooStock::Result::ArrayFormat.new(@string_result)
21
+ other_result_obj.should_receive(:output)
22
+ result = YahooStock::Result.new(other_result_obj)
23
+ result.output
24
+ end
25
+ end
26
+
27
+ describe "store" do
28
+ it "should open a file to append the output" do
29
+ File.should_receive(:open).with('filename', 'a')
30
+ @result.store('filename')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YahooStock::ScripSymbol do
4
+ describe ".results" do
5
+ before(:each) do
6
+ @company = stub('ScripSymbol')
7
+ @result = YahooStock::Result.new('cst')
8
+ YahooStock::ScripSymbol.stub!(:new).and_return(@company)
9
+ @company.stub!(:results).and_return(@result)
10
+ end
11
+ it "should create ScripSymbol instance for each company name" do
12
+ YahooStock::ScripSymbol.should_receive(:new).with('company1').and_return(@company)
13
+ YahooStock::ScripSymbol.should_receive(:new).with('company2').and_return(@company)
14
+ YahooStock::ScripSymbol.results('company1', 'company2')
15
+ end
16
+
17
+ it "find results for each company" do
18
+ @company.should_receive(:results).twice.and_return(@result)
19
+ YahooStock::ScripSymbol.results('company1', 'company2')
20
+ end
21
+
22
+ it "should concatenate the results of all company names and then initialize the YahooStock::Result object" do
23
+ company2 = stub('ScripSymbol')
24
+ @result2 = YahooStock::Result.new('qwe')
25
+ company2.stub!(:results).and_return(@result2)
26
+ YahooStock::ScripSymbol.stub!(:new).with('company1').and_return(@company)
27
+ YahooStock::ScripSymbol.stub!(:new).with('company2').and_return(company2)
28
+ YahooStock::Result.should_receive(:new).with("cst\nqwe\n")
29
+ YahooStock::ScripSymbol.results('company1', 'company2')
30
+ end
31
+ end
32
+
33
+ describe "data_attributes" do
34
+ before(:each) do
35
+ @symbol = YahooStock::ScripSymbol.new('company name')
36
+ end
37
+ it "should return an array of data attributes" do
38
+ @symbol.data_attributes.should be_instance_of(Array)
39
+ end
40
+
41
+ it "should have following data attributes" do
42
+ @symbol.data_attributes.should include('Symbol', 'Name', 'Last Trade', 'Type', 'Industry Category', 'Exchange')
43
+ end
44
+ end
45
+
46
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yahoo_stock
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nasir Jamal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-04 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Yahoo Stock is a Ruby library for extracting information about stocks from yahoo finance
17
+ email: nas35_in@yahoo.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - History.txt
26
+ - Manifest.txt
27
+ - README.rdoc
28
+ - Rakefile
29
+ - lib/yahoo_stock.rb
30
+ - lib/yahoo_stock/base.rb
31
+ - lib/yahoo_stock/history.rb
32
+ - lib/yahoo_stock/interface.rb
33
+ - lib/yahoo_stock/interface/history.rb
34
+ - lib/yahoo_stock/interface/quote.rb
35
+ - lib/yahoo_stock/interface/scrip_symbol.rb
36
+ - lib/yahoo_stock/quote.rb
37
+ - lib/yahoo_stock/result.rb
38
+ - lib/yahoo_stock/result/array_format.rb
39
+ - lib/yahoo_stock/result/hash_format.rb
40
+ - lib/yahoo_stock/scrip_symbol.rb
41
+ has_rdoc: true
42
+ homepage: http://github.com/nas/yahoo_stock
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --charset=UTF-8
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "1.8"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.4
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Yahoo Stock is a Ruby library for extracting information about stocks from yahoo finance.
69
+ test_files:
70
+ - spec/spec_helper.rb
71
+ - spec/yahoo_stock/base_spec.rb
72
+ - spec/yahoo_stock/history_spec.rb
73
+ - spec/yahoo_stock/interface_spec.rb
74
+ - spec/yahoo_stock/interface/history_spec.rb
75
+ - spec/yahoo_stock/interface/quote_spec.rb
76
+ - spec/yahoo_stock/interface/scrip_symbol_spec.rb
77
+ - spec/yahoo_stock/quote_spec.rb
78
+ - spec/yahoo_stock/result_spec.rb
79
+ - spec/yahoo_stock/result/array_format_spec.rb
80
+ - spec/yahoo_stock/result/hash_format_spec.rb
81
+ - spec/yahoo_stock/scrip_symbol_spec.rb