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