Use ActiveSupport’s #second.
				
					
				
			This commit is contained in:
		
							parent
							
								
									72f350e757
								
							
						
					
					
						commit
						c4d418e126
					
				@ -5,9 +5,7 @@ end
 | 
			
		||||
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
 | 
			
		||||
 | 
			
		||||
# check ruby version before requiring any modules.
 | 
			
		||||
RUBY_VERSION_SPLIT = RUBY_VERSION.split "."
 | 
			
		||||
RUBY_X = RUBY_VERSION_SPLIT[0].to_i
 | 
			
		||||
RUBY_Y = RUBY_VERSION_SPLIT[1].to_i
 | 
			
		||||
RUBY_X, RUBY_Y, = RUBY_VERSION.split(".").map(&:to_i)
 | 
			
		||||
if RUBY_X < 2 || (RUBY_X == 2 && RUBY_Y < 3)
 | 
			
		||||
  raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}."
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -115,10 +115,8 @@ module Cask
 | 
			
		||||
        command.run!("/bin/launchctl", args: ["list"]).stdout.lines
 | 
			
		||||
               .map { |line| line.chomp.split("\t") }
 | 
			
		||||
               .map { |pid, state, id| [pid.to_i, state.to_i, id] }
 | 
			
		||||
               .select do |fields|
 | 
			
		||||
                 next if fields[0].zero?
 | 
			
		||||
 | 
			
		||||
                 fields[2] =~ /^#{Regexp.escape(bundle_id)}($|\.\d+)/
 | 
			
		||||
               .select do |(pid, _, id)|
 | 
			
		||||
                 pid.nonzero? && id.match?(/^#{Regexp.escape(bundle_id)}($|\.\d+)/)
 | 
			
		||||
               end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -89,19 +89,19 @@ module Cask
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def before_comma
 | 
			
		||||
        version { split(",", 2)[0] }
 | 
			
		||||
        version { split(",", 2).first }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def after_comma
 | 
			
		||||
        version { split(",", 2)[1] }
 | 
			
		||||
        version { split(",", 2).second }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def before_colon
 | 
			
		||||
        version { split(":", 2)[0] }
 | 
			
		||||
        version { split(":", 2).first }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def after_colon
 | 
			
		||||
        version { split(":", 2)[1] }
 | 
			
		||||
        version { split(":", 2).second }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def no_dividers
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,7 @@ module Homebrew
 | 
			
		||||
                   .map { |d| Keg.new(d).version }
 | 
			
		||||
                   .sort
 | 
			
		||||
                   .join(", ")
 | 
			
		||||
    version = ARGV[1]
 | 
			
		||||
    version = ARGV.second
 | 
			
		||||
 | 
			
		||||
    if !version || ARGV.named.length > 2
 | 
			
		||||
      onoe usage
 | 
			
		||||
 | 
			
		||||
@ -45,9 +45,9 @@ module Homebrew
 | 
			
		||||
    elsif ARGV.named.empty?
 | 
			
		||||
      puts Tap.names
 | 
			
		||||
    else
 | 
			
		||||
      tap = Tap.fetch(ARGV.named[0])
 | 
			
		||||
      tap = Tap.fetch(ARGV.named.first)
 | 
			
		||||
      begin
 | 
			
		||||
        tap.install clone_target: ARGV.named[1],
 | 
			
		||||
        tap.install clone_target: ARGV.named.second,
 | 
			
		||||
                    force_auto_update: force_auto_update?,
 | 
			
		||||
                    full_clone: full_clone?,
 | 
			
		||||
                    quiet: ARGV.quieter?
 | 
			
		||||
 | 
			
		||||
@ -512,7 +512,7 @@ module Homebrew
 | 
			
		||||
      # Formulae names can legitimately be uppercase/lowercase/both.
 | 
			
		||||
      name = Regexp.new(formula.name, Regexp::IGNORECASE)
 | 
			
		||||
      reason.sub!(name, "")
 | 
			
		||||
      first_word = reason.split[0]
 | 
			
		||||
      first_word = reason.split.first
 | 
			
		||||
 | 
			
		||||
      if reason =~ /\A[A-Z]/ && !reason.start_with?(*whitelist)
 | 
			
		||||
        problem <<~EOS
 | 
			
		||||
@ -724,7 +724,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
        version = Version.parse(stable.url)
 | 
			
		||||
        if version >= Version.create("1.0")
 | 
			
		||||
          minor_version = version.to_s.split(".", 3)[1].to_i
 | 
			
		||||
          _, minor_version, = version.to_s.split(".", 3).map(&:to_i)
 | 
			
		||||
          if minor_version.odd?
 | 
			
		||||
            problem "#{stable.version} is a development release"
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,7 @@ module Homebrew
 | 
			
		||||
    # Expect exactly two named arguments: formula and tap
 | 
			
		||||
    raise UsageError if ARGV.named.length != 2
 | 
			
		||||
 | 
			
		||||
    destination_tap = Tap.fetch(ARGV.named[1])
 | 
			
		||||
    destination_tap = Tap.fetch(ARGV.named.second)
 | 
			
		||||
    odie "Cannot extract formula to homebrew/core!" if destination_tap.core_tap?
 | 
			
		||||
    destination_tap.install unless destination_tap.installed?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ module Homebrew
 | 
			
		||||
    ).lines.first.chomp
 | 
			
		||||
    odie "Could not find any previous tags!" unless previous_tag
 | 
			
		||||
 | 
			
		||||
    end_ref = ARGV.named[1] || "origin/master"
 | 
			
		||||
    end_ref = ARGV.named.second || "origin/master"
 | 
			
		||||
 | 
			
		||||
    [previous_tag, end_ref].each do |ref|
 | 
			
		||||
      next if quiet_system "git", "-C", HOMEBREW_REPOSITORY, "rev-parse", "--verify", "--quiet", ref
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,7 @@ module Homebrew
 | 
			
		||||
        Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
 | 
			
		||||
      elsif args.to_tag?
 | 
			
		||||
        tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
 | 
			
		||||
        previous_tag = tags.lines[1]
 | 
			
		||||
        previous_tag = tags.lines.second
 | 
			
		||||
        previous_tag ||= begin
 | 
			
		||||
          if (HOMEBREW_REPOSITORY/".git/shallow").exist?
 | 
			
		||||
            safe_system "git", "fetch", "--tags", "--depth=1"
 | 
			
		||||
@ -69,7 +69,7 @@ module Homebrew
 | 
			
		||||
          elsif OS.linux?
 | 
			
		||||
            tags = Utils.popen_read("git tag --list | sort -rV")
 | 
			
		||||
          end
 | 
			
		||||
          tags.lines[1]
 | 
			
		||||
          tags.lines.second
 | 
			
		||||
        end
 | 
			
		||||
        previous_tag = previous_tag.to_s.chomp
 | 
			
		||||
        odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
 | 
			
		||||
 | 
			
		||||
@ -105,7 +105,7 @@ module FormulaClassUnavailableErrorModule
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def format_list(class_list)
 | 
			
		||||
    class_list.map { |klass| klass.name.split("::")[-1] }.join(", ")
 | 
			
		||||
    class_list.map { |klass| klass.name.split("::").last }.join(", ")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -417,7 +417,7 @@ class Formula
 | 
			
		||||
  def aliases
 | 
			
		||||
    @aliases ||= if tap
 | 
			
		||||
      tap.alias_reverse_table[full_name].to_a.map do |a|
 | 
			
		||||
        a.split("/")[-1]
 | 
			
		||||
        a.split("/").last
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      []
 | 
			
		||||
@ -1371,7 +1371,7 @@ class Formula
 | 
			
		||||
  # an array of all {Formula} names
 | 
			
		||||
  # @private
 | 
			
		||||
  def self.names
 | 
			
		||||
    @names ||= (core_names + tap_names.map { |name| name.split("/")[-1] }).uniq.sort
 | 
			
		||||
    @names ||= (core_names + tap_names.map { |name| name.split("/").last }).uniq.sort
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # an array of all {Formula} files
 | 
			
		||||
@ -1462,7 +1462,7 @@ class Formula
 | 
			
		||||
  # an array of all aliases
 | 
			
		||||
  # @private
 | 
			
		||||
  def self.aliases
 | 
			
		||||
    @aliases ||= (core_aliases + tap_aliases.map { |name| name.split("/")[-1] }).uniq.sort
 | 
			
		||||
    @aliases ||= (core_aliases + tap_aliases.map { |name| name.split("/").last }).uniq.sort
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # an array of all aliases, , which the tap formulae have the fully-qualified name
 | 
			
		||||
 | 
			
		||||
@ -71,9 +71,7 @@ module Language
 | 
			
		||||
        rm_rf Dir[".cabal-sandbox/*packages.conf.d/"]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def install_cabal_package(*args)
 | 
			
		||||
        options = args[-1].is_a?(Hash) ? args.pop : {}
 | 
			
		||||
 | 
			
		||||
      def install_cabal_package(*args, **options)
 | 
			
		||||
        cabal_sandbox do
 | 
			
		||||
          cabal_install_tools(*options[:using]) if options[:using]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,8 +17,8 @@ class Tap
 | 
			
		||||
    when 1
 | 
			
		||||
      user, repo = args.first.split("/", 2)
 | 
			
		||||
    when 2
 | 
			
		||||
      user = args[0]
 | 
			
		||||
      repo = args[1]
 | 
			
		||||
      user = args.first
 | 
			
		||||
      repo = args.second
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if [user, repo].any? { |part| part.nil? || part.include?("/") }
 | 
			
		||||
 | 
			
		||||
@ -419,10 +419,10 @@ describe Cask::DSL, :cask do
 | 
			
		||||
      let(:token) { "with-installer-script" }
 | 
			
		||||
 | 
			
		||||
      it "allows installer script to be specified" do
 | 
			
		||||
        expect(cask.artifacts.to_a[0].path).to eq(Pathname("/usr/bin/true"))
 | 
			
		||||
        expect(cask.artifacts.to_a[0].args[:args]).to eq(["--flag"])
 | 
			
		||||
        expect(cask.artifacts.to_a[1].path).to eq(Pathname("/usr/bin/false"))
 | 
			
		||||
        expect(cask.artifacts.to_a[1].args[:args]).to eq(["--flag"])
 | 
			
		||||
        expect(cask.artifacts.to_a.first.path).to eq(Pathname("/usr/bin/true"))
 | 
			
		||||
        expect(cask.artifacts.to_a.first.args[:args]).to eq(["--flag"])
 | 
			
		||||
        expect(cask.artifacts.to_a.second.path).to eq(Pathname("/usr/bin/false"))
 | 
			
		||||
        expect(cask.artifacts.to_a.second.args[:args]).to eq(["--flag"])
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -86,8 +86,8 @@ describe Patch do
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      expect(patches.length).to eq(2)
 | 
			
		||||
      expect(patches[0].strip).to eq(:p1)
 | 
			
		||||
      expect(patches[1].strip).to eq(:p1)
 | 
			
		||||
      expect(patches.first.strip).to eq(:p1)
 | 
			
		||||
      expect(patches.second.strip).to eq(:p1)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "can create patches from a :p0 hash" do
 | 
			
		||||
 | 
			
		||||
@ -53,8 +53,9 @@ RSpec.shared_context "integration test" do
 | 
			
		||||
  def command_id_from_args(args)
 | 
			
		||||
    @command_count ||= 0
 | 
			
		||||
    pretty_args = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@")
 | 
			
		||||
    file_and_line = caller[1].sub(/(.*\d+):.*/, '\1')
 | 
			
		||||
                             .sub("#{HOMEBREW_LIBRARY_PATH}/test/", "")
 | 
			
		||||
    file_and_line = caller.second
 | 
			
		||||
                          .sub(/(.*\d+):.*/, '\1')
 | 
			
		||||
                          .sub("#{HOMEBREW_LIBRARY_PATH}/test/", "")
 | 
			
		||||
    "#{file_and_line}:brew #{pretty_args}:#{@command_count += 1}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ module Utils
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def resolve_version(bottle_file)
 | 
			
		||||
        PkgVersion.parse receipt_path(bottle_file).split("/")[1]
 | 
			
		||||
        PkgVersion.parse receipt_path(bottle_file).split("/").second
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def formula_contents(bottle_file,
 | 
			
		||||
 | 
			
		||||
@ -7,8 +7,8 @@ module Tty
 | 
			
		||||
 | 
			
		||||
  def width
 | 
			
		||||
    @width ||= begin
 | 
			
		||||
      width = `/bin/stty size 2>/dev/null`.split[1]
 | 
			
		||||
      width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
 | 
			
		||||
      _, width = `/bin/stty size 2>/dev/null`.split
 | 
			
		||||
      width, = `/usr/bin/tput cols 2>/dev/null`.split if width.to_i.zero?
 | 
			
		||||
      width ||= 80
 | 
			
		||||
      width.to_i
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -351,7 +351,7 @@ class Version
 | 
			
		||||
    # e.g. https://github.com/JustArchi/ArchiSteamFarm/releases/download/2.3.2.0/ASF.zip
 | 
			
		||||
    # e.g. https://people.gnome.org/~newren/eg/download/1.7.5.2/eg
 | 
			
		||||
    m = %r{/([rvV]_?)?(\d\.\d+(\.\d+){,2})}.match(spec_s)
 | 
			
		||||
    return m.captures[1] unless m.nil?
 | 
			
		||||
    return m.captures.second unless m.nil?
 | 
			
		||||
 | 
			
		||||
    # e.g. https://www.ijg.org/files/jpegsrc.v8d.tar.gz
 | 
			
		||||
    m = /\.v(\d+[a-z]?)/.match(stem)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user