fluent-plugin-record_indexing_test 0.2.1 → 0.2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2865d1ecd58abe3b735526da14dd5240cfc2c5402d52bf041614b625b81f74bf
4
- data.tar.gz: 3f2b9709c60b05ee1ea7421c43cda6858d190821454d1d6e1b8d11a8aee9f315
3
+ metadata.gz: 7f7796f884ed595263aec7d09a800478fc8ec6e4940995f62b768ecb463bd557
4
+ data.tar.gz: f9a2ef6751760bd6b0853412c55111874b133c71e33e5a5c2070b2e0973929ce
5
5
  SHA512:
6
- metadata.gz: c5fad3e0173f9956c05b38f2a144d12d20800a8e897fb5a62b0548571db6ee8165fd69987040e99f9bac26ed8d5f68521b290b9ee0973a15c0176d3046c831d8
7
- data.tar.gz: 02b8d4f280f9ebd39f3bbcc69482a5282dbb39193029e0d360a87789a37541618f3a4dcc9f0abbe75f03f6e5e54a3272927e9b67dc9efe382d76c3e9cbd91c9e
6
+ metadata.gz: 0b16b2a62b07104ea552adb931f74cb6da8800cb517e55b78568fc532641224f7d839d838233ba33169073c7771023ae7b77f3b27275fafb0144851e63710db3
7
+ data.tar.gz: 9775ad98ca05b1d223900d73e67b2ae903f1008f458f21095f9a55b9f6f0d9b26ea7a311a33f2447f6c7dfc7dd9ed9791795dfb8a29999ff916d1b7dbd255f80
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "fluent-plugin-record_indexing_test"
4
- spec.version = "0.2.1"
4
+ spec.version = "0.2.2.3"
5
5
  spec.authors = ["imcotop"]
6
6
  spec.email = ["imcotop@icloud.com"]
7
7
 
@@ -8,13 +8,12 @@ module Fluent
8
8
  config_param :key_names, :array, default: []
9
9
  config_param :key_prefix, :string, default: nil
10
10
  config_param :check_all_key, :bool, default: true
11
+ config_param :ignore_length, :bool, default: true
11
12
  config_param :exclude_keys, :array, default: []
12
13
 
13
14
  def filter(tag, time, record)
14
- if check_all_key == false
15
- unless key_names.any?
16
- raise ArgumentError, "key_names parameter is required if check_all_key set false"
17
- end
15
+ if !@check_all_key && key_names.empty?
16
+ raise ArgumentError, "key_names parameter is required if check_all_key set false"
18
17
  end
19
18
  new_record = {}
20
19
  each_with_index(record, new_record)
@@ -23,17 +22,28 @@ module Fluent
23
22
  end
24
23
 
25
24
  def each_with_index(record, new_record)
25
+ seen_keys = {} # To keep track of duplicate names
26
26
  record.each do |key, value|
27
- if check_all_key || key_names.include?(key)
28
- if exclude_keys.include?(key)
27
+ if @check_all_key || @key_names.include?(key)
28
+ if @exclude_keys.include?(key)
29
29
  new_record[key] = value # Keep the value as is without indexing
30
30
  elsif value.is_a?(Array)
31
- if value.length == 1
31
+ if !@ignore_length && value.length == 1
32
32
  new_record[key] = value.first
33
33
  else
34
34
  new_record[key] = {}
35
35
  value.each_with_index do |item, index|
36
- new_record[key]["#{key_prefix}#{index}"] = item
36
+ if item.is_a?(Hash) && item.key?("name") && item.key?("value")
37
+ item_name = item["name"]
38
+ if seen_keys[item_name]
39
+ new_record[key]["#{@key_prefix}#{index}"] = item
40
+ else
41
+ new_record[key][item_name] = item["value"]
42
+ seen_keys[item_name] = true
43
+ end
44
+ else
45
+ new_record[key]["#{@key_prefix}#{index}"] = item
46
+ end
37
47
  end
38
48
  end
39
49
  elsif value.is_a?(Hash)
@@ -62,4 +72,3 @@ module Fluent
62
72
  end
63
73
  end
64
74
  end
65
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record_indexing_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - imcotop
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,7 +78,7 @@ homepage: https://github.com/imcotop/fluent-plugin-record_indexing
78
78
  licenses:
79
79
  - apache2
80
80
  metadata: {}
81
- post_install_message:
81
+ post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths:
84
84
  - lib
@@ -93,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubygems_version: 3.0.3.1
97
- signing_key:
96
+ rubygems_version: 3.5.7
97
+ signing_key:
98
98
  specification_version: 4
99
99
  summary: A fluentd filter plugin that will be used to Iterate over the object with
100
100
  its index and returns the value of the given object.