Class: Shenzhen::Plugins::FTP::Client
- Inherits:
-
Object
- Object
- Shenzhen::Plugins::FTP::Client
- Defined in:
- lib/shenzhen/plugins/ftp.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(host, port, user, password) ⇒ Client
constructor
A new instance of Client.
- #upload(ipa, options = {}) ⇒ Object
Constructor Details
#initialize(host, port, user, password) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/shenzhen/plugins/ftp.rb', line 8 def initialize(host, port, user, password) @host, @port, @user, @password = host, port, user, password end |
Instance Method Details
#upload(ipa, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shenzhen/plugins/ftp.rb', line 12 def upload(ipa, = {}) connection = Net::FTP.new connection.passive = true connection.connect(@host, @port) path = (ipa, [:path]) begin connection.login(@user, @password) rescue raise "Login authentication failed" if [:mkdir] components, pwd = path.split(/\//).reject(&:empty?), nil components.each do |component| pwd = File.join(*[pwd, component].compact) begin connection.mkdir pwd rescue => exception raise exception unless /File exists/ === exception. end end end connection.chdir path unless path.empty? connection.putbinaryfile ipa, File.basename(ipa) connection.putbinaryfile([:dsym], File.basename([:dsym])) if [:dsym] ensure connection.close end end |