bridgetown-foundation 2.0.0.beta6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b34ab6dbe77174fef1fda7b2ad3892c8e7b8b3b87434cfc5978f57414b020c6d
4
- data.tar.gz: 36f14459e9d004ba65cfb6392ca9321ee3c7862fde5ef7000853423a408dea91
3
+ metadata.gz: e8d0cccba07d7b68b0db5c2f938a401ccf271705b6b3394a312058ff501d8648
4
+ data.tar.gz: fd28eb9738389d85e387f9a69849701b298b154d51585fb28602775524609aee
5
5
  SHA512:
6
- metadata.gz: 67c0837467ed540ac526a42681914c8ec55dd73de1befd763ee5a959b2a2a01200a7f839c5fc539113b24739fa90556edc36087cf8831f1ec517ae7d7b58fc8b
7
- data.tar.gz: a28532a4fea4e72a069ef1975f1d07f857f7c89015e39efd83f6d41f531ae58152a5ac45cce8ab1b80c17f6faaa61465c8577917fc814e78073d5054efe46892
6
+ metadata.gz: e6cb471b980291ec4cc9bb3d34adc2be05c1cb60bf8681fa8425a45093c3a1c683d8465fa52d101f03b9ec23fa05ce2fafd92334b067122a7f9217004d47f47f
7
+ data.tar.gz: c524d0b59fefadd89b6673c2e191766d609d9cd5ece9af038d897069b71d257f5bc89a9961d170dc07ae672eec785fca3875d90a557fcd01a21541810fb87912
@@ -10,14 +10,16 @@ module Bridgetown::Foundation
10
10
  hash = dup
11
11
  each do |key, value|
12
12
  hash.delete(key)
13
+ new_value = if value.is_a?(Array) || value.is_a?(Hash)
14
+ value.deep_dup
15
+ else
16
+ value.dup
17
+ end
18
+
13
19
  if key.is_a?(::String) || key.is_a?(::Symbol)
14
- hash[key] = value.dup
20
+ hash[key] = new_value
15
21
  else
16
- hash[key.dup] = if value.is_a?(Array) || value.is_a?(Hash)
17
- value.deep_dup
18
- else
19
- value.dup
20
- end
22
+ hash[key.dup] = new_value
21
23
  end
22
24
  end
23
25
  hash
@@ -25,7 +27,7 @@ module Bridgetown::Foundation
25
27
  end
26
28
 
27
29
  refine ::Array do
28
- def deep_dep
30
+ def deep_dup
29
31
  map do |item|
30
32
  next item.dup unless item.is_a?(Array) || item.is_a?(Hash)
31
33
 
@@ -9,7 +9,8 @@ module Bridgetown::Foundation
9
9
  def nested_within?(other)
10
10
  return false if self == other
11
11
 
12
- other.nested_parents.within?(nested_parents) #[1..])
12
+ other_hierarchy = [other, *other.nested_parents]
13
+ nested_parents[-other_hierarchy.length..] == other_hierarchy
13
14
  end
14
15
 
15
16
  def nested_parents
@@ -7,7 +7,7 @@ module Bridgetown::Foundation
7
7
  # This method lets you check if the receiver is "within" the other object. In most cases,
8
8
  # this check is accomplished via the `include?` method…aka, `10.within? [5, 10]` would
9
9
  # return `true` as `[5, 10].include? 10` is true. And String/String comparison are
10
- # case-insensivitve.
10
+ # case-insensitive.
11
11
  #
12
12
  # However, for certain comparison types: Module/Class, Hash, and Set, the lesser-than (`<`)
13
13
  # operator is used instead. This is so you can check `BigDecimal.within? Numeric`,
@@ -23,21 +23,21 @@ module Bridgetown::Foundation
23
23
  # @return [Boolean]
24
24
  def within?(other) # rubocop:disable Metrics
25
25
  # rubocop:disable Style/IfUnlessModifier
26
- if is_a?(Module) && other.is_a?(Module)
27
- return self < other
26
+ if is_a?(::Module) && other.is_a?(::Module)
27
+ return self < other == true # return a boolean instead of true/nil default
28
28
  end
29
29
 
30
- if (is_a?(Hash) && other.is_a?(Hash)) || (is_a?(Set) && other.is_a?(Set))
30
+ if (is_a?(::Hash) && other.is_a?(::Hash)) || (is_a?(::Set) && other.is_a?(::Set))
31
31
  return self < other
32
32
  end
33
33
 
34
- if is_a?(Array) && other.is_a?(Array)
34
+ if is_a?(::Array) && other.is_a?(::Array)
35
35
  return false if empty?
36
36
 
37
37
  return difference(other).empty?
38
38
  end
39
39
 
40
- if other.is_a?(Range)
40
+ if other.is_a?(::Range)
41
41
  return other.cover?(self) == true
42
42
  end
43
43
 
@@ -54,7 +54,7 @@ module Bridgetown::Foundation
54
54
  # NOTE: if you _really_ need to preserve Active Support's `in?` functionality, you can just
55
55
  # require "active_support/core_ext/object/inclusion"
56
56
  def in?(...) = Bridgetown::Foundation.deprecation_warning(
57
- self, :in?, :within?, 2025, 12
57
+ self, :in?, :within?, 2026, 12
58
58
  ).then { within?(...) }
59
59
  end
60
60
  end
@@ -9,7 +9,10 @@ module Bridgetown::Foundation
9
9
  Kernel.warn "multiple arguments aren't supported by `indent!' in Bridgetown", uplevel: 1
10
10
  end
11
11
 
12
- gsub! %r!^(?\!$)!, " " * indent_by
12
+ # this seems odd, but gsub! can return nil if there's not a match, so
13
+ # instead we'll return the string unchanged rather than cause a
14
+ # nil bug
15
+ gsub!(%r!^(?\!$)!, " " * indent_by) || self
13
16
  end
14
17
 
15
18
  def indent(indent_by, *args)
@@ -23,7 +26,7 @@ module Bridgetown::Foundation
23
26
  def questionable = Bridgetown::Foundation::QuestionableString.new(self)
24
27
 
25
28
  def inquiry = Bridgetown::Foundation.deprecation_warning(
26
- self, :inquiry, :questionable, 2025, 12
29
+ self, :inquiry, :questionable, 2026, 12
27
30
  ).then { questionable }
28
31
  end
29
32
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "2.0.0.beta6"
5
- CODE_NAME = "(TBD!)"
4
+ VERSION = "2.0.0"
5
+ CODE_NAME = "River City"
6
6
  end
@@ -7,7 +7,7 @@ require "zeitwerk"
7
7
  require "delegate"
8
8
 
9
9
  module Bridgetown::Foundation
10
- # This is loosly based on the `deprecate` method in `Gem::Deprecate`
10
+ # This is loosely based on the `deprecate` method in `Gem::Deprecate`
11
11
  #
12
12
  # @param target [Object]
13
13
  # @param name [Symbol] e.g. `:howdy`
@@ -32,6 +32,14 @@ end
32
32
  # refinement which lives inside `Bridgetown::Foundation::RefineExt`.
33
33
  module Bridgetown::Refinements
34
34
  include HashWithDotAccess::Refinements
35
+
36
+ # Include this mixin to access `helper` method which delegates to `Bridgetown.refine`
37
+ #
38
+ # @param *obj [Object]
39
+ # @return [Bridgetown::WrappedObjectWithRefinements]
40
+ module Helper
41
+ def refine(*obj) = Bridgetown.refine(*obj)
42
+ end
35
43
  end
36
44
 
37
45
  Zeitwerk.with_loader do |l|
@@ -45,10 +53,7 @@ module Bridgetown
45
53
  # Any method call sent will be passed along to the wrapped object with refinements activated
46
54
  class WrappedObjectWithRefinements < SimpleDelegator
47
55
  using Bridgetown::Refinements
48
-
49
- # rubocop:disable Style/MissingRespondToMissing
50
- def method_missing(method, ...) = __getobj__.send(method, ...)
51
- # rubocop:enable Style/MissingRespondToMissing
56
+ def method_missing(...) = __getobj__.send(...) # rubocop:disable Style
52
57
  end
53
58
 
54
59
  # Call this method to wrap any object(s) in order to use Foundation's refinements
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-foundation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-30 00:00:00.000000000 Z
11
+ date: 2025-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hash_with_dot_access
@@ -94,9 +94,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '3.1'
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ">"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 1.3.1
99
+ version: '0'
100
100
  requirements: []
101
101
  rubygems_version: 3.3.26
102
102
  signing_key: