Use () as delimiters for %Q and %q literals.
This commit is contained in:
parent
1a0f8b8a02
commit
8e9eae695a
@ -31,7 +31,7 @@ module Hbc
|
|||||||
print_stderr: false).stdout.sub(/\A\((.*)\)\Z/, '\1')
|
print_stderr: false).stdout.sub(/\A\((.*)\)\Z/, '\1')
|
||||||
odebug "Existing metadata is: '#{altnames}'"
|
odebug "Existing metadata is: '#{altnames}'"
|
||||||
altnames.concat(", ") unless altnames.empty?
|
altnames.concat(", ") unless altnames.empty?
|
||||||
altnames.concat(%Q{"#{altname}"})
|
altnames.concat(%Q("#{altname}"))
|
||||||
altnames = "(#{altnames})"
|
altnames = "(#{altnames})"
|
||||||
|
|
||||||
# Some packges are shipped as u=rx (e.g. Bitcoin Core)
|
# Some packges are shipped as u=rx (e.g. Bitcoin Core)
|
||||||
|
|||||||
@ -87,7 +87,7 @@ module Hbc
|
|||||||
def warn_for_unknown_directives(directives)
|
def warn_for_unknown_directives(directives)
|
||||||
unknown_keys = directives.keys - ORDERED_DIRECTIVES
|
unknown_keys = directives.keys - ORDERED_DIRECTIVES
|
||||||
return if unknown_keys.empty?
|
return if unknown_keys.empty?
|
||||||
opoo %Q{Unknown arguments to #{stanza} -- #{unknown_keys.inspect}. Running "brew update; brew cleanup; brew cask cleanup" will likely fix it.}
|
opoo %Q(Unknown arguments to #{stanza} -- #{unknown_keys.inspect}. Running "brew update; brew cleanup; brew cask cleanup" will likely fix it.)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Preserve prior functionality of script which runs first. Should rarely be needed.
|
# Preserve prior functionality of script which runs first. Should rarely be needed.
|
||||||
@ -129,7 +129,7 @@ module Hbc
|
|||||||
ohai "Quitting application ID #{id}"
|
ohai "Quitting application ID #{id}"
|
||||||
num_running = count_running_processes(id)
|
num_running = count_running_processes(id)
|
||||||
next unless num_running > 0
|
next unless num_running > 0
|
||||||
@command.run!("/usr/bin/osascript", args: ["-e", %Q{tell application id "#{id}" to quit}], sudo: true)
|
@command.run!("/usr/bin/osascript", args: ["-e", %Q(tell application id "#{id}" to quit)], sudo: true)
|
||||||
sleep 3
|
sleep 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -156,13 +156,13 @@ module Hbc
|
|||||||
|
|
||||||
def count_running_processes(bundle_id)
|
def count_running_processes(bundle_id)
|
||||||
@command.run!("/usr/bin/osascript",
|
@command.run!("/usr/bin/osascript",
|
||||||
args: ["-e", %Q{tell application "System Events" to count processes whose bundle identifier is "#{bundle_id}"}],
|
args: ["-e", %Q(tell application "System Events" to count processes whose bundle identifier is "#{bundle_id}")],
|
||||||
sudo: true).stdout.to_i
|
sudo: true).stdout.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_unix_pids(bundle_id)
|
def get_unix_pids(bundle_id)
|
||||||
pid_string = @command.run!("/usr/bin/osascript",
|
pid_string = @command.run!("/usr/bin/osascript",
|
||||||
args: ["-e", %Q{tell application "System Events" to get the unix id of every process whose bundle identifier is "#{bundle_id}"}],
|
args: ["-e", %Q(tell application "System Events" to get the unix id of every process whose bundle identifier is "#{bundle_id}")],
|
||||||
sudo: true).stdout.chomp
|
sudo: true).stdout.chomp
|
||||||
return [] unless pid_string =~ /\A\d+(?:\s*,\s*\d+)*\Z/ # sanity check
|
return [] unless pid_string =~ /\A\d+(?:\s*,\s*\d+)*\Z/ # sanity check
|
||||||
pid_string.split(/\s*,\s*/).map(&:strip).map(&:to_i)
|
pid_string.split(/\s*,\s*/).map(&:strip).map(&:to_i)
|
||||||
@ -172,7 +172,7 @@ module Hbc
|
|||||||
Array(directives[:login_item]).each do |name|
|
Array(directives[:login_item]).each do |name|
|
||||||
ohai "Removing login item #{name}"
|
ohai "Removing login item #{name}"
|
||||||
@command.run!("/usr/bin/osascript",
|
@command.run!("/usr/bin/osascript",
|
||||||
args: ["-e", %Q{tell application "System Events" to delete every login item whose name is "#{name}"}],
|
args: ["-e", %Q(tell application "System Events" to delete every login item whose name is "#{name}")],
|
||||||
sudo: false)
|
sudo: false)
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -266,7 +266,7 @@ module Hbc
|
|||||||
next unless klass.visible
|
next unless klass.visible
|
||||||
puts " #{klass.command_name.ljust(max_command_len)} #{_help_for(klass)}"
|
puts " #{klass.command_name.ljust(max_command_len)} #{_help_for(klass)}"
|
||||||
end
|
end
|
||||||
puts %Q{\nSee also "man brew-cask"}
|
puts %Q(\nSee also "man brew-cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
def help
|
def help
|
||||||
|
|||||||
@ -104,7 +104,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.locale_variables
|
def self.locale_variables
|
||||||
ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q{#{v}="#{ENV[v]}"} }.sort.join("\n")
|
ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.privileged_uid
|
def self.privileged_uid
|
||||||
@ -154,7 +154,7 @@ module Hbc
|
|||||||
|
|
||||||
def self.render_env_var(var)
|
def self.render_env_var(var)
|
||||||
if ENV.key?(var)
|
if ENV.key?(var)
|
||||||
%Q{#{var}="#{ENV[var]}"}
|
%Q(#{var}="#{ENV[var]}")
|
||||||
else
|
else
|
||||||
none_string
|
none_string
|
||||||
end
|
end
|
||||||
|
|||||||
@ -9,7 +9,7 @@ module Hbc
|
|||||||
cask_path = Hbc.path(cask_token)
|
cask_path = Hbc.path(cask_token)
|
||||||
odebug "Opening editor for Cask #{cask_token}"
|
odebug "Opening editor for Cask #{cask_token}"
|
||||||
unless cask_path.exist?
|
unless cask_path.exist?
|
||||||
raise CaskUnavailableError, %Q{#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask}
|
raise CaskUnavailableError, %Q(#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask)
|
||||||
end
|
end
|
||||||
exec_editor cask_path
|
exec_editor cask_path
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,7 @@ module Hbc
|
|||||||
|
|
||||||
class CaskAlreadyCreatedError < AbstractCaskErrorWithToken
|
class CaskAlreadyCreatedError < AbstractCaskErrorWithToken
|
||||||
def to_s
|
def to_s
|
||||||
%Q{A Cask for #{token} already exists. Run "brew cask cat #{token}" to see it.}
|
%Q(A Cask for #{token} already exists. Run "brew cask cat #{token}" to see it.)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -302,7 +302,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def zap
|
def zap
|
||||||
ohai %Q{Implied "brew cask uninstall #{@cask}"}
|
ohai %Q(Implied "brew cask uninstall #{@cask}")
|
||||||
uninstall_artifacts
|
uninstall_artifacts
|
||||||
if Artifact::Zap.me?(@cask)
|
if Artifact::Zap.me?(@cask)
|
||||||
ohai "Dispatching zap stanza"
|
ohai "Dispatching zap stanza"
|
||||||
|
|||||||
@ -2,6 +2,6 @@ module HashValidator
|
|||||||
def assert_valid_keys(*valid_keys)
|
def assert_valid_keys(*valid_keys)
|
||||||
unknown_keys = keys - valid_keys
|
unknown_keys = keys - valid_keys
|
||||||
return if unknown_keys.empty?
|
return if unknown_keys.empty?
|
||||||
raise CaskError, %Q{Unknown keys: #{unknown_keys.inspect}. Running "#{UPDATE_CMD}" will likely fix it.}
|
raise CaskError, %Q(Unknown keys: #{unknown_keys.inspect}. Running "#{UPDATE_CMD}" will likely fix it.)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -201,10 +201,10 @@ describe Hbc::Artifact::Uninstall do
|
|||||||
let(:bundle_id) { "my.fancy.package.app" }
|
let(:bundle_id) { "my.fancy.package.app" }
|
||||||
let(:count_processes_script) {
|
let(:count_processes_script) {
|
||||||
'tell application "System Events" to count processes ' +
|
'tell application "System Events" to count processes ' +
|
||||||
%Q{whose bundle identifier is "#{bundle_id}"}
|
%Q(whose bundle identifier is "#{bundle_id}")
|
||||||
}
|
}
|
||||||
let(:quit_application_script) {
|
let(:quit_application_script) {
|
||||||
%Q{tell application id "#{bundle_id}" to quit}
|
%Q(tell application id "#{bundle_id}" to quit)
|
||||||
}
|
}
|
||||||
|
|
||||||
it "can uninstall" do
|
it "can uninstall" do
|
||||||
@ -227,7 +227,7 @@ describe Hbc::Artifact::Uninstall do
|
|||||||
let(:unix_pids) { [12_345, 67_890] }
|
let(:unix_pids) { [12_345, 67_890] }
|
||||||
let(:get_unix_pids_script) {
|
let(:get_unix_pids_script) {
|
||||||
'tell application "System Events" to get the unix id of every process ' +
|
'tell application "System Events" to get the unix id of every process ' +
|
||||||
%Q{whose bundle identifier is "#{bundle_id}"}
|
%Q(whose bundle identifier is "#{bundle_id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
it "can uninstall" do
|
it "can uninstall" do
|
||||||
|
|||||||
@ -202,10 +202,10 @@ describe Hbc::Artifact::Zap do
|
|||||||
let(:bundle_id) { "my.fancy.package.app" }
|
let(:bundle_id) { "my.fancy.package.app" }
|
||||||
let(:count_processes_script) {
|
let(:count_processes_script) {
|
||||||
'tell application "System Events" to count processes ' +
|
'tell application "System Events" to count processes ' +
|
||||||
%Q{whose bundle identifier is "#{bundle_id}"}
|
%Q(whose bundle identifier is "#{bundle_id}")
|
||||||
}
|
}
|
||||||
let(:quit_application_script) {
|
let(:quit_application_script) {
|
||||||
%Q{tell application id "#{bundle_id}" to quit}
|
%Q(tell application id "#{bundle_id}" to quit)
|
||||||
}
|
}
|
||||||
|
|
||||||
it "can zap" do
|
it "can zap" do
|
||||||
@ -228,7 +228,7 @@ describe Hbc::Artifact::Zap do
|
|||||||
let(:unix_pids) { [12_345, 67_890] }
|
let(:unix_pids) { [12_345, 67_890] }
|
||||||
let(:get_unix_pids_script) {
|
let(:get_unix_pids_script) {
|
||||||
'tell application "System Events" to get the unix id of every process ' +
|
'tell application "System Events" to get the unix id of every process ' +
|
||||||
%Q{whose bundle identifier is "#{bundle_id}"}
|
%Q(whose bundle identifier is "#{bundle_id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
it "can zap" do
|
it "can zap" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user