Module: Osaka::LaunchServices

Defined in:
lib/osaka/launchservices.rb

Class Method Summary collapse

Class Method Details

.dumpObject



5
6
7
# File 'lib/osaka/launchservices.rb', line 5

def self.dump
  Osaka::CommandRunner.run("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump")
end

.retrieve(bundle_name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/osaka/launchservices.rb', line 9

def self.retrieve(bundle_name)
  launch_services_dump = Osaka::CommandRunner.run("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump")
  current_hash = {}
  launch_services_hash = {}

  launch_services_dump.each_line do |line|
    if line =~ /^(\w.*):\s+(\w.*)$/
      launch_services_hash[current_hash[:name]] = current_hash
      current_hash = {:id => $2}
    end
    if line =~ /^\t(\w.*):\s+(\w.*)$/
      current_hash[$1.to_sym] = $2
      #puts current_hash
    end
  end
  launch_services_hash[current_hash[:name]] = current_hash
  launch_services_hash[bundle_name]
end