Sha256: 206ec4ce22b1ed9f56141d1443bee5df79a6517b99086ee104c560b4db0b11b0
Contents?: true
Size: 976 Bytes
Versions: 5
Compression:
Stored size: 976 Bytes
Contents
# coding: utf-8 require 'net/ftp' require 'dech/rakuten/csv' module Dech class Rakuten class FTP DEFAULT_HOST = "upload.rakuten.ne.jp" DEFAULT_PATH = "/ritem/batch/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::Rakuten::CSV.new(@products) end def ready? ftp_connection{|ftp| !ftp.nlst(File.dirname(@path)).include?(@path) } end def upload! ftp_connection{|ftp| ftp.storlines("STOR #{@path}", csv) } true end def upload ready? && upload! end private def ftp_connection Net::FTP.open(@host, @username, @password){|ftp| yield(ftp) } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
dech-0.1.0 | lib/dech/rakuten/ftp.rb |
dech-0.0.7 | lib/dech/rakuten/ftp.rb |
dech-0.0.6 | lib/dech/rakuten/ftp.rb |
dech-0.0.5 | lib/dech/rakuten/ftp.rb |
dech-0.0.4 | lib/dech/rakuten/ftp.rb |