fluent-plugin-rewrite 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "fluent-plugin-rewrite"
3
- gem.version = '0.0.4'
3
+ gem.version = '0.0.5'
4
4
  gem.authors = ["Kentaro Kuribayashi"]
5
5
  gem.email = ["kentarok@gmail.com"]
6
6
  gem.homepage = "http://github.com/kentaro/fluent-plugin-rewrite"
@@ -58,7 +58,7 @@ module Fluent
58
58
  if @remove_prefix and
59
59
  ((tag.start_with?(@removed_prefix_string) && tag.length > @removed_length) ||
60
60
  tag == @remove_prefix)
61
- tag = tag[@removed_length..-1]
61
+ tag = tag[@removed_length..-1] || ''
62
62
  end
63
63
 
64
64
  if @add_prefix
@@ -94,9 +94,9 @@ module Fluent
94
94
 
95
95
  if rule["append_to_tag"]
96
96
  if rule["tag"]
97
- tag << ".#{rule["tag"]}"
97
+ tag << (tag == "" ? "" : ".") << "#{rule["tag"]}"
98
98
  else
99
- matched.captures.each { |m| tag << ".#{m}" }
99
+ matched.captures.each { |m| tag << (tag == "" ? "" : ".") << "#{m}" }
100
100
  end
101
101
  end
102
102
 
@@ -158,6 +158,37 @@ class RewriteOutputTest < Test::Unit::TestCase
158
158
  [ "test", { "is_logged_in" => "0" } ],
159
159
  d3.instance.rewrite("test", { "is_logged_in" => "0" })
160
160
  )
161
+
162
+ d4 = create_driver(%[
163
+ remove_prefix test
164
+
165
+ <rule>
166
+ key path
167
+ pattern ^\/(users|entries)
168
+ append_to_tag true
169
+ </rule>
170
+ ])
171
+
172
+ assert_equal(
173
+ [ "users", { "path" => "/users/antipop" } ],
174
+ d4.instance.rewrite("test", { "path" => "/users/antipop" })
175
+ )
176
+
177
+ d5 = create_driver(%[
178
+ remove_prefix test
179
+
180
+ <rule>
181
+ key is_logged_in
182
+ pattern 1
183
+ append_to_tag true
184
+ tag user
185
+ </rule>
186
+ ])
187
+
188
+ assert_equal(
189
+ [ "user", { "is_logged_in" => "1" } ],
190
+ d5.instance.rewrite("test", { "is_logged_in" => "1" })
191
+ )
161
192
  end
162
193
 
163
194
  def test_last
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-rewrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: