Skip to content

Commit

Permalink
Update this plugin to the v2.0 of the plugin api
Browse files Browse the repository at this point in the history
  • Loading branch information
ph committed May 2, 2016
1 parent 2bfb051 commit 5a19569
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
sudo: false
language: ruby
cache: bundler
rvm:
- jruby-1.7.23
script:
- bundle exec rspec spec
- jruby-1.7.25
script:
- bundle exec rspec spec
jdk: oraclejdk8
before_install:
- git clone -b feature/event_interface https://github.com/elastic/logstash
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
source 'https://rubygems.org'
gemspec
gemspec
gem "logstash-core", :path => "./logstash/logstash-core"
gem "logstash-core-plugin-api", :path => "./logstash/logstash-core-plugin-api"
gem "logstash-core-event-java", :path => "./logstash/logstash-core-event-java"
gem "logstash-devutils", :github => "elastic/logstash-devutils", :branch => "feature/plugin-api-2_0"
6 changes: 3 additions & 3 deletions lib/logstash/filters/uuid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def filter(event)
# only UTF8 strings can be passed to a LogStash::Event
# we need to reencode it here
if overwrite
event[target] = SecureRandom.uuid.force_encoding(Encoding::UTF_8)
else
event[target] ||= SecureRandom.uuid.force_encoding(Encoding::UTF_8)
event.set(target, SecureRandom.uuid.force_encoding(Encoding::UTF_8))
elsif event.get(target).nil?
event.set(target, SecureRandom.uuid.force_encoding(Encoding::UTF_8))
end

filter_matched(event)
Expand Down
2 changes: 1 addition & 1 deletion logstash-filter-uuid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"

s.add_development_dependency 'logstash-devutils'
end
Expand Down
7 changes: 2 additions & 5 deletions spec/filters/uuid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
end

describe "generation" do

it "should generate an uuid field" do
subject.filter(event)
expect(event[target]).not_to be_nil
expect(event.get(target)).not_to be_nil
end

context "with overwrite" do
Expand All @@ -31,10 +30,8 @@

it "should override the target field" do
subject.filter(event)
expect(event[target]).not_to eq("foo")
expect(event.get(target)).not_to eq("foo")
end
end

end

end

0 comments on commit 5a19569

Please sign in to comment.