Class: Smokegraphy::FtpResourceController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Smokegraphy::FtpResourceController
- Defined in:
- lib/smokegraphy/resource_controller/ftp_resource_controller.rb
Instance Method Summary collapse
- #add_execute_permission(filename) ⇒ Object
- #cleanup(filename = nil) ⇒ Object
- #close ⇒ Object
- #init ⇒ Object
-
#initialize(config) ⇒ FtpResourceController
constructor
A new instance of FtpResourceController.
- #transfer_source_file(filename, testsuite, destname = nil) ⇒ Object
Methods inherited from ResourceController
Constructor Details
#initialize(config) ⇒ FtpResourceController
Returns a new instance of FtpResourceController.
9 10 11 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 9 def initialize(config) @config = config end |
Instance Method Details
#add_execute_permission(filename) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 50 def (filename) begin @@ftp.voidcmd("site chmod 755 #{filename}") rescue => evar print "Failed to chmod #{filename}: #{evar}" end end |
#cleanup(filename = nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 58 def cleanup(filename = nil) if filename then files = @@ftp.nlst @@ftp.delete(filename) if files.include?(filename) @uploaded.delete filename else files = @@ftp.nlst @uploaded.each do |f| @@ftp.delete(f) if files.include?(f) end end end |
#close ⇒ Object
24 25 26 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 24 def close @@ftp.close end |
#init ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 13 def init @uploaded = [] if (@config["deploy"] == "ftp" && $ftp == nil) then @@ftp = Net::FTPTLS.new(@config["ftp"]["server"], @config["ftp"]["username"], @config["ftp"]["password"]); @@ftp.passive = true @@ftp.debug_mode = false end end |
#transfer_source_file(filename, testsuite, destname = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/smokegraphy/resource_controller/ftp_resource_controller.rb', line 28 def transfer_source_file(filename, testsuite, destname = nil) begin source = "source/#{testsuite}/#{filename}" destname ||= filename if File.exist?(source) then document_root = @config["http"]["document_root"] temp = Tempfile.new("ftp_") File.open(temp.path, "w") { |out| out << ERB.new(File.new(source).read).result(binding) } @@ftp.put(temp.path, destname) temp.close @uploaded << destname if !(@uploaded.include? destname) else raise "no such file: #{source}" end rescue => evar raise "Failed to copy #{filename}: #{evar}" end end |