Permalink
Browse files

fresh start

  • Loading branch information...
1 parent ee6363b commit 428f8811adf26ba9158e02b9e4f664d71b751c26 @cjolly committed Dec 8, 2012
Showing with 0 additions and 43,563 deletions.
  1. +0 −21 Gemfile.lock
  2. +0 −15 lib/pickem.thor
  3. +0 −29 lib/pickem/game.rb
  4. +0 −15 lib/pickem/team.rb
  5. +0 −45 lib/pickem/week.rb
  6. +0 −3 pickem.gemspec
  7. +0 −43,421 spec/fixtures/vcr_cassettes/nfl.yml
  8. +0 −5 spec/pickem_spec.rb
  9. +0 −9 spec/scraper_spec.rb
View
@@ -2,35 +2,16 @@ PATH
remote: .
specs:
pickem (0.0.1)
- activerecord (~> 3.2.0)
nokogiri
- ri_cal
terminal-table
- thor
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.2.8)
- activesupport (= 3.2.8)
- builder (~> 3.0.0)
- activerecord (3.2.8)
- activemodel (= 3.2.8)
- activesupport (= 3.2.8)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activesupport (3.2.8)
- i18n (~> 0.6)
- multi_json (~> 1.0)
addressable (2.3.2)
- arel (3.0.2)
- builder (3.0.3)
crack (0.3.1)
diff-lcs (1.1.3)
- i18n (0.6.1)
- multi_json (1.3.6)
nokogiri (1.5.0)
- ri_cal (0.8.8)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
@@ -40,8 +21,6 @@ GEM
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)
terminal-table (1.4.3)
- thor (0.14.6)
- tzinfo (0.3.33)
vcr (2.2.5)
webmock (1.8.10)
addressable (>= 2.2.7)
View
@@ -1,15 +0,0 @@
-$LOAD_PATH<<'.'
-require 'pickem'
-require 'terminal-table'
-
-module Pickem
- class Picks < Thor
- default_task :for_week
-
- desc "for_week", "Suggestions for week "
- def for_week(week_number)
- week = ::Pickem::Week.new(week_number)
- puts Terminal::Table.new :title => "Week #{week_number} Suggestions", :rows => week.suggestions
- end
- end
-end
View
@@ -1,29 +0,0 @@
-module Pickem
- class Game
- attr_accessor :teams, :home, :away
- def initialize(nokogiri_nodes)
- @teams = []
- @teams << Pickem::Team.new(nokogiri_nodes[0])
- @teams << Pickem::Team.new(nokogiri_nodes[1])
-
- @home = @teams.find {|t| t.home == "1"}
- @away = @teams.find {|t| t.home == "0"}
- end
-
- def to_s
- " #{@home} at #{@away}"
- end
-
- def favorite
- if @home.percent >= @away.percent
- @home
- else
- @away
- end
- end
-
- def underdog
- favorite.name == away.name ? home : away
- end
- end
-end
View
@@ -1,15 +0,0 @@
-module Pickem
- class Team
- attr_accessor :name, :comm, :home, :percent
- def initialize(nokogiri_node)
- @name = nokogiri_node['name']
- @comm = nokogiri_node['comm']
- @home = nokogiri_node['home']
- @percent = nokogiri_node['percent'].to_f
- end
-
- def to_s
- "#{name} (#{percent}%)"
- end
- end
-end
View
@@ -1,45 +0,0 @@
-require 'open-uri'
-require 'nokogiri'
-
-module Pickem
- # espn_picks_page = 'http://espn.go.com/nfl/picks'
- # espn_projections_page = "http://insider.espn.go.com/nfl/projections?weekNumber=5&seasonType=2&seasonYear=2010"
-
- class Week
- attr_accessor :games, :week
- def initialize(week_number)
- @games = []
- @week = week_number.to_i
- parse_espn_projections
- end
-
- def sorted
- @games.sort_by {|g| [g.home.percent, g.away.percent].max }.reverse
- end
-
- def suggestions
- suggestions = []
- sorted.each_with_index do |g, i|
- suggestions << [16-i, g.favorite.name, g.favorite.percent.to_s + '%', (g.favorite.name == g.home.name ? 'Home' : 'Away'), g.underdog.name]
- end
- suggestions
- end
-
- private
-
- def parse_espn_projections
- espn_projections_page = "http://insider.espn.go.com/nfl/projections?week=#{@week}"
-
- doc = Nokogiri::HTML(open(espn_projections_page))
- scripts = doc.search('#my-teams-table script')
-
- accuscore_xml_links = scripts.collect{|s| s.to_s.match(/XMLURL=([^\&]*)/)[1] }
- accuscore_predictions = accuscore_xml_links.collect {|l| Nokogiri::XML(open(l)) }
-
- accuscore_predictions.each_with_index do |game, i|
- @games << Pickem::Game.new(game.search('//team'))
- end
- end
-
- end
-end
View
@@ -22,9 +22,6 @@ Gem::Specification.new do |s|
s.add_development_dependency "vcr"
s.add_development_dependency "webmock"
- s.add_runtime_dependency "thor"
s.add_runtime_dependency "nokogiri"
s.add_runtime_dependency "terminal-table"
- s.add_runtime_dependency "ri_cal"
- s.add_runtime_dependency "activerecord", "~> 3.2.0"
end
Oops, something went wrong.
View
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe Pickem do
- it "should help me win money"
-end
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-describe Scraper do
- it "should scrape" do
- VCR.use_cassette('nfl') do
- Scraper.go
- end
- end
-end

0 comments on commit 428f881

Please sign in to comment.