Class: Xcode::Deploy::Testflight

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

Constant Summary collapse

@@defaults =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Testflight.



13
14
15
16
17
18
19
20
21
# File 'lib/xcode/deploy/testflight.rb', line 13

def initialize(builder, options={})
  @builder = builder
  @api_token = options[:api_token]||@@defaults[:api_token]
  @team_token = options[:team_token]||@@defaults[:team_token]
  @notify = options.has_key?(:notify) ? options[:notify] : true
  @notes = options[:notes]
  @lists = options[:lists]||[]
  @proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def api_token
  @api_token
end

#builderObject

Returns the value of attribute builder.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def builder
  @builder
end

#listsObject

Returns the value of attribute lists.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def lists
  @lists
end

#notesObject

Returns the value of attribute notes.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def notes
  @notes
end

#notifyObject

Returns the value of attribute notify.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def notify
  @notify
end

#proxyObject

Returns the value of attribute proxy.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def proxy
  @proxy
end

#team_tokenObject

Returns the value of attribute team_token.



6
7
8
# File 'lib/xcode/deploy/testflight.rb', line 6

def team_token
  @team_token
end

Class Method Details

.defaults(defaults = {}) ⇒ Object



9
10
11
# File 'lib/xcode/deploy/testflight.rb', line 9

def self.defaults(defaults={})
  @@defaults = defaults
end

Instance Method Details

#deploy {|json| ... } ⇒ Object

Yields:

  • (json)


23
24
25
26
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
53
54
55
56
57
58
59
60
61
62
# File 'lib/xcode/deploy/testflight.rb', line 23

def deploy
  puts "Uploading to Testflight..."

  # RestClient.proxy = @proxy || ENV['http_proxy'] || ENV['HTTP_PROXY']
  # RestClient.log = '/tmp/restclient.log'
  #
  # response = RestClient.post('http://testflightapp.com/api/builds.json',
  #   :file => File.new(builder.ipa_path),
  #   :dsym => File.new(builder.dsym_zip_path),
  #   :api_token => @api_token,
  #   :team_token => @team_token,
  #   :notes => @notes,
  #   :notify => @notify ? 'True' : 'False',
  #   :distribution_lists => @lists.join(',')
  # )
  #
  # json = JSON.parse(response)
  # puts " + Done, got: #{json.inspect}"
  # json

  cmd = Xcode::Shell::Command.new 'curl'
  cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy==''
  cmd << "-X POST http://testflightapp.com/api/builds.json"
  cmd << "-F file=@\"#{@builder.ipa_path}\""
  cmd << "-F dsym=@\"#{@builder.dsym_zip_path}\"" unless @builder.dsym_zip_path.nil?
  cmd << "-F api_token='#{@api_token}'"
  cmd << "-F team_token='#{@team_token}'"
  cmd << "-F notes=\"#{@notes}\"" unless @notes.nil?
  cmd << "-F notify=#{@notify ? 'True' : 'False'}"
  cmd << "-F distribution_lists='#{@lists.join(',')}'" unless @lists.count==0

  response = cmd.execute

  json = MultiJson.load(response.join(''))
  puts " + Done, got: #{json.inspect}"

  yield(json) if block_given?

  json
end