deepmap 0.2.1 → 0.2.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 +5 -5
- data/readme.md +9 -17
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8d0c139648afeaa87a8ea6bb16067cb7f1f92164da6027384b8bcd7ceac10eff
|
4
|
+
data.tar.gz: 74f443fb5271e3ceab1ff0937bc8144828961600ba72ac74268a39aef7563b33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc67590a7a5787783cfbf57be228d288cad7b0605a5fe4c2c9adc8ae1a3899ea4895b864c67d09e7203d01af248cc04e32645e42334b0a4b2d52a46f46bf3e6
|
7
|
+
data.tar.gz: d82348cf15853ec822742224830e407e52256fef6ae35229a2135a1763a713f74b2c33703fbd4133bf07604ed4a6aa170806b418129dc7b46fa5a32c984f21aa
|
data/readme.md
CHANGED
@@ -1,13 +1,8 @@
|
|
1
|
-
deepmap
|
2
|
-
=======
|
3
|
-
|
1
|
+
# deepmap
|
4
2
|
|
5
3
|
[](https://badge.fury.io/rb/deepmap)
|
6
|
-
[](https://travis-ci.org/jeremywrnr/deepmap)
|
7
|
-
[](https://codeclimate.com/github/jeremywrnr/deepmap)
|
8
4
|
[](http://jeremywrnr.com/mit-license)
|
9
5
|
|
10
|
-
|
11
6
|
## setup
|
12
7
|
|
13
8
|
[sudo] gem install deepmap
|
@@ -16,16 +11,15 @@ deepmap
|
|
16
11
|
|
17
12
|
Ruby gem that adds three methods to the Hash and Array classes. Overview:
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
* `#deep_map` - apply block to each key and value in object
|
15
|
+
* `#key_map` - apply block to each key in object
|
16
|
+
* `#val_map` - apply block to each value in object
|
22
17
|
|
23
18
|
These may be useful when you want to apply a function to each value (or key or
|
24
19
|
pair) of a complex nested object (such as the result of parsing a YAML or JSON
|
25
20
|
file), which can have hashes or arrays as subfields. The function currently
|
26
21
|
needs to be passed in as a block (see usage).
|
27
22
|
|
28
|
-
|
29
23
|
## usage
|
30
24
|
|
31
25
|
```ruby
|
@@ -47,7 +41,7 @@ irb(main):005:0> test.val_map {|i| i.to_i * 2 }
|
|
47
41
|
|
48
42
|
Once you `require 'deepmap'`, you can call any of the three provided functions
|
49
43
|
on any (existing or new!) hash or array, as demonstrated above. You can also
|
50
|
-
use the (
|
44
|
+
use the (`&:method`) shortcut to call a method on each object concisely:
|
51
45
|
|
52
46
|
```ruby
|
53
47
|
irb(main):002:0> test = { 'a' => 'b', 'c' => ['d', 'e'], 'f' => { 'g' => ['h', 'i', { 'j' => 'k' }] } }
|
@@ -63,7 +57,6 @@ irb(main):005:0> test.val_map(&:upcase)
|
|
63
57
|
=> {"a"=>"B", "c"=>["D", "E"], "f"=>{"g"=>["H", "I", {"j"=>"K"}]}}
|
64
58
|
```
|
65
59
|
|
66
|
-
|
67
60
|
## development / testing
|
68
61
|
|
69
62
|
First, clone this repo:
|
@@ -79,17 +72,16 @@ try running `gem install bundler`. Once that is done:
|
|
79
72
|
Now, we should be able to build the gem locally. This will build the local
|
80
73
|
deepmap gem and link it in your path, so you can playing around with `deepmap`.
|
81
74
|
|
82
|
-
rake build
|
75
|
+
bundle exec rake build
|
83
76
|
|
84
77
|
This uses `rspec` and `rake` to run a suite of unit tests. To run the suite:
|
85
78
|
|
86
|
-
rake
|
87
|
-
|
79
|
+
bundle exec rake
|
88
80
|
|
89
81
|
## todo
|
90
82
|
|
91
|
-
|
83
|
+
* collison checking/warning/confirmation workflow
|
84
|
+
* support key-val iteration in mapping over vals/keys. This would allow support
|
92
85
|
for mapping conditionally based on a key/value, even if you are iterating
|
93
86
|
over all values/keys (`key_map {|k, v| k > 0 ? k : v }`).
|
94
87
|
|
95
|
-
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deepmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Warner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.8.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rufo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.15.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.15.1
|
55
55
|
description: Map functions over nested hash/arrays objects (e.g. JSON).
|
56
56
|
email: jeremywrnr@gmail.com
|
57
57
|
executables: []
|
@@ -64,7 +64,7 @@ homepage: http://github.com/jeremywrnr/deepmap
|
|
64
64
|
licenses:
|
65
65
|
- MIT
|
66
66
|
metadata: {}
|
67
|
-
post_install_message:
|
67
|
+
post_install_message:
|
68
68
|
rdoc_options: []
|
69
69
|
require_paths:
|
70
70
|
- lib/deepmap
|
@@ -79,9 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
|
83
|
-
|
84
|
-
signing_key:
|
82
|
+
rubygems_version: 3.3.7
|
83
|
+
signing_key:
|
85
84
|
specification_version: 4
|
86
85
|
summary: Nested hash/array function mapping.
|
87
86
|
test_files: []
|