logstash-filter-mutate 3.1.7 → 3.2.0

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: 31804753a2488261d11a0771fa0eab2e956b261d4d7268cc38fe6861bbde25cd
4
- data.tar.gz: 94a5e236050fd73f8a40e8808941b33bb21446de4473a7c34ed88bd234c90a29
3
+ metadata.gz: e8196cb41a7cc83ef6ff48ab4dc9be6f130a00048cfc16821ca93f62a00955fe
4
+ data.tar.gz: 7fccc907cd8ef3fc7c8c8f0b3ae91b7e61ebd7ff949a9265d3e35c0d33d92674
5
5
  SHA512:
6
- metadata.gz: 1ef82046c5de8c0332bd615641f80bfd1f9b990872cf09a17a64ba06e1c9a17e31e95535ea72467d01fd0e500c3b2363d9718882ab0a71e89b2969b9fc73a956
7
- data.tar.gz: 466e5bf30f31db88f2f39a939b6ceaa8318a8280ff84fc98058d72ffab018b1bc285e6d6592c4acd0a902ca9e9823be0abb03334d893055d12052ded9b840ece
6
+ metadata.gz: 4ff52c37f5bc4525e97f73eaa605d646aae1a7474e0627c334ac0d3bfdc4d33736d201a3aaae0b4d0d6e7bf8ff1db3f08f3e1e8835719e5c33f15008c7746896
7
+ data.tar.gz: 7b2d637b7902aec46732838b327c307963da5ae279c1ff9ce91b5303adbf2a6411b75adc0944aec421226bd2c5e9efe2c0e059e79405c4e0d12d5b42e1a3dcd8
@@ -1,3 +1,6 @@
1
+ ## 3.2.0
2
+ - Support boolean to integer conversion #107
3
+
1
4
  ## 3.1.7
2
5
  - Update gemspec summary
3
6
 
@@ -58,7 +58,7 @@ filter plugins.
58
58
 
59
59
  Convert a field's value to a different type, like turning a string to an
60
60
  integer. If the field value is an array, all members will be converted.
61
- If the field is a hash, no action will be taken.
61
+ If the field is a hash no action will be taken.
62
62
 
63
63
  If the conversion type is `boolean`, the acceptable values are:
64
64
 
@@ -68,6 +68,10 @@ If the conversion type is `boolean`, the acceptable values are:
68
68
  If a value other than these is provided, it will pass straight through
69
69
  and log a warning message.
70
70
 
71
+ If the conversion type is `integer` and the value is a boolean, it will be converted as:
72
+ * **True:** `1`
73
+ * **False:** `0`
74
+
71
75
  Valid conversion targets are: integer, float, string, and boolean.
72
76
 
73
77
  Example:
@@ -45,7 +45,7 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
45
45
 
46
46
  # Convert a field's value to a different type, like turning a string to an
47
47
  # integer. If the field value is an array, all members will be converted.
48
- # If the field is a hash, no action will be taken.
48
+ # If the field is a hash no action will be taken.
49
49
  #
50
50
  # If the conversion type is `boolean`, the acceptable values are:
51
51
  #
@@ -55,6 +55,10 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
55
55
  # If a value other than these is provided, it will pass straight through
56
56
  # and log a warning message.
57
57
  #
58
+ # If the conversion type is `integer` and the value is a boolean, it will be converted as:
59
+ # * **True:** `1`
60
+ # * **False:** `0`
61
+ #
58
62
  # Valid conversion targets are: integer, float, string, and boolean.
59
63
  #
60
64
  # Example:
@@ -285,6 +289,8 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
285
289
  end
286
290
 
287
291
  def convert_integer(value)
292
+ return 1 if value == true
293
+ return 0 if value == false
288
294
  value.to_i
289
295
  end
290
296
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-mutate'
4
- s.version = '3.1.7'
4
+ s.version = '3.2.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Performs mutations on fields"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -537,6 +537,35 @@ describe LogStash::Filters::Mutate do
537
537
  end
538
538
  end
539
539
 
540
+ describe "convert booleans to integer" do
541
+ config <<-CONFIG
542
+ filter {
543
+ mutate {
544
+ convert => {
545
+ "[foo][0]" => "integer"
546
+ "[foo][1]" => "integer"
547
+ "[foo][2]" => "integer"
548
+ "[foo][3]" => "integer"
549
+ "[foo][4]" => "integer"
550
+ }
551
+ }
552
+ }
553
+ CONFIG
554
+
555
+ sample({ "foo" => [false, true, "0", "1", "2"] }) do
556
+ expect(subject.get("[foo][0]")).to eq 0
557
+ expect(subject.get("[foo][0]")).to be_a(Fixnum)
558
+ expect(subject.get("[foo][1]")).to eq 1
559
+ expect(subject.get("[foo][1]")).to be_a(Fixnum)
560
+ expect(subject.get("[foo][2]")).to eq 0
561
+ expect(subject.get("[foo][2]")).to be_a(Fixnum)
562
+ expect(subject.get("[foo][3]")).to eq 1
563
+ expect(subject.get("[foo][3]")).to be_a(Fixnum)
564
+ expect(subject.get("[foo][4]")).to eq 2
565
+ expect(subject.get("[foo][4]")).to be_a(Fixnum)
566
+ end
567
+ end
568
+
540
569
  #LOGSTASH-1529
541
570
  describe "gsub on a String with dynamic fields (%{}) in pattern" do
542
571
  config '
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-mutate
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.7
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.6.11
116
+ rubygems_version: 2.6.13
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Performs mutations on fields