class Dech::Ponpare::FTPS
Constants
- DEFAULT_HOST
- DEFAULT_PATH
Attributes
host[RW]
path[RW]
products[RW]
username[RW]
Public Class Methods
new(args={})
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 13 def initialize(args={}) @products = args[:products] || [] @username = args[:username] @password = args[:password] @host = args[:host] || DEFAULT_HOST @path = args[:path] || DEFAULT_PATH end
Public Instance Methods
csv()
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 21 def csv Dech::Ponpare::CSV.new(@products) end
ready?()
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 25 def ready? ftps_connection{|ftps| !ftps.nlst(File.dirname(@path)).include?(@path) } end
upload()
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 34 def upload ready? && upload! end
upload!()
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 29 def upload! ftps_connection{|ftps| ftps.storlines("STOR #{@path}", csv) } true end
Private Instance Methods
ftps_connection() { |ftps| ... }
click to toggle source
# File lib/dech/ponpare/ftps.rb, line 40 def ftps_connection(&block) ftps = DoubleBagFTPS.new ftps.passive = true ftps.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE) ftps.connect(@host) ftps.login(@username, @password) yield(ftps) ensure ftps.close end