Created
March 8, 2011 20:41
-
-
Save gmgent/860998 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Process daily.' | |
require 'ftps_implicit' | |
include Gmg | |
require "fastercsv" | |
namespace :testing do | |
task :gmg_api do | |
puts "\n\n\n TESTING gmg_api CONNECT \n\n\n" | |
@ftp_host = 'xxx' | |
@ftp_user = 'xxx' | |
@ftp_password = 'xxx' | |
@get_file = 'xxx.csv' | |
begin | |
ftp = Net::FTPS::Implicit.new(@ftp_host, @ftp_user, @ftp_password) | |
puts "we logged in" | |
puts ftp.list | |
ftp.gettextfile(@get_file) | |
puts "got file #{@get_file}. moving it now." | |
FileUtils.mv(@get_file, "xxx/#{@get_file}") | |
ensure | |
ftp.close | |
end | |
puts "processing file." | |
read_file = FasterCSV.read("xxx/#{@get_file}", {:headers => true}) | |
@csv = Gmg::ParseGenericSale.new(read_file).parse | |
@csv.each do |this_line| | |
p this_line | |
end | |
puts "you the man now, dawg!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment