Class: Wox::TestFlight

Inherits:
Task
  • Object
show all
Includes:
Environment, NumberHelper
Defined in:
lib/wox/test_flight.rb

Instance Attribute Summary

Attributes included from Environment

#environment

Instance Method Summary collapse

Methods included from NumberHelper

#bytes_to_human_size, #plural

Methods included from Environment

#initialize

Methods inherited from Task

#run_command

Instance Method Details

#api_argsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wox/test_flight.rb', line 12

def api_args
  args = { 
    :file => "@#{environment[:ipa_file]}",
    :api_token => environment[:api_token],
    :team_token => environment[:team_token],
    :notes => environment[:notes]
  }
  
  args[:distribution_lists] = environment[:distribution_lists].join(",") if environment.has_entry? :distribution_lists 
  args[:notify] = environment[:notify] if environment.has_entry? :notify
  args
end

#arg_to_string(arg) ⇒ Object



8
9
10
# File 'lib/wox/test_flight.rb', line 8

def arg_to_string arg
  arg.respond_to?(:join) ? arg.join(",") : arg
end

#curl_arg_stringObject



25
26
27
# File 'lib/wox/test_flight.rb', line 25

def curl_arg_string
  api_args.map {|k,v| "-F #{k}='#{v}'"}.join(" ")
end

#publishObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wox/test_flight.rb', line 29

def publish
  ipa_file = environment[:ipa_file]
  
  puts "Publishing to TestFlight"
  puts "File: #{ipa_file} (#{bytes_to_human_size File.size?(ipa_file)})"
  puts "Accessible To: #{environment[:distribution_lists].join(", ")}" if environment.has_entry? :distribution_lists
  puts "After publish will notify team members" if environment.has_entry? :notify
  
  log_file = File.join environment[:build_dir], "testflight.log"
  run_command "curl --progress-bar #{curl_arg_string} http://testflightapp.com/api/builds.json", :results => log_file
end