ticker_fetcher 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@ticker_fetcher
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'autotest'
7
+ gem 'test_notifier'
8
+ gem 'ruby-debug19'
9
+ end
10
+
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ticker_fetcher (0.1.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ ZenTest (4.6.0)
10
+ archive-tar-minitar (0.5.2)
11
+ autotest (4.4.6)
12
+ ZenTest (>= 4.4.1)
13
+ columnize (0.3.4)
14
+ flexmock (0.9.0)
15
+ linecache19 (0.5.12)
16
+ ruby_core_source (>= 0.1.4)
17
+ notifier (0.1.3)
18
+ ruby-debug-base19 (0.11.25)
19
+ columnize (>= 0.3.1)
20
+ linecache19 (>= 0.5.11)
21
+ ruby_core_source (>= 0.1.4)
22
+ ruby-debug19 (0.11.6)
23
+ columnize (>= 0.3.1)
24
+ linecache19 (>= 0.5.11)
25
+ ruby-debug-base19 (>= 0.11.19)
26
+ ruby_core_source (0.1.5)
27
+ archive-tar-minitar (>= 0.5.2)
28
+ test_notifier (0.3.6)
29
+ notifier
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ autotest
36
+ flexmock (>= 0.8.2)
37
+ ruby-debug19
38
+ test_notifier
39
+ ticker_fetcher!
data/Rakefile CHANGED
@@ -1,54 +1,11 @@
1
- require 'rubygems'
2
1
  require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "ticker_fetcher"
8
- gem.summary = %Q{Fetches all tickers for NYSE, NASDAQ, and AMEX exchanges.}
9
- gem.description = %Q{Retrieves tickers, and names for all securities listed on the 3 major US exchanges (NYSE, NASDAQ, AMEX).}
10
- gem.email = "mattw922@gmail.com"
11
- gem.homepage = "http://github.com/whitethunder/ticker_fetcher"
12
- gem.authors = ["Matt White"]
13
- gem.add_development_dependency "fastercsv", ">= 1.5.0"
14
- gem.add_development_dependency "flexmock", ">= 0.8.2"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
2
  require 'rake/testtask'
3
+ require 'bundler/gem_tasks'
4
+
23
5
  Rake::TestTask.new(:test) do |test|
24
6
  test.libs << 'lib' << 'test'
25
7
  test.pattern = 'test/**/test_*.rb'
26
8
  test.verbose = true
27
9
  end
28
10
 
29
- begin
30
- require 'rcov/rcovtask'
31
- Rcov::RcovTask.new do |test|
32
- test.libs << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
- rescue LoadError
37
- task :rcov do
38
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
- end
40
- end
41
-
42
- task :test => :check_dependencies
43
-
44
11
  task :default => :test
45
-
46
- require 'rake/rdoctask'
47
- Rake::RDocTask.new do |rdoc|
48
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
-
50
- rdoc.rdoc_dir = 'rdoc'
51
- rdoc.title = "ticker_fetcher #{version}"
52
- rdoc.rdoc_files.include('README*')
53
- rdoc.rdoc_files.include('lib/**/*.rb')
54
- end
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'open-uri'
3
- require 'fastercsv'
3
+ require 'csv'
4
4
 
5
5
  class TickerFetcher
6
6
  Symbol = 0
@@ -9,7 +9,7 @@ class TickerFetcher
9
9
  MarketCap = 3
10
10
  Sector = 5
11
11
  Industry = 6
12
- attr_accessor :exchanges
12
+ attr_reader :exchanges
13
13
 
14
14
  # Passing 1 or more exchange names will retrieve only those exchanges. Default
15
15
  # is to retrieve all.
@@ -22,11 +22,12 @@ class TickerFetcher
22
22
  }
23
23
  end
24
24
 
25
- def retrieve(exchange)
26
- unless exchange == :all
27
- @exchange_urls.delete_if { |k,v| exchange.upcase != k }
25
+ def retrieve(exchange=:all)
26
+ if exchange == :all
27
+ @exchange_urls.each { |exchange, url| @exchanges[exchange] = parse_exchange(exchange, url) }
28
+ else
29
+ @exchanges[exchange] = parse_exchange(exchange, @exchange_urls[exchange])
28
30
  end
29
- @exchange_urls.each { |exchange, url| @exchanges[exchange] = parse_exchange(exchange, url) }
30
31
  end
31
32
 
32
33
  def parse_exchange(exchange, url)
@@ -34,11 +35,15 @@ class TickerFetcher
34
35
  parse_csv(data)
35
36
  end
36
37
 
38
+ def [](exchange)
39
+ exchanges[exchange]
40
+ end
41
+
37
42
  private
38
43
 
39
44
  def parse_csv(data)
40
45
  tickers = []
41
- FasterCSV.parse(data) { |row|
46
+ CSV.parse(data) { |row|
42
47
  name = row[Name]
43
48
  ticker = row[Symbol].strip.gsub('"', '')
44
49
  unless(ticker.nil? || ticker.empty? || ticker == 'Symbol')
@@ -1,6 +1,6 @@
1
1
  "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","Industry","Summary Quote"
2
- "SC","StupidCompany, Inc.",2.71,72858350,"1999","Consumer Services","Other Specialty Stores","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=SC&selected=SC"
2
+ "SC","StupidCompany, Inc.",2.71,72858350,1999,"Consumer Services","Other Specialty Stores","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=SC&selected=SC"
3
3
  "AC^B","AwesomeCompany, Inc.",100,26656000,"n/a","n/a","n/a","n/a"
4
- "C-A","Company, Inc.",0.15,26656000,"2001","Health Care","Major Banks","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=C-A&selected=C-A"
5
- "ZIGO","Zygo Corporation",5,17411000,"2010","Consumer Durables","Specialty Chemicals","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=ZIGO&selected=ZIGO"
6
- "ZGEN","ZymoGenetics, Inc.",25,85473000,"2015","Technology","Semiconductors","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=ZGEN&selected=ZGEN"
4
+ "C.A","Company, Inc.",0.15,26656000,2001,"Health Care","Major Banks","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=C-A&selected=C-A"
5
+ "ZIGO","Zygo Corporation",5,17411000,2010,"Consumer Durables","Specialty Chemicals","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=ZIGO&selected=ZIGO"
6
+ "ZGEN","ZymoGenetics, Inc.",25,85473000,2015,"Technology","Semiconductors","http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=ZGEN&selected=ZGEN"
@@ -19,11 +19,12 @@ class TestTickerFetcher < Test::Unit::TestCase
19
19
  assert_nil(@t_mock.exchanges['AMEX'])
20
20
  assert_equal('SC', @t_mock.exchanges['NYSE'][0][0])
21
21
  assert_equal('AC-B', @t_mock.exchanges['NYSE'][1][0])
22
- assert_equal('C-A', @t_mock.exchanges['NYSE'][2][0])
22
+ assert_equal('C.A', @t_mock.exchanges['NYSE'][2][0])
23
23
  end
24
24
 
25
25
  def test_retrieve_with_two_exchanges_returns_a_ticker_fetcher_with_the_correct_data
26
- @t_mock.retrieve('NYSE', 'NASD')
26
+ @t_mock.retrieve('NYSE')
27
+ @t_mock.retrieve('NASD')
27
28
  assert_not_nil(@t_mock.exchanges['NYSE'])
28
29
  assert_not_nil(@t_mock.exchanges['NASD'])
29
30
  assert_nil(@t_mock.exchanges['AMEX'])
@@ -1,61 +1,17 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
- s.name = %q{ticker_fetcher}
8
- s.version = "0.1.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ s.name = "ticker_fetcher"
5
+ s.version = "0.2.0"
11
6
  s.authors = ["Matt White"]
12
- s.date = %q{2010-05-25}
13
- s.description = %q{Retrieves tickers, and names for all securities listed on the 3 major US exchanges (NYSE, NASDAQ, AMEX).}
14
7
  s.email = %q{mattw922@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/ticker_fetcher.rb",
27
- "test/amex_test_data.csv",
28
- "test/helper.rb",
29
- "test/nasd_test_data.csv",
30
- "test/nyse_test_data.csv",
31
- "test/test_ticker_fetcher.rb",
32
- "ticker_fetcher-0.1.0.gem",
33
- "ticker_fetcher.gemspec"
34
- ]
35
8
  s.homepage = %q{http://github.com/whitethunder/ticker_fetcher}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.6}
39
9
  s.summary = %q{Fetches all tickers for NYSE, NASDAQ, and AMEX exchanges.}
40
- s.test_files = [
41
- "test/test_ticker_fetcher.rb",
42
- "test/helper.rb"
43
- ]
44
-
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 3
10
+ s.description = %q{Retrieves tickers, and names for all securities listed on the 3 major US exchanges (NYSE, NASDAQ, AMEX).}
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
13
+ s.require_paths = ["lib"]
48
14
 
49
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
- s.add_development_dependency(%q<fastercsv>, [">= 1.5.0"])
51
- s.add_development_dependency(%q<flexmock>, [">= 0.8.2"])
52
- else
53
- s.add_dependency(%q<fastercsv>, [">= 1.5.0"])
54
- s.add_dependency(%q<flexmock>, [">= 0.8.2"])
55
- end
56
- else
57
- s.add_dependency(%q<fastercsv>, [">= 1.5.0"])
58
- s.add_dependency(%q<flexmock>, [">= 0.8.2"])
59
- end
15
+ s.add_development_dependency(%q<flexmock>, [">= 0.8.2"])
60
16
  end
61
17
 
metadata CHANGED
@@ -1,104 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ticker_fetcher
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Matt White
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-05-25 00:00:00 -06:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: fastercsv
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 5
30
- - 0
31
- version: 1.5.0
32
- type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
35
15
  name: flexmock
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 8
44
- - 2
16
+ requirement: &81809110 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
45
21
  version: 0.8.2
46
22
  type: :development
47
- version_requirements: *id002
48
- description: Retrieves tickers, and names for all securities listed on the 3 major US exchanges (NYSE, NASDAQ, AMEX).
23
+ prerelease: false
24
+ version_requirements: *81809110
25
+ description: Retrieves tickers, and names for all securities listed on the 3 major
26
+ US exchanges (NYSE, NASDAQ, AMEX).
49
27
  email: mattw922@gmail.com
50
28
  executables: []
51
-
52
29
  extensions: []
53
-
54
- extra_rdoc_files:
55
- - LICENSE
56
- - README.rdoc
57
- files:
30
+ extra_rdoc_files: []
31
+ files:
58
32
  - .document
59
33
  - .gitignore
34
+ - .rvmrc
35
+ - Gemfile
36
+ - Gemfile.lock
60
37
  - LICENSE
61
38
  - README.rdoc
62
39
  - Rakefile
63
- - VERSION
64
40
  - lib/ticker_fetcher.rb
65
41
  - test/amex_test_data.csv
66
42
  - test/helper.rb
67
43
  - test/nasd_test_data.csv
68
44
  - test/nyse_test_data.csv
69
45
  - test/test_ticker_fetcher.rb
70
- - ticker_fetcher-0.1.0.gem
71
46
  - ticker_fetcher.gemspec
72
- has_rdoc: true
73
47
  homepage: http://github.com/whitethunder/ticker_fetcher
74
48
  licenses: []
75
-
76
49
  post_install_message:
77
- rdoc_options:
78
- - --charset=UTF-8
79
- require_paths:
50
+ rdoc_options: []
51
+ require_paths:
80
52
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
- version: "0"
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- segments:
93
- - 0
94
- version: "0"
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
95
65
  requirements: []
96
-
97
66
  rubyforge_project:
98
- rubygems_version: 1.3.6
67
+ rubygems_version: 1.8.6
99
68
  signing_key:
100
69
  specification_version: 3
101
70
  summary: Fetches all tickers for NYSE, NASDAQ, and AMEX exchanges.
102
- test_files:
103
- - test/test_ticker_fetcher.rb
104
- - test/helper.rb
71
+ test_files: []
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.1
Binary file