tins 1.36.0 → 1.36.1
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 +4 -4
- data/CHANGES.md +5 -1
- data/lib/tins/hash_bfs.rb +4 -4
- data/lib/tins/version.rb +1 -1
- data/tests/hash_bfs_test.rb +2 -2
- data/tins.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ccd9381ab74305d467c86810271be1033c7f68b777cdb4c561b3b5bfb5152a
|
4
|
+
data.tar.gz: 977fa807b40ee00176d7ecde2c363d871acc8c476988e34b682d3d8b19e7ef20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c689f798c3679f290db513c4203b4c19b92696606e76feee88b27d0959b0d4ec09d9f7aac80c1d502d3e44d205da82715678b5b629ba51f669264a75bb8c77ce
|
7
|
+
data.tar.gz: 5bf30172063f7b6406247b15ff340fd65e2421799fa93c9d52ab69de315ba71b12550ffdabff42d0d6dc801a69c1bcc5679afdcaec090558886890d05edd7bf2
|
data/CHANGES.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2024-10-11 v1.36.1
|
4
|
+
|
5
|
+
* Fixed a typo in the code
|
6
|
+
|
3
7
|
## 2024-10-11 v1.36.0
|
4
8
|
|
5
9
|
### Significant Changes
|
6
10
|
|
7
11
|
* Refactor bfs method in `hash_bfs.rb`:
|
8
|
-
+ Rename `include_nodes` variable to `
|
12
|
+
+ Rename `include_nodes` variable to `visit_internal`
|
9
13
|
+ Update test cases in `hash_bfs_test.rb` to use new method signature
|
10
14
|
+ Update method signature and docstring to reflect new behavior
|
11
15
|
* Update hash conversion logic:
|
data/lib/tins/hash_bfs.rb
CHANGED
@@ -9,7 +9,7 @@ module Tins
|
|
9
9
|
# The bfs method performs a breadth-first search on the object's structure,
|
10
10
|
# visiting all elements and yielding their indices and values to the block.
|
11
11
|
#
|
12
|
-
# @param
|
12
|
+
# @param visit_internal [ true, false ] whether to visit internal hashes or arrays
|
13
13
|
# @yield [ index, value ] yields each element's index and value to the block
|
14
14
|
#
|
15
15
|
# @raise [ ArgumentError ] if no &block argument was provided
|
@@ -17,7 +17,7 @@ module Tins
|
|
17
17
|
# @example bfs { |index, value| … } # performs a breadth-first search on the object's structure
|
18
18
|
#
|
19
19
|
# @return [ self ] returns the receiver
|
20
|
-
def bfs(
|
20
|
+
def bfs(visit_internal: false, &block)
|
21
21
|
block or raise ArgumentError, 'require &block argument'
|
22
22
|
self.seen = {}
|
23
23
|
queue = []
|
@@ -31,13 +31,13 @@ module Tins
|
|
31
31
|
object.each do |k, v|
|
32
32
|
queue.push([ k, convert_to_hash_or_ary(v) ])
|
33
33
|
end
|
34
|
-
|
34
|
+
visit_internal or next
|
35
35
|
when Array === object
|
36
36
|
seen[object.__id__] = true
|
37
37
|
object.each_with_index do |v, i|
|
38
38
|
queue.push([ i, convert_to_hash_or_ary(v) ])
|
39
39
|
end
|
40
|
-
|
40
|
+
visit_internal or next
|
41
41
|
end
|
42
42
|
block.(index, object)
|
43
43
|
end
|
data/lib/tins/version.rb
CHANGED
data/tests/hash_bfs_test.rb
CHANGED
@@ -15,7 +15,7 @@ module Tins
|
|
15
15
|
|
16
16
|
def test_with_nodes
|
17
17
|
results = []
|
18
|
-
@hash.bfs(
|
18
|
+
@hash.bfs(visit_internal: true) { |*a| results.push(a) }
|
19
19
|
assert_equal(
|
20
20
|
[[nil, {a:"foo", b:[{c:"baz"}, {d:"quux"}, ["blub"]]}], [:a, "foo"],
|
21
21
|
[:b, [{c:"baz"}, {d:"quux"}, ["blub"]]], [0, {c:"baz"}], [1, {d:"quux"}],
|
@@ -27,7 +27,7 @@ module Tins
|
|
27
27
|
def test_with_nodes_with_circle
|
28
28
|
results = []
|
29
29
|
@hash[:b].last << @hash
|
30
|
-
@hash.bfs(
|
30
|
+
@hash.bfs(visit_internal: true) { |*a| results.push(a) }
|
31
31
|
assert_equal 9, results.size
|
32
32
|
end
|
33
33
|
end
|
data/tins.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: tins 1.36.
|
2
|
+
# stub: tins 1.36.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "tins".freeze
|
6
|
-
s.version = "1.36.
|
6
|
+
s.version = "1.36.1".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|