dorian-json-deep-map 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/json-deep-map +7 -4
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 321de00122085b3493353f9e1d6acca4c52a06ba0894380b450a8a5784e81fb7
4
- data.tar.gz: fa5ffbd105eaca9dfde0ff5ebd9b756b81b07352b1d84fc2fce4c8c42c3d14f3
3
+ metadata.gz: c0cbdc527c31a863d15cf9962250f6839dabbd4025397744d426f758936a241b
4
+ data.tar.gz: 817ace3bc69423d5c9a41a134cbaed2244e1aed2804dcdf2b2897c71dd0f6469
5
5
  SHA512:
6
- metadata.gz: 6514093a5eb3f50c87d56d94b798c4ed0c2261f634eb092cd57c742a6576394b5ffdeaf00c1a2423fe87e328899ae7cc358f957f9a748649dff8f26c47d55852
7
- data.tar.gz: 4c75b89fdaa9bf76fb6a211b20dab768429e44b153bbad288e2603d8ada7a98fdab32cdd71e79c61a67227ddc47c33e583bc958d5047033d46299b1d93b832c0
6
+ metadata.gz: 43ba9ea9879677df093d21ee5484e0839724ea664cf9a8235b174e5e7c1d5c92d2d6ac32f8737f870d7c09f88f52f39e2317961893d6284c31c9938e272605da
7
+ data.tar.gz: 792fcf6bad318096383405d59fea0f31a032dcbbe741620f07e9c2aa43578121b185813ca175fea7d9f64f880d33fc9166b1ec8e6da4e17b7596d0a0bb570158
data/bin/json-deep-map CHANGED
@@ -2,15 +2,18 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "dorian/arguments"
5
+ require "dorian/to_struct"
5
6
  require "json"
6
7
 
7
8
  def deep_map(json, &block)
9
+ json = yield(json.to_deep_struct).from_deep_struct
10
+
8
11
  if json.is_a?(Hash)
9
- yield(json).to_h { |key, value| deep_map([key, value], &block) }
12
+ json.to_h { |key, value| deep_map([key, value], &block) }
10
13
  elsif json.is_a?(Array)
11
- yield(json).map { |element| deep_map(element, &block) }
14
+ json.map { |element| deep_map(element, &block) }
12
15
  else
13
- yield(json)
16
+ json
14
17
  end
15
18
  end
16
19
 
@@ -19,7 +22,7 @@ parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
19
22
  abort parsed.help if parsed.options.help
20
23
 
21
24
  if parsed.options.version
22
- abort File.read(File.expand_path("../../VERSION", __FILE__))
25
+ abort File.read(File.expand_path("../VERSION", __dir__))
23
26
  end
24
27
 
25
28
  inputs = parsed.files.map { |file| File.read(file) }
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-json-deep-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-24 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: dorian-arguments
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: dorian-arguments
42
+ name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -71,9 +71,9 @@ require_paths:
71
71
  - lib
72
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 3.3.4
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="