module NewclearHelper

Constants

NUKE_MESSAGE

Public Instance Methods

build_project() click to toggle source
# File lib/newclear_helper.rb, line 37
def build_project
  puts "Building project..."
  if is_android? and !running_genymotion?
    puts "for device"
    exec('rake device')
  else
    exec('rake')
  end
end
has_task?(task_name) click to toggle source
# File lib/newclear_helper.rb, line 47
def has_task?(task_name)
  Rake.application.tasks.count{ |rt| rt.name == task_name} > 0
end
is_android?() click to toggle source
# File lib/newclear_helper.rb, line 51
def is_android?
  @android ||= system("rake -T | grep -q .apk")
end
nuke_project() click to toggle source
# File lib/newclear_helper.rb, line 9
def nuke_project
  puts "\nCleaning Project..."
  `rake clean:all`

  unless is_android?
    puts "\nResetting simulator..."
    `reset-sim`
  end

  # Fast bundle
  puts "\nBundling..."
  `bundle install --jobs=3 --retry=3`

  # iOS Depencies
  if has_task? "pod:install"
    puts "\nSetting up cocoapods..."
    `pod setup`
    puts "\nInstalling cocoapod dependencies..."
    `rake pod:install`
  end

  # Android Dependencies
  if has_task? "gradle:install"
    puts "\nSetting up gradle automation dependencies..."
    `rake gradle:install`
  end
end
running_genymotion?() click to toggle source

We assume they keep their API in the emulator name

# File lib/newclear_helper.rb, line 56
def running_genymotion?
  genymotion_active = false
  if system("which VBoxManage > /dev/null")
    running_vms = `VboxManage list runningvms`
    vm_ids = running_vms.scan(/({[^}]+})\n/).flatten # get all VM IDs
    # check all to see if any are Genymotion VMs
    vm_ids.each do |vm_id|
      genymotion_active = true if system("VBoxManage showvminfo #{vm_id} | grep -q Genymotion")
    end
  end

  # Return our findings
  genymotion_active
end