fluent-plugin-grepcounter 0.5.3 → 0.5.4

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
  SHA1:
3
- metadata.gz: 02fcfc4239d3f9c72ad1831c502ffa09c71552f8
4
- data.tar.gz: e341d89ebae652e888159f2e830c4ed3252dcc3d
3
+ metadata.gz: 90eca84d0b796ebd73afe0413d519a7d5d0517ec
4
+ data.tar.gz: 39accc620e237df5075a40d8c752535df1c9c989
5
5
  SHA512:
6
- metadata.gz: 530e25bea4620fe5798183dbb48d3c1a8a5b760fc05f28fed0bba103392ab65d02e19922946fc8b920945f069368cd0e6388885dd993dc8d77a389ed1171280a
7
- data.tar.gz: cf539ce20180ab51363a4e5f03cd46179b2530322f3d1f553cbd9e9942acda61eb307ae0a1f15407021765eee34fec55855b4877b67ea8b07601ecc4eaa84e32
6
+ metadata.gz: e6fc4b7c068508e720d119c8ce7ed41c1b686259aac99bdaa44dd3e1ecfb0274f92eb6371eab2aee7cef510a437aa5c65f0ecd9c6469af5d53965f9b1d6e0c01
7
+ data.tar.gz: fdf50b8f80388238581370f1491a967af796f2cd4dcebaca5be2a0293157a72d5b7098d4d36369193567843740ae8d42b8d8a552706deeaf21716f35ddb89e2e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.4 (2014/04/12)
2
+
3
+ Changes:
4
+
5
+ * Allow . in tag options to support compatibility with HandleTagNameMixin
6
+
1
7
  ## 0.5.3 (2014/04/11)
2
8
 
3
9
  Enhancement:
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-grepcounter"
6
- s.version = "0.5.3"
6
+ s.version = "0.5.4"
7
7
  s.authors = ["Naotoshi Seo"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-grepcounter"
@@ -97,22 +97,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
97
97
  if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil?
98
98
  @add_tag_prefix = 'count' # not ConfigError to support lower version compatibility
99
99
  end
100
- @tag_prefix = "#{@add_tag_prefix}." if @add_tag_prefix
101
- @tag_suffix = ".#{@add_tag_suffix}" if @add_tag_suffix
102
- @tag_prefix_match = "#{@remove_tag_prefix}." if @remove_tag_prefix
103
- @tag_suffix_match = ".#{@remove_tag_suffix}" if @remove_tag_suffix
104
- @tag_proc =
105
- if @tag
106
- Proc.new {|tag| @tag }
107
- elsif @tag_prefix_match and @tag_suffix_match
108
- Proc.new {|tag| "#{@tag_prefix}#{rstrip(lstrip(tag, @tag_prefix_match), @tag_suffix_match)}#{@tag_suffix}" }
109
- elsif @tag_prefix_match
110
- Proc.new {|tag| "#{@tag_prefix}#{lstrip(tag, @tag_prefix_match)}#{@tag_suffix}" }
111
- elsif @tag_suffix_match
112
- Proc.new {|tag| "#{@tag_prefix}#{rstrip(tag, @tag_suffix_match)}#{@tag_suffix}" }
113
- else
114
- Proc.new {|tag| "#{@tag_prefix}#{tag}#{@tag_suffix}" }
115
- end
100
+ @tag_proc = tag_proc
116
101
 
117
102
  case @aggregate
118
103
  when 'all'
@@ -249,12 +234,25 @@ class Fluent::GrepCounterOutput < Fluent::Output
249
234
  output
250
235
  end
251
236
 
252
- def rstrip(string, substring)
253
- string.chomp(substring)
254
- end
255
-
256
- def lstrip(string, substring)
257
- string.index(substring) == 0 ? string[substring.size..-1] : string
237
+ def tag_proc
238
+ rstrip = Proc.new {|str, substr| str.chomp(substr) }
239
+ lstrip = Proc.new {|str, substr| str.start_with?(substr) ? str[substr.size..-1] : str }
240
+ tag_prefix = "#{rstrip.call(@add_tag_prefix, '.')}." if @add_tag_prefix
241
+ tag_suffix = ".#{lstrip.call(@add_tag_suffix, '.')}" if @add_tag_suffix
242
+ tag_prefix_match = "#{rstrip.call(@remove_tag_prefix, '.')}." if @remove_tag_prefix
243
+ tag_suffix_match = ".#{lstrip.call(@remove_tag_suffix, '.')}" if @remove_tag_suffix
244
+ tag_fixed = @tag if @tag
245
+ if tag_fixed
246
+ Proc.new {|tag| tag_fixed }
247
+ elsif tag_prefix_match and tag_suffix_match
248
+ Proc.new {|tag| "#{tag_prefix}#{rstrip.call(lstrip.call(tag, tag_prefix_match), tag_suffix_match)}#{tag_suffix}" }
249
+ elsif tag_prefix_match
250
+ Proc.new {|tag| "#{tag_prefix}#{lstrip.call(tag, tag_prefix_match)}#{tag_suffix}" }
251
+ elsif tag_suffix_match
252
+ Proc.new {|tag| "#{tag_prefix}#{rstrip.call(tag, tag_suffix_match)}#{tag_suffix}" }
253
+ else
254
+ Proc.new {|tag| "#{tag_prefix}#{tag}#{tag_suffix}" }
255
+ end
258
256
  end
259
257
 
260
258
  def match(regexp, string)
@@ -355,6 +355,46 @@ describe Fluent::GrepCounterOutput do
355
355
  it { emit }
356
356
  end
357
357
 
358
+ context 'add_tag_prefix.' do
359
+ let(:config) { CONFIG + %[add_tag_prefix foo.] }
360
+ let(:tag) { 'syslog.host1' }
361
+ before do
362
+ Fluent::Engine.stub(:now).and_return(time)
363
+ Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
364
+ end
365
+ it { emit }
366
+ end
367
+
368
+ context 'remove_tag_prefix.' do
369
+ let(:config) { CONFIG + %[remove_tag_prefix syslog.] }
370
+ let(:tag) { 'syslog.host1' }
371
+ before do
372
+ Fluent::Engine.stub(:now).and_return(time)
373
+ Fluent::Engine.should_receive(:emit).with("host1", time, expected)
374
+ end
375
+ it { emit }
376
+ end
377
+
378
+ context '.add_tag_suffix' do
379
+ let(:config) { CONFIG + %[add_tag_suffix .foo] }
380
+ let(:tag) { 'syslog.host1' }
381
+ before do
382
+ Fluent::Engine.stub(:now).and_return(time)
383
+ Fluent::Engine.should_receive(:emit).with("#{tag}.foo", time, expected)
384
+ end
385
+ it { emit }
386
+ end
387
+
388
+ context '.remove_tag_suffix' do
389
+ let(:config) { CONFIG + %[remove_tag_suffix .host1] }
390
+ let(:tag) { 'syslog.host1' }
391
+ before do
392
+ Fluent::Engine.stub(:now).and_return(time)
393
+ Fluent::Engine.should_receive(:emit).with("syslog", time, expected)
394
+ end
395
+ it { emit }
396
+ end
397
+
358
398
  context 'output_with_joined_delimiter (obsolete)' do
359
399
  # \\n shall be \n in config file
360
400
  let(:config) { CONFIG + %[output_with_joined_delimiter \\n] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-grepcounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo