xcselect 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/xcsim CHANGED
@@ -15,10 +15,13 @@ class Main
15
15
  optparse = OptionParser.new do |opts|
16
16
  opts.on('-h', '--help', "Display this !!") { puts opts; exit }
17
17
  opts.on('-v', '--version', "Print version info") { puts "xcselect-" + VERSION; exit; }
18
+
18
19
  opts.on('-p', '--print', "print the path instead of opening it") { @options[:print] = true }
20
+ opts.on('-c', '--cd', "cd into the directory (spawns new shell, type `exit` to return) ") { @options[:print] = false; @options[:cd] = true }
21
+
22
+ opts.on('-a', '--apps' , "Show list of apps") { show_apps(); exit }
19
23
  opts.on('-d', '--latest-documents' , "Reveal last built app's documents folder") { show_latest_docs() ;exit}
20
24
  opts.on('-n', '--latest-newsstand' , "Show list of newsstand issues for last built app") { show_latest_newsstand(); exit }
21
- opts.on('-a', '--apps' , "Show list of apps") { show_apps(); exit }
22
25
  end
23
26
  begin
24
27
  optparse.parse!
@@ -34,7 +37,12 @@ class Main
34
37
  end
35
38
 
36
39
  def open_path p
37
- if @options[:print]
40
+ if @options[:cd]
41
+ # this will allow you to go into the folder
42
+ # then type exit to return to your parent shell
43
+ Dir.chdir p
44
+ exec ENV['SHELL']
45
+ elsif @options[:print]
38
46
  puts p
39
47
  else
40
48
  `open -R "#{p}"`
@@ -44,6 +52,7 @@ class Main
44
52
  def select_menu title, selections
45
53
  i = 0
46
54
  puts title
55
+ puts ""
47
56
  selections.each do |opt|
48
57
  i += 1
49
58
  puts " [#{i}] #{opt}"
@@ -78,7 +87,7 @@ class Main
78
87
  open_path ns_issues.last[issue_names.last]
79
88
  return
80
89
  end
81
- select_menu("Select issue in #{latest_app.name} to open:", issue_names) {|i|
90
+ select_menu("Select issue in #{latest_app} to open:", issue_names) {|i|
82
91
  open_path ns_issues.values[i]
83
92
  }
84
93
 
@@ -1,3 +1,3 @@
1
1
  module Xcselect
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -68,17 +68,29 @@ module Xcselect
68
68
  end
69
69
 
70
70
  def newsstand_objects
71
- ppath = "#{base_dir}/Library/Application Support/com.apple.newsstand-library.plist"
72
- ns_plist = Plist::parse_xml(read_bin_plist_to_xml(ppath))
73
- items = ns_plist['$objects'].select{|o| o.class == String && ["$null","issues"].index(o).nil? }
74
- hash = {}
75
- paths = newsstand_issue_paths
76
- items.each_slice(2) {|name,uuid|
77
- uuid = newsstand_path if uuid.nil?
78
- hash[name] = paths.select{|p| p[uuid] }.last
79
- hash[name] = File.dirname hash[name] unless oomph_app?
80
- }
81
- return hash
71
+ issues = {}
72
+ return issues unless newsstand?
73
+ # this is an NSKeyedArchiver plist
74
+ ns_plist = Plist::parse_xml(read_bin_plist_to_xml("#{base_dir}/Library/Application Support/com.apple.newsstand-library.plist"))
75
+
76
+ # this is the integer that we will use to filter all archived nkissue objects
77
+ nk_issue_key = ns_plist['$objects'].index(ns_plist['$objects'].select{|o| o['$classname'] == "NKIssue"}.last)
78
+
79
+ # filter just the nkissue hashes
80
+ obj_key_hashs = ns_plist['$objects'].select{|o| o.class == Hash && o['$class'] && nk_issue_key == o['$class']['CF$UID'] }
81
+ object_array = ns_plist['$objects']
82
+
83
+ # load these paths as our apps have 1 folder inside the newsstand folders
84
+ paths = newsstand_issue_paths if oomph_app?
85
+
86
+ obj_key_hashs.each do |nskey|
87
+ name = object_array[nskey['name']['CF$UID']]
88
+ uuid = object_array[nskey['directory']['CF$UID']]
89
+ next if name.nil?
90
+ issues[name] = "#{newsstand_path}/#{uuid}"
91
+ issues[name] = paths.select{|p| p[uuid] }.last if oomph_app? # specially for me :)
92
+ end
93
+ return issues
82
94
  end
83
95
 
84
96
  def newsstand_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcselect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: