#!/usr/bin/env ruby require 'rubygems' require 'fileutils' def print_usage puts < where can be one of install installs Frank-Calabash by coping libFrankCalabash.a into Frank/plugins/calabash uninstall uninstalls Frank.Calabash by removing Frank/plugins/calabash console starts the Frank console prepared for Calabash: use c = calabash_client to obtain a Calabash client. Use launch to launch using instruments. EOF end FRANK_DIR = 'Frank' PLUGIN_DIR = File.join(FRANK_DIR, 'plugins') CAL_PLUGIN_DIR = File.join(PLUGIN_DIR, 'calabash') XCCONFIG = File.join(File.dirname(__FILE__), '..', 'scripts', 'calabash.xcconfig.erb') LIB_FRANK_CAL = File.join(File.dirname(__FILE__), '..', 'staticlib', 'libFrankCalabash.a') def check_frank_exists unless File.directory?(FRANK_DIR) puts "Unable to find #{FRANK_DIR} directory (in #{Dir.pwd})" puts "Please make sure you've run frank setup." exit(false) end end def install_frank_plugin check_frank_exists unless File.directory?(PLUGIN_DIR) puts "Unable to find #{PLUGIN_DIR} directory (in #{Dir.pwd})" puts "Please make sure you've running the latest version of Frank." puts 'Try rerunning frank setup.' exit(false) end if File.exist?(CAL_PLUGIN_DIR) puts 'Clearing Calabash plugin...' FileUtils.rm_f(CAL_PLUGIN_DIR) end puts "Creating directory #{CAL_PLUGIN_DIR}" FileUtils.mkdir_p CAL_PLUGIN_DIR FileUtils.cp([LIB_FRANK_CAL, XCCONFIG], CAL_PLUGIN_DIR) puts "Copied files #{Dir[File.join(CAL_PLUGIN_DIR,'*')].join(', ')}" puts "\nInstalled Frank-Calabash plugin." puts 'Please rebuild using frank build.' end def uninstall_frank_plugin check_frank_exists if File.directory?(CAL_PLUGIN_DIR) puts 'Found Calabash plugin...' puts "Deleting #{CAL_PLUGIN_DIR}" FileUtils.rm_f CAL_PLUGIN_DIR puts 'Uninstalled Calabash plugin. Please rebuild.' end end def console require 'frank-cucumber/console' require 'frank-calabash' require 'calabash-cucumber/operations' require 'pry' ENV['CALABASH_VERSION_PATH']='calabash_version' console = Frank::Console.new console.extend ::Frank::Calabash def console.embed(*args) end console.pry end unless ARGV.length == 1 print_usage exit(false) end cmd = ARGV.shift case cmd when 'install' install_frank_plugin when 'uninstall' uninstall_frank_plugin when 'console' console else puts "Unsupported command #{cmd}" exit(false) end