Class: Calasmash::Runner
- Inherits:
-
Object
- Object
- Calasmash::Runner
- Defined in:
- lib/calasmash.rb
Instance Method Summary collapse
- #app_path ⇒ Object
- #compile ⇒ Object
-
#initialize(args) ⇒ Runner
constructor
A new instance of Runner.
- #parse(args) ⇒ Object
- #plist_path ⇒ Object
- #run_cucumber ⇒ Object
- #start ⇒ Object
- #update_plist ⇒ Object
- #validate_options(options) ⇒ Object
Constructor Details
#initialize(args) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 |
# File 'lib/calasmash.rb', line 11 def initialize(args) = parse(args) if [:valid] start end end |
Instance Method Details
#app_path ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/calasmash.rb', line 101 def app_path files = [] Find.find("#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/") do |path| files << path if path =~ /#{@options[:scheme]}.app$/ end app_path = files.sort_by { |filename| File.mtime(filename)}.last # get the latest return app_path end |
#compile ⇒ Object
68 69 70 71 72 73 |
# File 'lib/calasmash.rb', line 68 def compile puts "Compiling..." IO.popen("xcodebuild -workspace #{@options[:workspace]} -scheme #{@options[:scheme]} -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO") {|output| puts output.read } end |
#parse(args) ⇒ Object
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 |
# File 'lib/calasmash.rb', line 26 def parse(args) = {} @opt_parser = OptionParser.new do |opt| opt. = "Usage: calasmash [OPTIONS]" opt.separator "" opt.separator "Options" opt.on("-t","--tags TAGS","the tags to test against") do || [:tags] = end opt.on("-w","--workspace WORKSPACE","the workspace to build") do || [:workspace] = end opt.on("-s","--scheme SCHEME","the scheme to build") do || [:scheme] = end opt.on("-h","--help","help") do puts @opt_parser end end @opt_parser.parse! args [:valid] = true () end |
#plist_path ⇒ Object
113 114 115 116 117 |
# File 'lib/calasmash.rb', line 113 def plist_path plist_path = app_path + "/server_config.plist" return plist_path end |
#run_cucumber ⇒ Object
94 95 96 97 98 99 |
# File 'lib/calasmash.rb', line 94 def run_cucumber puts "Running cucumber..." IO.popen("cucumber OS=ios7 SDK_VERSION=7.0 DEVICE_TARGET=simulator --tags #{@options[:tags]}") {|output| puts output.read } end |
#start ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/calasmash.rb', line 18 def start puts "Starting..." compile update_plist sleep(2) run_cucumber end |
#update_plist ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/calasmash.rb', line 75 def update_plist puts "Updating plist..." ip = Socket.ip_address_list.find {|a| a.ipv4? && !a.ipv4_loopback?}.ip_address port = 4567 #sinatras default port plist_file = CFPropertyList::List.new(:file => plist_path) plist = CFPropertyList.native_types(plist_file.value) plist["url_preference"] = ip plist["port_preference"] = port puts("plist: #{plist}") plist_file.value = CFPropertyList.guess(plist) plist_file.save(plist_path, CFPropertyList::List::FORMAT_XML) end |
#validate_options(options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/calasmash.rb', line 57 def () if [:workspace].nil? puts "Workspace path required, see --help for more information" [:valid] = false elsif [:scheme].nil? puts "Scheme required, see --help for more information" [:valid] = false end end |