Skip to content

Commit

Permalink
Merge pull request #586 from Homebrew/remove_generate_plist
Browse files Browse the repository at this point in the history
formula_wrapper: remove generate_plist.
  • Loading branch information
MikeMcQuaid committed Sep 25, 2023
2 parents 221a5b3 + 0fbeedc commit 6efa53e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
23 changes: 0 additions & 23 deletions lib/service/formula_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,6 @@ def exit_code
return Regexp.last_match(1).to_i if status =~ exit_code_regex
end

# Generate that plist file, dude.
def generate_plist(data = nil)
data ||= service_file.file? ? service_file : formula.plist

if data.respond_to?(:file?) && data.file?
data = data.read
elsif !data
odie "Could not read the plist for `#{name}`!"
end

# Replace "template" variables and ensure label is always, always #service_name
data = data.to_s.gsub(/\{\{([a-z][a-z0-9_]*)\}\}/i) do |_|
formula.send(Regexp.last_match(1)).to_s if formula.respond_to?(Regexp.last_match(1))
end.gsub(%r{(<key>Label</key>\s*<string>)[^<]*(</string>)}, "\\1#{service_name}\\2")

# Always remove the "UserName" as it doesn't work since 10.11.5
if data.include?("<key>UserName</key>")
data = data.gsub(%r{(<key>UserName</key>\s*<string>)[^<]*(</string>)}, "")
end

data
end

def to_hash
hash = {
name: name,
Expand Down
12 changes: 0 additions & 12 deletions spec/homebrew/formula_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,6 @@
end
end

describe "#generate_plist?" do
it "macOS - outputs error for plist" do
allow(Service::System).to receive(:launchctl?).and_return(true)
allow(Service::System).to receive(:systemctl?).and_return(false)
allow(described_class).to receive(:service_file_present?).and_return(false)
allow(described_class).to receive(:service?).and_return(false)
expect do
service.generate_plist(nil)
end.to raise_error TestExit, "Could not read the plist for `mysql`!"
end
end

describe "#to_hash" do
it "represents non-service values" do
allow(Service::System).to receive(:launchctl?).and_return(true)
Expand Down

0 comments on commit 6efa53e

Please sign in to comment.