logstash-filter-translate 2.0.1 → 2.0.2

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
  SHA1:
3
- metadata.gz: c116c2740ae215eb52a565ee4df2ec5b4b07584d
4
- data.tar.gz: c3d46b174d92a572312b1f0c395b634681a404f2
3
+ metadata.gz: 5522423e565a186cb510bff658b46dc95a6faafa
4
+ data.tar.gz: 6a56306cc43c2e35376372f0a48283f8217030cc
5
5
  SHA512:
6
- metadata.gz: 38af43a34b5ec730fc8bc7d753e0c89946e2a3eebed7344f4043e838c2c6641c561e20baccbc9c72162cf536d5a353d92ece005e7a7fd57f554fa69efee8ab30
7
- data.tar.gz: 1b8d26d8ddbb3a8762ab87fd7c92e46edc4ab9be4232c2604c98e2176be29ed88af43efba217906336c96b500d61e9d4e3ff4d8a896baad1eebfa0cfcc59ea96
6
+ metadata.gz: db2cbcff7dad08c6b5f84fbf59f6400c734da6d723a6b453d36c7e5ca88814f55e26cb0100fe7989e7a7f4f29358bed8dcab4bc670982c993329a05e7566ee34
7
+ data.tar.gz: 962fb927bd78ef64b90f0de95cef9042bf06be1c489af1c0901fa9a2ab7eb517dd9aa11f642a79fb1235d0e625e7fcd024d873e88041c1d9f4f31cde1093027f
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-translate'
4
- s.version = '2.0.1'
4
+ s.version = '2.0.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "A general search and replace tool which uses a configured hash and/or a YAML file to determine replacement values."
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/plugin install gemname. This gem is not a stand-alone program"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
@@ -3,100 +3,120 @@ require "logstash/devutils/rspec/spec_helper"
3
3
  require "logstash/filters/translate"
4
4
 
5
5
  describe LogStash::Filters::Translate do
6
-
6
+
7
+ let(:config) { Hash.new }
8
+ subject { described_class.new(config) }
7
9
 
8
10
  describe "exact translation" do
9
- config <<-CONFIG
10
- filter {
11
- translate {
12
- field => "status"
13
- destination => "translation"
14
- dictionary => [ "200", "OK",
11
+
12
+ let(:config) do
13
+ {
14
+ "field" => "status",
15
+ "destination" => "translation",
16
+ "dictionary" => [ "200", "OK",
15
17
  "300", "Redirect",
16
18
  "400", "Client Error",
17
- "500", "Server Error" ]
18
- exact => true
19
- regex => false
20
- }
19
+ "500", "Server Error" ],
20
+ "exact" => true,
21
+ "regex" => false
21
22
  }
22
- CONFIG
23
+ end
24
+
25
+ let(:event) { LogStash::Event.new("status" => 200) }
23
26
 
24
- sample("status" => 200) do
25
- insist { subject["translation"] } == "OK"
27
+ it "return the exact translation" do
28
+ subject.register
29
+ subject.filter(event)
30
+ expect(event["translation"]).to eq("OK")
26
31
  end
27
32
  end
28
33
 
34
+
29
35
  describe "multi translation" do
30
- config <<-CONFIG
31
- filter {
32
- translate {
33
- field => "status"
34
- destination => "translation"
35
- dictionary => [ "200", "OK",
36
+
37
+ let(:config) do
38
+ {
39
+ "field" => "status",
40
+ "destination" => "translation",
41
+ "dictionary" => [ "200", "OK",
36
42
  "300", "Redirect",
37
43
  "400", "Client Error",
38
- "500", "Server Error" ]
39
- exact => false
40
- regex => false
41
- }
44
+ "500", "Server Error" ],
45
+ "exact" => false,
46
+ "regex" => false
42
47
  }
43
- CONFIG
48
+ end
44
49
 
45
- sample("status" => "200 & 500") do
46
- insist { subject["translation"] } == "OK & Server Error"
50
+ let(:event) { LogStash::Event.new("status" => "200 & 500") }
51
+
52
+ it "return the exact translation" do
53
+ subject.register
54
+ subject.filter(event)
55
+ expect(event["translation"]).to eq("OK & Server Error")
47
56
  end
57
+
48
58
  end
49
59
 
50
60
  describe "regex translation" do
51
- config <<-CONFIG
52
- filter {
53
- translate {
54
- field => "status"
55
- destination => "translation"
56
- dictionary => [ "^2[0-9][0-9]$", "OK",
61
+
62
+ let(:config) do
63
+ {
64
+ "field" => "status",
65
+ "destination" => "translation",
66
+ "dictionary" => [ "^2[0-9][0-9]$", "OK",
57
67
  "^3[0-9][0-9]$", "Redirect",
58
68
  "^4[0-9][0-9]$", "Client Error",
59
- "^5[0-9][0-9]$", "Server Error" ]
60
- exact => true
61
- regex => true
62
- }
69
+ "^5[0-9][0-9]$", "Server Error" ],
70
+ "exact" => true,
71
+ "regex" => true
63
72
  }
64
- CONFIG
73
+ end
65
74
 
66
- sample("status" => "200") do
67
- insist { subject["translation"] } == "OK"
75
+ let(:event) { LogStash::Event.new("status" => "200") }
76
+
77
+ it "return the exact translation" do
78
+ subject.register
79
+ subject.filter(event)
80
+ expect(event["translation"]).to eq("OK")
68
81
  end
69
82
  end
70
83
 
71
- describe "fallback value - static configuration" do
72
- config <<-CONFIG
73
- filter {
74
- translate {
75
- field => "status"
76
- destination => "translation"
77
- fallback => "no match"
84
+ describe "fallback value" do
85
+
86
+ context "static configuration" do
87
+ let(:config) do
88
+ {
89
+ "field" => "status",
90
+ "destination" => "translation",
91
+ "fallback" => "no match"
78
92
  }
79
- }
80
- CONFIG
93
+ end
94
+
95
+ let(:event) { LogStash::Event.new("status" => "200") }
81
96
 
82
- sample("status" => "200") do
83
- insist { subject["translation"] } == "no match"
97
+ it "return the exact translation" do
98
+ subject.register
99
+ subject.filter(event)
100
+ expect(event["translation"]).to eq("no match")
101
+ end
84
102
  end
85
- end
86
103
 
87
- describe "fallback value - allow sprintf" do
88
- config <<-CONFIG
89
- filter {
90
- translate {
91
- field => "status"
92
- destination => "translation"
93
- fallback => "%{missing_translation}"
104
+ context "allow sprintf" do
105
+ let(:config) do
106
+ {
107
+ "field" => "status",
108
+ "destination" => "translation",
109
+ "fallback" => "%{missing_translation}"
94
110
  }
95
- }
96
- CONFIG
111
+ end
112
+
113
+ let(:event) { LogStash::Event.new("status" => "200", "missing_translation" => "missing no match") }
97
114
 
98
- sample("status" => "200", "missing_translation" => "no match") do
99
- insist { subject["translation"] } == "no match"
115
+ it "return the exact translation" do
116
+ subject.register
117
+ subject.filter(event)
118
+ expect(event["translation"]).to eq("missing no match")
119
+ end
100
120
  end
101
121
  end
102
122
 
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - '>='
17
17
  - !ruby/object:Gem::Version
18
- version: 2.0.0.snapshot
18
+ version: 2.0.0.beta2
19
19
  - - <
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.0.0.snapshot
29
+ version: 2.0.0.beta2
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0