structure_walker 0.1.1 → 0.1.2
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/README.md +26 -11
- data/lib/structure_walker/version.rb +1 -1
- data/structure_walker.gemspec +2 -2
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec01bff23d577c82e849ade2858c86e7debacf13
|
4
|
+
data.tar.gz: 93696a192519e2866aea5fc5c52269ebfc81b8a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ba901417942e66855ac44329957c4c622a442c0b2826191ada8b57527581bc1b526b260e3c707778b591703998e87bf248af37bfc4d2f5b957ca686c9f38e3a
|
7
|
+
data.tar.gz: 83552a33691c8a1f8e6952a4e83e8e3f57ffefef820029ead85566b6bfb46f899a1709ca04b885f1f27fbaa6214c76a269962323f1f603c50f8ee3b9b2b0907d
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# StructureWalker
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/Kadavar32/walker)
|
4
|
+
|
5
|
+
Deep nested structure walker.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -20,11 +22,11 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
25
|
+
Examples:
|
24
26
|
|
25
27
|
handler = ->(data) { data[:example_key] = 'some_value'; data }
|
26
28
|
|
27
|
-
data = { some_key: { specific_key: [
|
29
|
+
data = { some_key: { specific_key: [{ key: 'value' }, { key: 'value' }], another_key: { key: 'value' } } }
|
28
30
|
|
29
31
|
steps = [[:enum, :hash], [:key, :specific_key], [:enum, :array]]
|
30
32
|
|
@@ -32,15 +34,28 @@ Example:
|
|
32
34
|
|
33
35
|
result = walker.call(steps, data)
|
34
36
|
|
35
|
-
{:
|
37
|
+
result # => { some_key: { specific_key: [{ key: "value", example_key: "some_value" }, { key: "value", example_key: "some_value" }], another_key: { key: "value" } } }
|
38
|
+
|
39
|
+
Example with multiple keys:
|
40
|
+
|
41
|
+
handler = ->(data) { data[:example_key] = 'some_value'; data }
|
42
|
+
|
43
|
+
data = { key: { specific_key: [{ key: 'value' }], another_key: [{ key: 'value' }], one_more_key: [{ key: 'value' }] } }
|
44
|
+
|
45
|
+
steps = [[:enum, :hash], [:keys, [:specific_key, :one_more_key]], [:enum, :array]]
|
46
|
+
|
47
|
+
walker = StructureWalker::Builder.invoke(handler)
|
48
|
+
|
49
|
+
result = walker.call(steps, data)
|
50
|
+
|
51
|
+
result # => { key: { specific_key: [{ key: 'value', new_key: 'value' }], another_key: [{ key: 'value' }], one_more_key: [{ key: 'value', new_key: 'value' }] } }
|
52
|
+
|
53
|
+
Available steps:
|
36
54
|
|
37
|
-
|
38
|
-
|
39
|
-
[:
|
40
|
-
[:
|
41
|
-
[:key, :some_key]
|
42
|
-
[:keys, [:key_one, :key_two]]
|
43
|
-
[:method, :method_name]
|
55
|
+
[:enum, :hash] - walk through hash elements value
|
56
|
+
[:enum, :array] - walk through array elements
|
57
|
+
[:key, :some_key] - walk on value of key :some_key
|
58
|
+
[:keys, [:key_one, :key_two]] - walk on values of keys key_one and key_two
|
44
59
|
|
45
60
|
|
46
61
|
## Contributing
|
data/structure_walker.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Kadavar"]
|
10
10
|
spec.email = ["Kadavar32@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{The gem helps you to 'walk' in nested structures,
|
13
|
-
spec.description = %q{The gem helps you to 'walk' in nested structures,
|
12
|
+
spec.summary = %q{The gem helps you to 'walk' in nested structures, avoiding nested each.}
|
13
|
+
spec.description = %q{The gem helps you to 'walk' in nested structures, avoiding nested each.}
|
14
14
|
spec.homepage = 'https://github.com/Kadavar32/walker.git'
|
15
15
|
spec.license = "MIT"
|
16
16
|
spec.required_ruby_version = '~> 2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: structure_walker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kadavar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,8 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: The gem helps you to 'walk' in nested structures,
|
56
|
-
and how you want.
|
55
|
+
description: The gem helps you to 'walk' in nested structures, avoiding nested each.
|
57
56
|
email:
|
58
57
|
- Kadavar32@gmail.com
|
59
58
|
executables: []
|
@@ -96,6 +95,5 @@ rubyforge_project:
|
|
96
95
|
rubygems_version: 2.4.8
|
97
96
|
signing_key:
|
98
97
|
specification_version: 4
|
99
|
-
summary: The gem helps you to 'walk' in nested structures,
|
100
|
-
and how you want.
|
98
|
+
summary: The gem helps you to 'walk' in nested structures, avoiding nested each.
|
101
99
|
test_files: []
|