Browse files

implementing the ftp protocol

  • Loading branch information...
1 parent 1736830 commit 5fb4fad94eda2ecf9554535ab20bf9618e5c1a44 @beaucollins committed Sep 17, 2009
Showing with 32 additions and 0 deletions.
  1. +32 −0 lib/power_reviews/protocols/ftp.rb
View
32 lib/power_reviews/protocols/ftp.rb
@@ -1,7 +1,39 @@
+
+require "net/ftp"
+
module PowerReviews
module Protocols
class Ftp < Base
+ # Returns true if the done file is missing
+ def done?
+ !client.nlst.include?(@config['done'])
+ end
+
+ # Delete the done file
+ def done!
+ client.delete(@config['done'])
+ end
+
+ # Do the copying of the zip file to the preferred destination
+ def copy_zip(to)
+ puts 'FTP getting file'
+ client.getbinaryfile(@config['zip'], to)
+ end
+
+ # do any cleanup necessary
+ def cleanup
+ @client.close
+ end
+
+ def client
+ return @client unless @client.nil?
+ puts "Connecting to #{@config['host']} as #{@config['username']}"
+ @client = Net::FTP.new(@config['host'])
+ @client.login(@config['username'], @config['password'])
+ @client
+ end
+
end
end
end

0 comments on commit 5fb4fad

Please sign in to comment.