Class: Xcode::Deploy::Ssh

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/deploy/ssh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, options) ⇒ Ssh

Returns a new instance of Ssh.



10
11
12
13
14
15
16
17
# File 'lib/xcode/deploy/ssh.rb', line 10

def initialize(builder, options)
  @builder = builder
  @username = options[:username]
  @password = options[:password]
  @dir = options[:dir]
  @host = options[:host]
  @base_url = options[:base_url]
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



8
9
10
# File 'lib/xcode/deploy/ssh.rb', line 8

def dir
  @dir
end

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/xcode/deploy/ssh.rb', line 8

def host
  @host
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/xcode/deploy/ssh.rb', line 8

def password
  @password
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/xcode/deploy/ssh.rb', line 8

def username
  @username
end

Instance Method Details

#deployObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/xcode/deploy/ssh.rb', line 23

def deploy
  WebAssets.generate @builder, @base_url do |dist_path|
    puts "Copying files to #{@remote_host}:#{remote_installation_path}"
    Net::SSH.start(@host, @username, :password => @password) do |ssh|
      puts "Creating folder with mkdir #{remote_installation_path}"
      ssh.exec!("mkdir #{remote_installation_path}")
    end
    Net::SCP.start(@host, @username, :password => @password) do |scp|
      puts "Copying files from folder #{dist_path}"
      Dir["#{dist_path}/*"].each do |f|
        puts "Copying #{f} to remote host in folder #{remote_installation_path}"
        scp.upload! "#{f}", "#{remote_installation_path}"
      end
      scp.upload! "#{@options[:ipa_path]}", "#{remote_installation_path}"
    end
  end
end

#remote_installation_pathObject



19
20
21
# File 'lib/xcode/deploy/ssh.rb', line 19

def remote_installation_path
  File.join(@dir, @builder.product_name)
end