diff --git a/.travis.yml b/.travis.yml index 350c4eb..6b858e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Gemfile b/Gemfile index d926697..c781dcb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,6 @@ source 'https://rubygems.org' -gemspec \ No newline at end of file +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" diff --git a/lib/logstash/filters/uuid.rb b/lib/logstash/filters/uuid.rb index c15ff80..1e426c1 100644 --- a/lib/logstash/filters/uuid.rb +++ b/lib/logstash/filters/uuid.rb @@ -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) diff --git a/logstash-filter-uuid.gemspec b/logstash-filter-uuid.gemspec index f7fefd2..f420eac 100644 --- a/logstash-filter-uuid.gemspec +++ b/logstash-filter-uuid.gemspec @@ -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 diff --git a/spec/filters/uuid_spec.rb b/spec/filters/uuid_spec.rb index 9bed575..2067060 100644 --- a/spec/filters/uuid_spec.rb +++ b/spec/filters/uuid_spec.rb @@ -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 @@ -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