mirror of
https://github.com/meineerde/rackstash.git
synced 2026-01-31 17:27:13 +00:00
Ignore blank tags
This commit is contained in:
parent
e9c98fc648
commit
95bf8430a9
@ -17,7 +17,7 @@ module Rackstash
|
||||
def <<(tag)
|
||||
tag = resolve_value(tag)
|
||||
tag = utf8_encode(tag).freeze
|
||||
@raw << tag
|
||||
@raw << tag unless tag.empty?
|
||||
self
|
||||
end
|
||||
|
||||
@ -41,7 +41,10 @@ module Rackstash
|
||||
end
|
||||
|
||||
def merge!(tags, scope: nil)
|
||||
@raw.merge normalize_tags(tags, scope: scope)
|
||||
tags = normalize_tags(tags, scope: scope)
|
||||
tags.reject!(&:empty?)
|
||||
|
||||
@raw.merge tags
|
||||
self
|
||||
end
|
||||
|
||||
@ -69,7 +72,7 @@ module Rackstash
|
||||
value.flatten!
|
||||
value
|
||||
else
|
||||
utf8_encode(value).freeze
|
||||
utf8_encode(value).strip.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -87,7 +87,7 @@ describe Rackstash::Fields::Tags do
|
||||
expect(tags.to_a).to eql ['foo', 'bar']
|
||||
|
||||
tags.merge! [123, 'foo', nil]
|
||||
expect(tags.to_a).to eql ['foo', 'bar', '123', '']
|
||||
expect(tags.to_a).to eql ['foo', 'bar', '123']
|
||||
|
||||
expect(tags.to_a).to all be_frozen
|
||||
end
|
||||
@ -123,7 +123,7 @@ describe Rackstash::Fields::Tags do
|
||||
end
|
||||
|
||||
describe '#tagged?' do
|
||||
it 'checks is the argument is tagged' do
|
||||
it 'checks if the argument is tagged' do
|
||||
tags.merge! ['foo', '123']
|
||||
|
||||
expect(tags.tagged?('foo')).to be true
|
||||
@ -144,7 +144,7 @@ describe Rackstash::Fields::Tags do
|
||||
|
||||
expect(tags.to_set.include?('foo')).to be true
|
||||
expect(tags.to_set.include?(nil)).to be false
|
||||
expect(tags.to_set.include?('')).to be true
|
||||
expect(tags.to_set.include?('')).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user