Fixup more frozen string handling.
This commit is contained in:
		
							parent
							
								
									36dbad3922
								
							
						
					
					
						commit
						fc6bd2ea1c
					
				@ -94,10 +94,10 @@ module Cask
 | 
			
		||||
              sleep 1
 | 
			
		||||
            end
 | 
			
		||||
            paths = [
 | 
			
		||||
              "/Library/LaunchAgents/#{service}.plist",
 | 
			
		||||
              "/Library/LaunchDaemons/#{service}.plist",
 | 
			
		||||
              +"/Library/LaunchAgents/#{service}.plist",
 | 
			
		||||
              +"/Library/LaunchDaemons/#{service}.plist",
 | 
			
		||||
            ]
 | 
			
		||||
            paths.each { |elt| elt.prepend(ENV["HOME"]) } unless with_sudo
 | 
			
		||||
            paths.each { |elt| elt.prepend(ENV["HOME"]).freeze } unless with_sudo
 | 
			
		||||
            paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
 | 
			
		||||
            paths.each do |path|
 | 
			
		||||
              command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo)
 | 
			
		||||
 | 
			
		||||
@ -61,8 +61,7 @@ module Cask
 | 
			
		||||
        if matches.one?
 | 
			
		||||
          "Did you mean “#{matches.first}”?"
 | 
			
		||||
        elsif !matches.empty?
 | 
			
		||||
          "Did you mean one of these?\n"
 | 
			
		||||
            .concat(Formatter.columns(matches.take(20)))
 | 
			
		||||
          "Did you mean one of these?\n#{Formatter.columns(matches.take(20))}"
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -12,9 +12,9 @@ module Cask
 | 
			
		||||
      def run
 | 
			
		||||
        exec_editor cask_path
 | 
			
		||||
      rescue CaskUnavailableError => e
 | 
			
		||||
        reason = e.reason.empty? ? "" : "#{e.reason} "
 | 
			
		||||
        reason = e.reason.empty? ? +"" : +"#{e.reason} "
 | 
			
		||||
        reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.")
 | 
			
		||||
        raise e.class.new(e.token, reason)
 | 
			
		||||
        raise e.class.new(e.token, reason.freeze)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def cask_path
 | 
			
		||||
 | 
			
		||||
@ -106,14 +106,14 @@ module Cask
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def self.artifact_info(cask)
 | 
			
		||||
        artifact_output = ohai_title("Artifacts")
 | 
			
		||||
        artifact_output = ohai_title("Artifacts").dup
 | 
			
		||||
        cask.artifacts.each do |artifact|
 | 
			
		||||
          next unless artifact.respond_to?(:install_phase)
 | 
			
		||||
          next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
 | 
			
		||||
 | 
			
		||||
          artifact_output << "\n" << artifact.to_s
 | 
			
		||||
        end
 | 
			
		||||
        artifact_output
 | 
			
		||||
        artifact_output.freeze
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -138,9 +138,10 @@ module Cask
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def summary
 | 
			
		||||
      s = ""
 | 
			
		||||
      s = +""
 | 
			
		||||
      s << "#{Emoji.install_badge}  " if Emoji.enabled?
 | 
			
		||||
      s << "#{@cask} was successfully #{upgrade? ? "upgraded" : "installed"}!"
 | 
			
		||||
      s.freeze
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def download
 | 
			
		||||
 | 
			
		||||
@ -42,7 +42,7 @@ class Caveats
 | 
			
		||||
        #{f.name} is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX},
 | 
			
		||||
        because #{f.keg_only_reason.to_s.chomp}.
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
    end.dup
 | 
			
		||||
 | 
			
		||||
    if f.bin.directory? || f.sbin.directory?
 | 
			
		||||
      s << <<~EOS
 | 
			
		||||
@ -120,10 +120,10 @@ class Caveats
 | 
			
		||||
          #{root_dir}/share/zsh/site-functions
 | 
			
		||||
      EOS
 | 
			
		||||
    when :fish
 | 
			
		||||
      fish_caveats = "fish #{installed.join(" and ")} have been installed to:"
 | 
			
		||||
      fish_caveats = +"fish #{installed.join(" and ")} have been installed to:"
 | 
			
		||||
      fish_caveats << "\n  #{root_dir}/share/fish/vendor_completions.d" if completion_installed
 | 
			
		||||
      fish_caveats << "\n  #{root_dir}/share/fish/vendor_functions.d" if functions_installed
 | 
			
		||||
      fish_caveats
 | 
			
		||||
      fish_caveats.freeze
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
# Uses ERB so can't use Frozen String Literals until >=Ruby 2.4:
 | 
			
		||||
# https://bugs.ruby-lang.org/issues/12031
 | 
			
		||||
# frozen_string_literal: false
 | 
			
		||||
 | 
			
		||||
require "formula"
 | 
			
		||||
require "utils/bottles"
 | 
			
		||||
@ -9,7 +11,7 @@ require "cli/parser"
 | 
			
		||||
require "utils/inreplace"
 | 
			
		||||
require "erb"
 | 
			
		||||
 | 
			
		||||
BOTTLE_ERB = <<-EOS
 | 
			
		||||
BOTTLE_ERB = <<-EOS.freeze
 | 
			
		||||
  bottle do
 | 
			
		||||
    <% if  !["#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}/bottles", "https://homebrew.bintray.com/bottles"].include?(root_url) %>
 | 
			
		||||
    root_url "<%= root_url %>"
 | 
			
		||||
@ -41,7 +43,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
  def bottle_args
 | 
			
		||||
    Homebrew::CLI::Parser.new do
 | 
			
		||||
      usage_banner <<~EOS
 | 
			
		||||
      usage_banner <<~EOS.freeze
 | 
			
		||||
        `bottle` [<options>] <formula>
 | 
			
		||||
 | 
			
		||||
        Generate a bottle (binary package) from a formula that was installed with
 | 
			
		||||
@ -378,7 +380,7 @@ module Homebrew
 | 
			
		||||
          "#{key}: old: #{old_value}, new: #{value}"
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        odie <<~EOS
 | 
			
		||||
        odie <<~EOS.freeze
 | 
			
		||||
          --keep-old was passed but there are changes in:
 | 
			
		||||
          #{mismatches.join("\n")}
 | 
			
		||||
        EOS
 | 
			
		||||
@ -489,7 +491,7 @@ module Homebrew
 | 
			
		||||
              end
 | 
			
		||||
 | 
			
		||||
              unless mismatches.empty?
 | 
			
		||||
                odie <<~EOS
 | 
			
		||||
                odie <<~EOS.freeze
 | 
			
		||||
                  --keep-old was passed but there are changes in:
 | 
			
		||||
                  #{mismatches.join("\n")}
 | 
			
		||||
                EOS
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
# Uses ERB so can't use Frozen String Literals until >=Ruby 2.4:
 | 
			
		||||
# https://bugs.ruby-lang.org/issues/12031
 | 
			
		||||
# frozen_string_literal: false
 | 
			
		||||
 | 
			
		||||
require "formula"
 | 
			
		||||
require "erb"
 | 
			
		||||
@ -16,7 +18,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
  def man_args
 | 
			
		||||
    Homebrew::CLI::Parser.new do
 | 
			
		||||
      usage_banner <<~EOS
 | 
			
		||||
      usage_banner <<~EOS.freeze
 | 
			
		||||
        `man` [<options>]
 | 
			
		||||
 | 
			
		||||
        Generate Homebrew's manpages.
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,8 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def inject_file_list(list, string)
 | 
			
		||||
        list.reduce(string) { |acc, elem| acc << "  #{elem}\n" }
 | 
			
		||||
        list.reduce(string.dup) { |acc, elem| acc << "  #{elem}\n" }
 | 
			
		||||
            .freeze
 | 
			
		||||
      end
 | 
			
		||||
      ############# END HELPERS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -531,7 +531,7 @@ class ErrorDuringExecution < RuntimeError
 | 
			
		||||
      status
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    s = "Failure while executing; `#{cmd.shelljoin.gsub(/\\=/, "=")}` exited with #{exitstatus}."
 | 
			
		||||
    s = +"Failure while executing; `#{cmd.shelljoin.gsub(/\\=/, "=")}` exited with #{exitstatus}."
 | 
			
		||||
 | 
			
		||||
    unless [*output].empty?
 | 
			
		||||
      format_output_line = lambda do |type_line|
 | 
			
		||||
@ -548,7 +548,7 @@ class ErrorDuringExecution < RuntimeError
 | 
			
		||||
      s << "\n" unless s.end_with?("\n")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    super s
 | 
			
		||||
    super s.freeze
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def stderr
 | 
			
		||||
 | 
			
		||||
@ -666,7 +666,7 @@ class FormulaInstaller
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def summary
 | 
			
		||||
    s = ""
 | 
			
		||||
    s = +""
 | 
			
		||||
    s << "#{Emoji.install_badge}  " if Emoji.enabled?
 | 
			
		||||
    s << "#{formula.prefix.resolved_path}: #{formula.prefix.abv}"
 | 
			
		||||
    s << ", built in #{pretty_duration build_time}" if build_time
 | 
			
		||||
 | 
			
		||||
@ -200,9 +200,9 @@ module Homebrew
 | 
			
		||||
        return if silent
 | 
			
		||||
 | 
			
		||||
        cask = Cask::CaskLoader.load(name)
 | 
			
		||||
        reason = "Found a cask named \"#{name}\" instead.\n"
 | 
			
		||||
        reason = +"Found a cask named \"#{name}\" instead.\n"
 | 
			
		||||
        reason << Cask::Cmd::Info.get_info(cask) if show_info
 | 
			
		||||
        reason
 | 
			
		||||
        reason.freeze
 | 
			
		||||
      rescue Cask::CaskUnavailableError
 | 
			
		||||
        nil
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -382,7 +382,7 @@ describe Formula do
 | 
			
		||||
 | 
			
		||||
      stamps_with_revisions.each do |stamp, revision|
 | 
			
		||||
        version = "HEAD-#{stamp}"
 | 
			
		||||
        version << "_#{revision}" unless revision.zero?
 | 
			
		||||
        version = "#{version}_#{revision}" unless revision.zero?
 | 
			
		||||
 | 
			
		||||
        prefix = f.rack/version
 | 
			
		||||
        prefix.mkpath
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ require "tempfile"
 | 
			
		||||
require "utils/inreplace"
 | 
			
		||||
 | 
			
		||||
describe StringInreplaceExtension do
 | 
			
		||||
  subject { string.extend(described_class) }
 | 
			
		||||
  subject { string.dup.extend(described_class) }
 | 
			
		||||
 | 
			
		||||
  describe "#change_make_var!" do
 | 
			
		||||
    context "flag" do
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ require "extend/string"
 | 
			
		||||
describe StringInreplaceExtension do
 | 
			
		||||
  subject { string.extend(described_class) }
 | 
			
		||||
 | 
			
		||||
  let(:string) { "foobar" }
 | 
			
		||||
  let(:string) { +"foobar" }
 | 
			
		||||
 | 
			
		||||
  describe "#sub!" do
 | 
			
		||||
    it "adds an error to #errors when no replacement was made" do
 | 
			
		||||
 | 
			
		||||
@ -113,8 +113,9 @@ def odeprecated(method, replacement = nil, disable: false, disable_on: nil, call
 | 
			
		||||
    break
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  message = "Calling #{method} is #{verb}! #{replacement_message}"
 | 
			
		||||
  message = +"Calling #{method} is #{verb}! #{replacement_message}"
 | 
			
		||||
  message << tap_message if tap_message
 | 
			
		||||
  message.freeze
 | 
			
		||||
 | 
			
		||||
  if ARGV.homebrew_developer? || disable || Homebrew.raise_deprecation_exceptions?
 | 
			
		||||
    exception = MethodDeprecatedError.new(message)
 | 
			
		||||
@ -152,12 +153,12 @@ end
 | 
			
		||||
 | 
			
		||||
def pretty_duration(s)
 | 
			
		||||
  s = s.to_i
 | 
			
		||||
  res = ""
 | 
			
		||||
  res = +""
 | 
			
		||||
 | 
			
		||||
  if s > 59
 | 
			
		||||
    m = s / 60
 | 
			
		||||
    s %= 60
 | 
			
		||||
    res = "#{m} #{"minute".pluralize(m)}"
 | 
			
		||||
    res = +"#{m} #{"minute".pluralize(m)}"
 | 
			
		||||
    return res.freeze if s.zero?
 | 
			
		||||
 | 
			
		||||
    res << " "
 | 
			
		||||
 | 
			
		||||
@ -3,10 +3,10 @@
 | 
			
		||||
module Utils
 | 
			
		||||
  class InreplaceError < RuntimeError
 | 
			
		||||
    def initialize(errors)
 | 
			
		||||
      formatted_errors = errors.reduce("inreplace failed\n") do |s, (path, errs)|
 | 
			
		||||
      formatted_errors = errors.reduce(+"inreplace failed\n") do |s, (path, errs)|
 | 
			
		||||
        s << "#{path}:\n" << errs.map { |e| "  #{e}\n" }.join
 | 
			
		||||
      end
 | 
			
		||||
      super formatted_errors
 | 
			
		||||
      super formatted_errors.freeze
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user