deepmap 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/readme.md +9 -17
- metadata +19 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e4adeb8dab4e842316ce016e9a4f068e09279391a786710d458f44c457b5104
|
4
|
+
data.tar.gz: 31c668de570218bc4e6a8bc9f16451bdb24a35295168e7e5d48eeab24bbd0cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7272c097be04fd52c017e25bd9079e8d8ec6f3e1dd25d592a7f214630bc41d3d1309fd9150c55997e7d1379caac9467efb9cf342e9efeeff554c46380f2e2b1
|
7
|
+
data.tar.gz: ac955004b42234b87f6b7bbbc292f6ff145d169772a56b29b6d365f391aa735ca68d484bc8dcd202ba19776f149bb05b4f849823e2f3c3fa8916d6923d269bf9
|
data/readme.md
CHANGED
@@ -1,13 +1,8 @@
|
|
1
|
-
deepmap
|
2
|
-
=======
|
3
|
-
|
1
|
+
# deepmap
|
4
2
|
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/deepmap.svg)](https://badge.fury.io/rb/deepmap)
|
6
|
-
[![Build Status](https://travis-ci.org/jeremywrnr/deepmap.svg?branch=master)](https://travis-ci.org/jeremywrnr/deepmap)
|
7
|
-
[![Code Climate](https://codeclimate.com/github/jeremywrnr/deepmap/badges/gpa.svg)](https://codeclimate.com/github/jeremywrnr/deepmap)
|
8
4
|
[![MIT](https://img.shields.io/npm/l/alt.svg?style=flat)](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,58 +1,58 @@
|
|
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.3
|
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:
|
55
|
-
description: Map functions over nested hash/arrays objects (e.g
|
54
|
+
version: 0.15.1
|
55
|
+
description: Map functions over nested hash/arrays objects (e.g., YAML, JSON).
|
56
56
|
email: jeremywrnr@gmail.com
|
57
57
|
executables: []
|
58
58
|
extensions: []
|
@@ -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: []
|