Class: RunLoop::App
- Inherits:
-
Object
- Object
- RunLoop::App
- Defined in:
- lib/run_loop/app.rb
Overview
A class for interacting with .app bundles.
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The path to the app bundle .app.
Instance Method Summary collapse
-
#bundle_identifier ⇒ String
Inspects the app’s Info.plist for the bundle identifier.
-
#calabash_server_version ⇒ Object
Inspects the app’s file for the server version.
-
#executable_name ⇒ String
Inspects the app’s Info.plist for the executable name.
-
#info_plist_path ⇒ Object
Returns the Info.plist path.
-
#initialize(app_bundle_path) ⇒ RunLoop::App
constructor
Creates a new App instance.
-
#sha1 ⇒ Object
Returns the sha1 of the application.
-
#valid? ⇒ Boolean
Is this a valid app?.
Constructor Details
#initialize(app_bundle_path) ⇒ RunLoop::App
Note:
The ‘app_bundle_path` is expanded during initialization.
Creates a new App instance.
15 16 17 |
# File 'lib/run_loop/app.rb', line 15 def initialize(app_bundle_path) @path = File.(app_bundle_path) end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns The path to the app bundle .app.
7 8 9 |
# File 'lib/run_loop/app.rb', line 7 def path @path end |
Instance Method Details
#bundle_identifier ⇒ String
Inspects the app’s Info.plist for the bundle identifier.
50 51 52 53 54 55 56 |
# File 'lib/run_loop/app.rb', line 50 def bundle_identifier identifier = plist_buddy.plist_read('CFBundleIdentifier', info_plist_path) unless identifier raise "Expected key 'CFBundleIdentifier' in '#{info_plist_path}'" end identifier end |
#calabash_server_version ⇒ Object
Inspects the app’s file for the server version
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/run_loop/app.rb', line 71 def calabash_server_version if valid? path_to_bin = File.join(path, executable_name) xcrun ||= RunLoop::Xcrun.new hash = xcrun.exec(["strings", path_to_bin]) unless hash.nil? version_str = hash[:out][/CALABASH VERSION: \d+\.\d+\.\d+/, 0] unless version_str.nil? || version_str == "" server_ver = version_str.split(":")[1].delete(' ') RunLoop::Version.new(server_ver) end end else raise 'Path is not valid' end end |
#executable_name ⇒ String
Inspects the app’s Info.plist for the executable name.
62 63 64 65 66 67 68 |
# File 'lib/run_loop/app.rb', line 62 def executable_name identifier = plist_buddy.plist_read('CFBundleExecutable', info_plist_path) unless identifier raise "Expected key 'CFBundleExecutable' in '#{info_plist_path}'" end identifier end |
#info_plist_path ⇒ Object
Returns the Info.plist path.
38 39 40 41 42 43 44 |
# File 'lib/run_loop/app.rb', line 38 def info_plist_path info_plist = File.join(path, 'Info.plist') unless File.exist?(info_plist) raise "Expected an Info.plist at '#{path}'" end info_plist end |
#sha1 ⇒ Object
Returns the sha1 of the application.
89 90 91 |
# File 'lib/run_loop/app.rb', line 89 def sha1 RunLoop::Directory.directory_digest(path) end |
#valid? ⇒ Boolean
Is this a valid app?
30 31 32 33 34 |
# File 'lib/run_loop/app.rb', line 30 def valid? [File.exist?(path), File.directory?(path), File.extname(path) == '.app'].all? end |