Skip to content

Commit

Permalink
Starting to move to pathnames rather than pure strings for local fold…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
geoffharcourt committed Mar 16, 2012
1 parent d2be8a5 commit c768154
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/greenmonster.rb
Expand Up @@ -3,6 +3,7 @@

require 'httparty'
require 'nokogiri'
require 'pathname'
require 'fileutils'

module Greenmonster
Expand All @@ -21,7 +22,7 @@ module Greenmonster
#

def self.set_games_folder(location)
@@games_folder = location
@@games_folder = Pathname.new(location)
end

##
Expand All @@ -30,7 +31,7 @@ def self.set_games_folder(location)
# Example:
# >> Greenmonster.set_games_folder("/Users/geoff/game_data")
# >> Greenmonster.games_folder
# => "/Users/geoff/game_data"
# => #<Pathname:/Users/geoff/game_data>

def self.games_folder
@@games_folder
Expand Down
5 changes: 3 additions & 2 deletions lib/greenmonster/spider.rb
Expand Up @@ -19,13 +19,14 @@ def self.pull_game(game_id,args = {})
:print_games => true,
:games_folder => Greenmonster.games_folder
}.merge(args)
args[:games_folder] = Pathname.new(args[:games_folder])

puts game_id if args[:print_games]

raise "Games folder location required." if args[:games_folder].nil?

paths = {
:localGameFolder => "#{args[:games_folder]}/#{args[:sport_code]}/#{format_date_as_folder(args[:date])}/#{game_id}/",
:localGameFolder => args[:games_folder] + args[:sport_code] + format_date_as_folder(args[:date]) + game_id,
:mlbGameFolder => "#{gameday_league_and_date_url(args)}/#{game_id}/"
}

Expand Down Expand Up @@ -170,4 +171,4 @@ def self.copy_gameday_xml (file_name,paths)
def self.format_date_as_folder(date)
date.strftime("year_%Y/month_%m/day_%d")
end
end
end
2 changes: 1 addition & 1 deletion test/test_greenmonster.rb
Expand Up @@ -7,7 +7,7 @@ def setup

def test_set_games_folder_location
Greenmonster.set_games_folder('./test_greenmonster_folder')
assert_equal './test_greenmonster_folder', Greenmonster.games_folder
assert_equal './test_greenmonster_folder', Greenmonster.games_folder.to_s
end

def teardown
Expand Down

0 comments on commit c768154

Please sign in to comment.