Class: Alloy::Task::Build::Chore

Inherits:
Object
  • Object
show all
Defined in:
lib/alloy/task/build.rb

Constant Summary collapse

PERL_COLOR_FILTER =
%Q{| perl -pe 's/^\\[DEBUG\\].*$/\\e[35m$&\\e[0m/g;s/^\\[INFO\\].*$/\\e[36m$&\\e[0m/g;s/^\\[WARN\\].*$/\\e[33m$&\\e[0m/g;s/^\\[ERROR\\].*$/\\e[31m$&\\e[0m/g;'}

Class Method Summary collapse

Class Method Details

.build_and_run_androidObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/alloy/task/build.rb', line 42

def self.build_and_run_android
  config = Alloy::Config.new('./alloy.json')
  puts "Building with Titanium... (DEVICE_TYPE: android)".blue
  command = 'simulator'
  project_name = config.app_name
  sdk_dir = config.android_sdk_path
  project_dir = config.project_root + '/'
  app_id = config.app_id
  avd_id = config.android_avd_id
  bash_arg = [config.titanium_android_builder,
              command,
              project_name,
              sdk_dir,
              project_dir,
              app_id,
              avd_id].map{|i|Shellwords.escape(i)}.join(' ')
  cmd = %Q{bash -c "#{bash_arg}" #{PERL_COLOR_FILTER}}
  puts cmd
  system cmd
end

.build_and_run_iphoneObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/alloy/task/build.rb', line 22

def self.build_and_run_iphone
  config = Alloy::Config.new('./alloy.json')
  puts "Building with Titanium... (DEVICE_TYPE: iphone)".blue
  bash_arg = [config.titanium_iphone_builder,
              'run',
              config.project_root + '/',
              config.iphone_sdk_version,
              config.app_id,
              config.app_name,
              'iphone'].map{|i|Shellwords.escape(i)}.join(' ')
  cmd = %Q{bash -c "#{bash_arg}" #{PERL_COLOR_FILTER}}
  begin
    system cmd
  rescue => e
    puts e.backtrace.join("\n")
    puts e.message.red
    system %Q{killall "iPhone Simulator"}
  end
end