Permalink
Browse files

expose SimLauncher.check_app_path for use by gem clients

  • Loading branch information...
moredip committed Sep 28, 2012
1 parent b29af37 commit c56c3f89d938f7c64d224caca588fe78fc25a33f
Showing with 25 additions and 23 deletions.
  1. +23 −0 lib/sim_launcher.rb
  2. +1 −22 lib/sim_launcher/simulator.rb
  3. +1 −1 lib/sim_launcher/version.rb
View
@@ -2,3 +2,26 @@
require 'sim_launcher/direct_client'
require 'sim_launcher/simulator'
require 'sim_launcher/sdk_detector'
+
+module SimLauncher
+ def self.check_app_path( app_path )
+ unless File.exists?( app_path )
+ return "The specified app path doesn't seem to exist: #{app_path}"
+ end
+
+ unless File.directory? app_path
+ file_appears_to_be_a_binary = !!( `file "#{app_path}"` =~ /Mach-O executable/ )
+ if file_appears_to_be_a_binary
+ return <<-EOS
+ The specified app path is a binary executable, rather than a directory. You need to provide the path to the app *bundle*, not the app executable itself.
+ The path you specified was: #{app_path}
+ You might want to instead try specifying: #{File.dirname(app_path)}
+ EOS
+ else
+ return "The specified app path is not a directory. You need to provide the path to your app bundle.\nSpecified app path was: #{app_path}"
+ end
+ end
+
+ nil
+ end
+end
@@ -5,33 +5,12 @@ def initialize( iphonesim_path_external = nil )
@iphonesim_path = iphonesim_path_external || iphonesim_path(xcode_version)
end
- def check_app_path( app_path )
- unless File.exists?( app_path )
- return "The specified app path doesn't seem to exist: #{app_path}"
- end
-
- unless File.directory? app_path
- file_appears_to_be_a_binary = !!( `file "#{app_path}"` =~ /Mach-O executable/ )
- if file_appears_to_be_a_binary
- return <<-EOS
- The specified app path is a binary executable, rather than a directory. You need to provide the path to the app *bundle*, not the app executable itself.
- The path you specified was: #{app_path}
- You might want to instead try specifying: #{File.dirname(app_path)}
- EOS
- else
- return "The specified app path is not a directory. You need to provide the path to your app bundle.\nSpecified app path was: #{app_path}"
- end
- end
-
- nil
- end
-
def showsdks
run_synchronous_command( 'showsdks' )
end
def launch_ios_app(app_path, sdk_version, device_family)
- if problem = check_app_path( app_path )
+ if problem = SimLauncher.check_app_path( app_path )
bangs = '!'*80
raise "\n#{bangs}\nENCOUNTERED A PROBLEM WITH THE SPECIFIED APP PATH:\n\n#{problem}\n#{bangs}"
end
@@ -1,3 +1,3 @@
module SimLauncher
- VERSION = "0.4.5"
+ VERSION = "0.4.6"
end

0 comments on commit c56c3f8

Please sign in to comment.