Class: Xcode::Testflight

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token, team_token) ⇒ Testflight

Returns a new instance of Testflight.



8
9
10
11
12
13
14
15
# File 'lib/xcode/testflight.rb', line 8

def initialize(api_token, team_token)
  @api_token = api_token
  @team_token = team_token
  @notify = true
  @notes = nil
  @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/testflight.rb', line 6

def api_token
  @api_token
end

#listsObject

Returns the value of attribute lists.



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

def lists
  @lists
end

#notesObject

Returns the value of attribute notes.



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

def notes
  @notes
end

#notifyObject

Returns the value of attribute notify.



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

def notify
  @notify
end

#proxyObject

Returns the value of attribute proxy.



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

def proxy
  @proxy
end

#team_tokenObject

Returns the value of attribute team_token.



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

def team_token
  @team_token
end

Instance Method Details

#upload(ipa_path, dsymzip_path = nil) {|json| ... } ⇒ Object

Yields:

  • (json)


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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xcode/testflight.rb', line 17

def upload(ipa_path, dsymzip_path=nil)
  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(ipa_path),
  #   :dsym => File.new(dsymzip_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 = []
  cmd << 'curl'
  cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy=='' 
  cmd << "-X POST http://testflightapp.com/api/builds.json"
  cmd << "-F file=@\"#{ipa_path}\""
  cmd << "-F dsym=@\"#{dsymzip_path}\"" unless dsymzip_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 = Xcode::Shell.execute(cmd)
  
  json = JSON.parse(response.join(''))
  puts " + Done, got: #{json.inspect}"
  
  yield(json) if block_given?
  
  json
end