Class: Xcode::Deploy::Ftp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, options = {}) ⇒ Ftp

Returns a new instance of Ftp.



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

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.



7
8
9
# File 'lib/xcode/deploy/ftp.rb', line 7

def dir
  @dir
end

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/xcode/deploy/ftp.rb', line 7

def host
  @host
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/xcode/deploy/ftp.rb', line 7

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/xcode/deploy/ftp.rb', line 7

def username
  @username
end

Instance Method Details

#deployObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/xcode/deploy/ftp.rb', line 27

def deploy
  WebAssets.generate @builder, @base_url do |dir|
    puts "Connecting to #{@remote_host} with username #{@username}"
    Net::FTP.open(@host, @username, @password) do |ftp|
      begin
        puts "Creating folder #{remote_installation_path}"
        ftp.mkdir(remote_installation_path)
      rescue Net::FTPError
        puts "It looks like the folder is already there."
      end

      puts "Changing to remote folder #{remote_installation_path}"
      files = ftp.chdir(remote_installation_path)

      Dir["#{dir}/*"].each do |f|
        filename = File.basename(f)
        puts "Uploading #{filename}"
        ftp.putbinaryfile(f, filename, 1024)
      end

      filename = File.basename("#{@builder.ipa_path}")
      puts "Uploading #{filename}"
      ftp.putbinaryfile("#{@builder.ipa_path}", filename, 1024)
    end
  end
end

#get_bindingObject

Support templating of member data.



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

def get_binding
  binding
end

#remote_installation_pathObject



23
24
25
# File 'lib/xcode/deploy/ftp.rb', line 23

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