Sha256: 0e1746d66dda02710198bed70fafaf86f8916d1813d780ad8b4bdd1c926ae1b0
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# coding: utf-8 require 'net/ftp' require 'dech/ponpare/csv' module Dech class Ponpare class FTPS DEFAULT_HOST = "ftps.ponparemall.com" DEFAULT_PATH = "/item.csv" attr_accessor :products, :username, :host, :path def initialize(args={}) @products = args[:products] || [] @username = args[:username] @password = args[:password] @host = args[:host] || DEFAULT_HOST @path = args[:path] || DEFAULT_PATH end def csv Dech::Ponpare::CSV.new(@products) end def ready? ftps_connection{|ftps| !ftps.nlst(File.dirname(@path)).include?(@path) } end def upload! ftps_connection{|ftps| ftps.storlines("STOR #{@path}", csv) } true end def upload ready? && upload! end private 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dech-0.0.7 | lib/dech/ponpare/ftps.rb |