-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16463 from dduugg/no-active-support
Remove ActiveSupport from runtime
- Loading branch information
Showing
43 changed files
with
409 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# frozen_string_literal: true | ||
|
||
require "delegate" | ||
require "extend/hash/keys" | ||
|
||
module Cask | ||
class DSL | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# typed: strict | ||
|
||
class Array | ||
sig { returns(T.nilable(Elem)) } | ||
def second; end | ||
|
||
sig { returns(T.nilable(Elem)) } | ||
def third; end | ||
|
||
sig { returns(T.nilable(Elem)) } | ||
def fourth; end | ||
|
||
sig { returns(T.nilable(Elem)) } | ||
def fifth; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
module Enumerable | ||
# The negative of the <tt>Enumerable#include?</tt>. Returns +true+ if the | ||
# collection does not include the object. | ||
sig { params(object: T.untyped).returns(T::Boolean) } | ||
def exclude?(object) = !include?(object) | ||
|
||
# Returns a new +Array+ without the blank items. | ||
# Uses Object#blank? for determining if an item is blank. | ||
# | ||
# [1, "", nil, 2, " ", [], {}, false, true].compact_blank | ||
# # => [1, 2, true] | ||
# | ||
# Set.new([nil, "", 1, false]).compact_blank | ||
# # => [1] | ||
# | ||
# When called on a +Hash+, returns a new +Hash+ without the blank values. | ||
# | ||
# { a: "", b: 1, c: nil, d: [], e: false, f: true }.compact_blank | ||
# # => { b: 1, f: true } | ||
sig { returns(T.self_type) } | ||
def compact_blank = T.unsafe(self).reject(&:blank?) | ||
end | ||
|
||
class Hash | ||
# Hash#reject has its own definition, so this needs one too. | ||
def compact_blank = reject { |_k, v| T.unsafe(v).blank? } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# typed: strict | ||
|
||
class Hash | ||
sig { returns(T::Hash[Hash::K, Hash::V]) } | ||
def compact_blank; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
class Hash | ||
sig do | ||
type_parameters(:k2).params( | ||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped], | ||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)) | ||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped]) | ||
end | ||
def deep_merge(other_hash, &block); end | ||
|
||
sig do | ||
type_parameters(:k2).params( | ||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped], | ||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)) | ||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped]) | ||
end | ||
def deep_merge!(other_hash, &block); end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
class Hash | ||
# Returns a new hash with all values converted by the block operation. | ||
# This includes the values from the root hash and from all | ||
# nested hashes and arrays. | ||
# | ||
# hash = { person: { name: 'Rob', age: '28' } } | ||
# | ||
# hash.deep_transform_values{ |value| value.to_s.upcase } | ||
# # => {person: {name: "ROB", age: "28"}} | ||
def deep_transform_values(&block) = _deep_transform_values_in_object(self, &block) | ||
|
||
# Destructively converts all values by using the block operation. | ||
# This includes the values from the root hash and from all | ||
# nested hashes and arrays. | ||
def deep_transform_values!(&block) = _deep_transform_values_in_object!(self, &block) | ||
|
||
private | ||
|
||
# Support methods for deep transforming nested hashes and arrays. | ||
sig { params(object: T.anything, block: T.proc.params(v: T.untyped).returns(T.untyped)).returns(T.untyped) } | ||
def _deep_transform_values_in_object(object, &block) | ||
case object | ||
when Hash | ||
object.transform_values { |value| _deep_transform_values_in_object(value, &block) } | ||
when Array | ||
object.map { |e| _deep_transform_values_in_object(e, &block) } | ||
else | ||
yield(object) | ||
end | ||
end | ||
|
||
sig { params(object: T.anything, block: T.proc.params(v: T.untyped).returns(T.untyped)).returns(T.untyped) } | ||
def _deep_transform_values_in_object!(object, &block) | ||
case object | ||
when Hash | ||
object.transform_values! { |value| _deep_transform_values_in_object!(value, &block) } | ||
when Array | ||
object.map! { |e| _deep_transform_values_in_object!(e, &block) } | ||
else | ||
yield(object) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# typed: strict | ||
|
||
class Hash | ||
sig { | ||
type_parameters(:out).params( | ||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)) | ||
).returns(T::Hash[Hash::K, T.type_parameter(:out)]) | ||
} | ||
def deep_transform_values(&block); end | ||
|
||
sig { | ||
type_parameters(:out).params( | ||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)) | ||
).returns(T::Hash[Hash::K, T.type_parameter(:out)]) | ||
} | ||
def deep_transform_values!(&block); end | ||
end |
Oops, something went wrong.