Class: Xcselect::XcApp
- Inherits:
-
Object
- Object
- Xcselect::XcApp
- Includes:
- Comparable
- Defined in:
- lib/xcselect/xcapp.rb
Instance Attribute Summary collapse
-
#info_plist ⇒ Object
readonly
Returns the value of attribute info_plist.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.all_apps ⇒ Object
all applications for all simulator versions, unsorted.
-
.all_newsstand_apps ⇒ Object
every newsstand application.
-
.app_support_folder ⇒ Object
the iPhone Simulator support folder.
- .last_built_app ⇒ Object
- .last_built_newsstand_app ⇒ Object
- .sort_by_touch_time(array) ⇒ Object
Instance Method Summary collapse
- #<=>(o) ⇒ Object
- #[](k) ⇒ Object
- #base_dir ⇒ Object
- #bundle_id ⇒ Object
- #cache_path ⇒ Object
- #documents_path ⇒ Object
-
#initialize(path) ⇒ XcApp
constructor
A new instance of XcApp.
- #last_build_time ⇒ Object
- #name ⇒ Object
- #newsstand? ⇒ Boolean
-
#newsstand_issue_paths ⇒ Object
all directories in newsstand folder.
-
#newsstand_objects ⇒ Object
Returns a hash of NKIssues in the form {“issue_name” => path }.
-
#newsstand_path ⇒ Object
path to the app’s root newsstand folder.
- #oomph_app? ⇒ Boolean
- #plist_path ⇒ Object
- #read_bin_plist_to_xml(plist_path) ⇒ Object
- #read_plist(plist_path) ⇒ Object
- #sim_version ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ XcApp
Returns a new instance of XcApp.
13 14 15 16 |
# File 'lib/xcselect/xcapp.rb', line 13 def initialize(path) @path = path @info_plist = JSON.parse read_plist(plist_path) end |
Instance Attribute Details
#info_plist ⇒ Object (readonly)
Returns the value of attribute info_plist.
11 12 13 |
# File 'lib/xcselect/xcapp.rb', line 11 def info_plist @info_plist end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/xcselect/xcapp.rb', line 10 def path @path end |
Class Method Details
.all_apps ⇒ Object
all applications for all simulator versions, unsorted
116 117 118 |
# File 'lib/xcselect/xcapp.rb', line 116 def self.all_apps Dir["#{app_support_folder}/**/*.app"].map{|a| XcApp.new a } end |
.all_newsstand_apps ⇒ Object
every newsstand application
121 122 123 |
# File 'lib/xcselect/xcapp.rb', line 121 def self.all_newsstand_apps self.all_apps.select(&:newsstand?) end |
.app_support_folder ⇒ Object
the iPhone Simulator support folder
111 112 113 |
# File 'lib/xcselect/xcapp.rb', line 111 def self.app_support_folder File.("~/Library/Application Support/iPhone Simulator/") end |
.last_built_app ⇒ Object
133 134 135 |
# File 'lib/xcselect/xcapp.rb', line 133 def self.last_built_app XcApp.sort_by_touch_time(all_apps).last end |
.last_built_newsstand_app ⇒ Object
125 126 127 |
# File 'lib/xcselect/xcapp.rb', line 125 def self.last_built_newsstand_app all_newsstand_apps.sort_by{|e| e.last_build_time }.last end |
.sort_by_touch_time(array) ⇒ Object
129 130 131 |
# File 'lib/xcselect/xcapp.rb', line 129 def self.sort_by_touch_time array array.sort_by{|e| e.last_build_time } end |
Instance Method Details
#<=>(o) ⇒ Object
22 23 24 25 |
# File 'lib/xcselect/xcapp.rb', line 22 def <=>(o) result = sim_version.to_f <=> o.sim_version.to_f (!result.zero?) ? result : name <=> o.name end |
#[](k) ⇒ Object
31 32 33 |
# File 'lib/xcselect/xcapp.rb', line 31 def [](k) @info_plist[k] end |
#base_dir ⇒ Object
35 36 37 |
# File 'lib/xcselect/xcapp.rb', line 35 def base_dir File.dirname path end |
#bundle_id ⇒ Object
39 40 41 |
# File 'lib/xcselect/xcapp.rb', line 39 def bundle_id self['CFBundleIdentifier'] end |
#cache_path ⇒ Object
63 64 65 |
# File 'lib/xcselect/xcapp.rb', line 63 def cache_path "#{base_dir}/Library/Caches" end |
#documents_path ⇒ Object
59 60 61 |
# File 'lib/xcselect/xcapp.rb', line 59 def documents_path "#{base_dir}/Documents" end |
#last_build_time ⇒ Object
104 105 106 |
# File 'lib/xcselect/xcapp.rb', line 104 def last_build_time File.mtime path end |
#name ⇒ Object
43 44 45 |
# File 'lib/xcselect/xcapp.rb', line 43 def name self['CFBundleName'] end |
#newsstand? ⇒ Boolean
71 72 73 |
# File 'lib/xcselect/xcapp.rb', line 71 def newsstand? self['UINewsstandApp'] || false end |
#newsstand_issue_paths ⇒ Object
all directories in newsstand folder
95 96 97 98 99 100 101 102 |
# File 'lib/xcselect/xcapp.rb', line 95 def newsstand_issue_paths #TODO: make this read the newsstand db and return a hash of names/paths if oomph_app? Dir["#{newsstand_path}/*-*/*"] else Dir["#{newsstand_path}/*-*"] end end |
#newsstand_objects ⇒ Object
Returns a hash of NKIssues in the form {“issue_name” => path }
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/xcselect/xcapp.rb', line 76 def newsstand_objects issues = NKIssue.parse "#{base_dir}/Library/Application Support/com.apple.newsstand-library.plist" return issues unless newsstand? paths = newsstand_issue_paths if oomph_app? issues.values.each do |issue| issue.content_path = "#{newsstand_path}/#{issue.uuid}" issue.content_path = paths.select{|p| p[issue.uuid] }.last if oomph_app? end return issues end |
#newsstand_path ⇒ Object
path to the app’s root newsstand folder
90 91 92 |
# File 'lib/xcselect/xcapp.rb', line 90 def newsstand_path "#{base_dir}/Library/Caches/Newsstand" end |
#oomph_app? ⇒ Boolean
67 68 69 |
# File 'lib/xcselect/xcapp.rb', line 67 def oomph_app? File.exists? "#{path}/Oomph.plist" end |
#plist_path ⇒ Object
55 56 57 |
# File 'lib/xcselect/xcapp.rb', line 55 def plist_path Dir[@path + "/*Info.plist"].first end |
#read_bin_plist_to_xml(plist_path) ⇒ Object
51 52 53 |
# File 'lib/xcselect/xcapp.rb', line 51 def read_bin_plist_to_xml plist_path `plutil -convert xml1 -o - '#{plist_path}'` end |
#read_plist(plist_path) ⇒ Object
47 48 49 |
# File 'lib/xcselect/xcapp.rb', line 47 def read_plist plist_path `plutil -convert json -o - '#{plist_path}'` end |
#sim_version ⇒ Object
27 28 29 |
# File 'lib/xcselect/xcapp.rb', line 27 def sim_version path.split('/')[-4] end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/xcselect/xcapp.rb', line 18 def to_s "#{name} (#{sim_version})" end |