jrf 0.1.10 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a42d35a082e26fb5ebc35733d705169793e42491eb20040aff884f65e016cf7
4
- data.tar.gz: 909ac3ea12a5bf4bf805ea65d25f03e01843efcc944a0180cda90d8d8dd89b8f
3
+ metadata.gz: edaeb729eecf63449c68fce92740acb8221885ff28a5ed26fe7bea32eb0a9bfa
4
+ data.tar.gz: 30364ac5e6eee46506da8c4d3ff2d8a05f12cd91b2b5cd248a12e612ea333891
5
5
  SHA512:
6
- metadata.gz: e38ba5d6ec1ae98cefe2d9ce848d3702ba2bddb6f2858df0b9055da84c08dd3371a1b3d6290ae74796b858765c5af5cbc4c68180fde6b161b78cbbefdfdbc84d
7
- data.tar.gz: cd5e4a2f2d93b34a45c3121e021b9ca23974476b82e3169f17ed6bce44600ecc82bcb5dc35cf3fc52cafb5749dd8be21370f7e5f2c33031774619f416e3c3518
6
+ metadata.gz: 22e73015ffb398d376c3636f8a9e324c01bd56ae5dc1170b39a8ad5c600c10273fadec1de5385706798e3aff19449b446744e608f1437ca73113871c33aa9b1b
7
+ data.tar.gz: 4c803ad64d65d6ae1d671426c2e81a4741ebcebd66ca4fb288574336e0a1088b8be2aa78f4235213ffc5794c92877410c88cbce7dae1f88bfb6369f6f37e3970
@@ -173,13 +173,13 @@ module Jrf
173
173
  def map(&block)
174
174
  raise ArgumentError, "map requires a block" unless block
175
175
 
176
- @__jrf_current_stage.step_map(:map, @obj, &block)
176
+ @__jrf_current_stage.step_map(:map, current_input, &block)
177
177
  end
178
178
 
179
179
  def map_values(&block)
180
180
  raise ArgumentError, "map_values requires a block" unless block
181
181
 
182
- @__jrf_current_stage.step_map(:map_values, @obj, &block)
182
+ @__jrf_current_stage.step_map(:map_values, current_input, &block)
183
183
  end
184
184
 
185
185
  def group_by(key, &block)
data/lib/jrf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jrf
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.11"
5
5
  end
data/test/jrf_test.rb CHANGED
@@ -847,6 +847,14 @@ stdout, stderr, status = run_jrf('_["values"] >> map { |x| x + 1 } >> map { |x|
847
847
  assert_success(status, stderr, "chained map transforms")
848
848
  assert_equal(['[20,110,1010]', '[30,210,2010]', '[40,310,3010]'], lines(stdout), "chained map transforms output")
849
849
 
850
+ stdout, stderr, status = run_jrf('map { map { |y| [ sum(y[0]), sum(y[1]) ] } }', "[[[1,2]]]\n[[[3,4]]]\n")
851
+ assert_success(status, stderr, "nested map reducer binds to current target")
852
+ assert_equal(['[[[4,6]]]'], lines(stdout), "nested map reducer output")
853
+
854
+ stdout, stderr, status = run_jrf('map_values { |obj| map_values { |v| sum(v) } }', "{\"a\":{\"x\":1,\"y\":2},\"b\":{\"x\":10,\"y\":20}}\n{\"a\":{\"x\":3,\"y\":4},\"b\":{\"x\":30,\"y\":40}}\n")
855
+ assert_success(status, stderr, "nested map_values reducer binds to current target")
856
+ assert_equal(['{"a":{"x":4,"y":6},"b":{"x":40,"y":60}}'], lines(stdout), "nested map_values reducer output")
857
+
850
858
  input_gb = <<~NDJSON
851
859
  {"status":200,"path":"/a","latency":10}
852
860
  {"status":404,"path":"/b","latency":50}
@@ -944,10 +952,18 @@ assert_equal([[2, 3], [4, 5]], j.call([[1, 2], [3, 4]]), "library map transform"
944
952
  j = Jrf.new(proc { map { |x| sum(x) } })
945
953
  assert_equal([[4, 6]], j.call([[1, 2], [3, 4]]), "library map reduce")
946
954
 
955
+ # nested map reduce binds to current target
956
+ j = Jrf.new(proc { map { map { |y| [sum(y[0]), sum(y[1])] } } })
957
+ assert_equal([[[[4, 6]]]], j.call([[[[1, 2]]], [[[3, 4]]]]), "library nested map reduce")
958
+
947
959
  # map_values transform
948
960
  j = Jrf.new(proc { map_values { |v| v * 10 } })
949
961
  assert_equal([{"a" => 10, "b" => 20}], j.call([{"a" => 1, "b" => 2}]), "library map_values transform")
950
962
 
963
+ # nested map_values reduce binds to current target
964
+ j = Jrf.new(proc { map_values { |obj| map_values { |v| sum(v) } } })
965
+ assert_equal([{"a" => {"x" => 4, "y" => 6}, "b" => {"x" => 40, "y" => 60}}], j.call([{"a" => {"x" => 1, "y" => 2}, "b" => {"x" => 10, "y" => 20}}, {"a" => {"x" => 3, "y" => 4}, "b" => {"x" => 30, "y" => 40}}]), "library nested map_values reduce")
966
+
951
967
  # map hash transform
952
968
  j = Jrf.new(proc { map { |k, v| "#{k}=#{v}" } })
953
969
  assert_equal([["a=1", "b=2"]], j.call([{"a" => 1, "b" => 2}]), "library map hash transform")
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - kazuho
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-12 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: oj
@@ -48,9 +49,11 @@ files:
48
49
  - lib/jrf/stage.rb
49
50
  - lib/jrf/version.rb
50
51
  - test/jrf_test.rb
52
+ homepage:
51
53
  licenses:
52
54
  - MIT
53
55
  metadata: {}
56
+ post_install_message:
54
57
  rdoc_options: []
55
58
  require_paths:
56
59
  - lib
@@ -65,7 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
68
  - !ruby/object:Gem::Version
66
69
  version: '0'
67
70
  requirements: []
68
- rubygems_version: 4.0.3
71
+ rubygems_version: 3.0.3.1
72
+ signing_key:
69
73
  specification_version: 4
70
74
  summary: JSON filter with the power and speed of Ruby
71
75
  test_files: []