Skip to content

Commit

Permalink
Add ActiveSupport String#exclude? to extend/
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Jan 11, 2024
1 parent 63d562a commit 353a5a9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/keys.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/deep_dup.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/duplicable.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/exclude.rb

# Ignore partially included gems where we don't need all files
**/vendor/gems/mechanize-*/.*
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def parse_basename(url, search_query: true)
end

if search_query && (uri_query = uri.query.presence)
components[:query] = URI.decode_www_form(uri_query).map { _1.fetch(1) }
components[:query] = URI.decode_www_form(uri_query).map { _2 }
end
else
components[:path] = [url]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: strict
# frozen_string_literal: true

class String
Expand All @@ -7,7 +8,6 @@ class String
# "hello".exclude? "lo" # => false
# "hello".exclude? "ol" # => true
# "hello".exclude? ?h # => false
def exclude?(string)
!include?(string)
end
sig { params(string: String).returns(T::Boolean) }
def exclude?(string) = !include?(string)
end
4 changes: 1 addition & 3 deletions Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
require "forwardable"
require "set"

# Only require "core_ext" here to ensure we're only requiring the minimum of
# what we need.
require "active_support/core_ext/enumerable"
require "active_support/core_ext/file/atomic"
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/string/exclude"

HOMEBREW_API_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_API_DEFAULT_DOMAIN").freeze
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_BOTTLE_DEFAULT_DOMAIN").freeze
Expand Down Expand Up @@ -71,6 +68,7 @@

require "extend/array"
require "extend/blank"
require "extend/string"
require "env_config"
require "macos_version"
require "os"
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/livecheck/strategy/gnu.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: strict
# frozen_string_literal: true

module Homebrew
Expand Down Expand Up @@ -32,11 +32,11 @@ class Gnu
NICE_NAME = "GNU"

# The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{
URL_MATCH_REGEX = T.let(%r{
^https?://
(?:(?:[^/]+?\.)*gnu\.org/(?:gnu|software)/(?<project_name>[^/]+)/
|(?<project_name>[^/]+)\.gnu\.org/?$)
}ix.freeze
}ix.freeze, Regexp)

# Whether the strategy can be applied to the provided URL.
#
Expand Down

0 comments on commit 353a5a9

Please sign in to comment.