fix a few bugs around recent changes
- re-added a lost nil guard on `Dmg` containers - `FakeSystemCommand` was still returning an array of split lines instead of a string, even though its real counterpart switched to string when install/uninstall landed - flushed out an alfred cli bug - moved plist parsing down to SystemCommand layer
This commit is contained in:
parent
711e44b405
commit
a9cd8e7101
|
@ -78,7 +78,7 @@ class Cask::CLI::Alfred
|
|||
end
|
||||
|
||||
def self.alfred_installed?
|
||||
alfred_preference('version').first =~ /^[0-9]\.[0-9]\.[0-9]$/
|
||||
alfred_preference('version') =~ /^[0-9]\.[0-9]\.[0-9]$/
|
||||
end
|
||||
|
||||
def self.linked?
|
||||
|
@ -95,7 +95,7 @@ class Cask::CLI::Alfred
|
|||
SCOPE_REGEXP = /^\s*"(.*)",?$/
|
||||
|
||||
def self.alfred_scopes
|
||||
scopes = alfred_preference(KEY).map do |line|
|
||||
scopes = alfred_preference(KEY).split("\n").map do |line|
|
||||
matchdata = line.match(SCOPE_REGEXP)
|
||||
matchdata ? matchdata.captures.first : nil
|
||||
end.compact
|
||||
|
|
|
@ -3,6 +3,7 @@ class Cask::Container::Dmg < Cask::Container::Base
|
|||
criteria.imageinfo != ''
|
||||
end
|
||||
|
||||
attr_reader :mounts
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@mounts = []
|
||||
|
@ -23,10 +24,14 @@ class Cask::Container::Dmg < Cask::Container::Base
|
|||
'mount',
|
||||
'-plist', '-nobrowse', '-readonly', '-noidme', '-mountrandom',
|
||||
'/tmp', @path
|
||||
])
|
||||
Plist::parse_xml(plist).fetch('system-entities', []).each do |entity|
|
||||
@mounts << entity['mount-point']
|
||||
end
|
||||
], :plist => true)
|
||||
@mounts = mounts_from_plist(plist)
|
||||
end
|
||||
|
||||
def mounts_from_plist(plist)
|
||||
plist.fetch('system-entities', []).map do |entity|
|
||||
entity['mount-point']
|
||||
end.compact
|
||||
end
|
||||
|
||||
def assert_mounts_found
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Cask::Pkg
|
||||
def self.all_matching(regexp, command)
|
||||
command.run(%Q(pkgutil --pkgs="#{regexp}")).map do |package_id|
|
||||
command.run(%Q(pkgutil --pkgs="#{regexp}")).split("\n").map do |package_id|
|
||||
new(package_id.chomp, command)
|
||||
end
|
||||
end
|
||||
|
@ -29,19 +29,26 @@ class Cask::Pkg
|
|||
end
|
||||
|
||||
def dirs
|
||||
_run('pkgutil', :args => ['--only-dirs', '--files', package_id]).map { |path| root.join(path) }
|
||||
@command.run('pkgutil',
|
||||
:args => ['--only-dirs', '--files', package_id]
|
||||
).split("\n").map { |path| root.join(path) }
|
||||
end
|
||||
|
||||
def files
|
||||
_run('pkgutil', :args => ['--only-files', '--files', package_id]).map { |path| root.join(path) }
|
||||
@command.run('pkgutil',
|
||||
:args => ['--only-files', '--files', package_id]
|
||||
).split("\n").map { |path| root.join(path) }
|
||||
end
|
||||
|
||||
def root
|
||||
@root ||= Pathname(info['volume']).join(info['install-location'])
|
||||
@root ||= Pathname(info.fetch('volume')).join(info.fetch('install-location'))
|
||||
end
|
||||
|
||||
def info
|
||||
@info ||= Plist::parse_xml(_run('pkgutil', :args => ['--pkg-info-plist', package_id]).join("\n"))
|
||||
@command.run('pkgutil',
|
||||
:args => ['--pkg-info-plist', package_id],
|
||||
:plist => true
|
||||
)
|
||||
end
|
||||
|
||||
def _deepest_path_first(paths)
|
||||
|
@ -50,10 +57,6 @@ class Cask::Pkg
|
|||
end
|
||||
end
|
||||
|
||||
def _run(command, options={})
|
||||
@command.run(command, options).map(&:chomp)
|
||||
end
|
||||
|
||||
def _clean_symlinks(dir)
|
||||
# Some pkgs leave broken symlinks hanging around; we clean them out before
|
||||
# attempting to rmdir to prevent extra cruft from lying around after
|
||||
|
|
|
@ -12,7 +12,11 @@ class Cask::SystemCommand
|
|||
ohai line.chomp if options[:print]
|
||||
end
|
||||
end
|
||||
output
|
||||
if options[:plist]
|
||||
Plist::parse_xml(output)
|
||||
else
|
||||
output
|
||||
end
|
||||
end
|
||||
|
||||
def self._process_options(command, options)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
describe Cask::Container::Dmg do
|
||||
describe "mount!" do
|
||||
it "does not store nil mounts for dmgs with extra data" do
|
||||
transmission = Cask.load('local-transmission')
|
||||
|
||||
dmg = Cask::Container::Dmg.new(
|
||||
transmission,
|
||||
Pathname(transmission.url.path),
|
||||
Cask::SystemCommand
|
||||
)
|
||||
|
||||
begin
|
||||
dmg.mount!
|
||||
dmg.mounts.wont_include nil
|
||||
ensure
|
||||
dmg.eject!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -25,7 +25,11 @@ class Cask::FakeSystemCommand
|
|||
fail("no response faked for #{command.inspect}, faked responses are: #{@responses.inspect}")
|
||||
end
|
||||
@system_calls[command] += 1
|
||||
@responses[command].split("\n")
|
||||
if options[:plist]
|
||||
Plist::parse_xml(@responses[command])
|
||||
else
|
||||
@responses[command]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue