logstash-filter-languagedetect 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTU0NTY0ODEwZTZhYWE0NjY0MjJkMmQ5NzhkNzhlZDZjMGZkNGJiNA==
4
+ NzczODI1YjUxZmFiZmY4NmY3ZGM4Mjc0MWM1ZmEwZTdhNGM0NmUwNA==
5
5
  data.tar.gz: !binary |-
6
- NjgxMGUxNWFlYTgxOTkxMjBmMWQ5NDBiNjBjMWNlNWNlZmZlMDY4NQ==
6
+ N2U2MDZiZDkzMDYzYWUwZWIzYjY0YjI4MzI1N2Y0ZjE4NTEzYmFlMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTczYjUzMjI2MWE1OGQxN2QyOWUwZDcyYmNmM2NmNTU0MmE4NDVlNjk4MmJl
10
- NGU5NmQ3ODM4MDFhYjQwNzFjN2U3NWM2M2U2YTMyMGM5NGIzMGUwZDcwNWNj
11
- MWI2ZGE5ZGMzMmNlMzBiZmJhMzY2N2RjZGQzYjc5NzM5NTE2M2I=
9
+ MTQ2NmJlMzliZGY1YjQ2M2Y3ZjYyNDFkODJjNDA3YTMwNjE2NDM4NmZhYTk3
10
+ YWJhYWVjOWRkNmM5NWJkNzk5MWY5ZjQ2YTFiZDBhMTk0N2RjOGVhZDYzMjQ4
11
+ YmRmNWMxMjlhZTNhYTgyMTQ4M2Q2YjUzNmYzZGY1YzYzYjhmZjU=
12
12
  data.tar.gz: !binary |-
13
- MDM1Y2FkOWQwMGRjZTFiOWIxYjM2MTgxZDAyZjNmZDVkYTc5NTExYTA4Yjhm
14
- ZjA4NTI5NGQ5Y2E0Y2Y2OGUzYzFlZmVjMjY0YjAxNjZjNjM0YTc4ZGE2MTQz
15
- MmZhZTJiNWEwMDE0MzJhODA0Mzg0Njk0NjYwNTg3OGQ3OTUzNDY=
13
+ OWE3ZmNiNGIzNjdjOGEzOTNjN2M3ZjQzNTE2ZDk0ZDUxZmExNDEzMDU3NzFh
14
+ ODRkNWJlMTA4NGE3MmEwMmQ4M2M0OGU1NDg0Y2E3MGMxMjJiYWJiZmMyOGMx
15
+ MTg5ZTcwYjhjZjgwZmZhZWE3MmUyNjJjNDUzYzM4ZmQ3MGJlODI=
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.bak
4
4
  .bundle
5
5
  vendor
6
6
  .idea/
7
+ coverage/
data/.travis.yml CHANGED
@@ -1,16 +1,17 @@
1
1
  language: ruby
2
2
  rvm:
3
- - jruby-1.7.20
4
- # - jruby-19mode
5
- # - jruby-head
6
- #jdk:
7
- # - openjdk7
8
- # - oraclejdk7
9
- # - oraclejdk8
3
+ - jruby-1.7.20
10
4
  before_install:
11
- - gem install bundler -v 1.10.1
5
+ - gem install bundler -v 1.10.1
12
6
  script: bundle exec rspec
13
7
  deploy:
14
8
  provider: rubygems
15
9
  api_key:
16
10
  secure: J3/E3dTIv1ZkCLLbDj0EJVh5toxHOACsqjTuoUjwnV0dc6GQsqhlgxxOebtOU+LMyO7WaXncPH9Yy3zYpI2G7hulOczGiF+9JG1SqysMg0RS5LX0lyZlE8UPb/C3ILKPAbMfyrp/dMhS+9M36p6ZOjtS2PMXVgAi/tUUvFEgXLmoi1yzfbG1Dy0JLOURPgLdKgXdV54VxxPb/V3YZXq2S0XVu5MTDQOJoblYJ6RyBfkFVcDoSFI3qBUD6m2xmw1qpv0rfiKEZmiImpTi1/jOIxBEIIARBi0X1RWM1p/mOcXxiWMpJ925crYftibd39acuAO2bIMiYyeevB76QhM4va+OlQ1/yHe85EibixH+kRL7Xd99j+Ouwdpa6m14M8NWFo2Lx3Rr99MjAYeDNMV++OBS3KBMmyAZIqA/sosAjnzMeZHFKRxRMdkZW1/AFHkXVcOFYIIGn83l0ciLBFpjRnDimBN2KVA6Alslu7+qPGEuQKTSEpVZF1uNui+tF1z/MgnllX1IMnNN4RODNbYKAUc+drL2nRit1QCnUAR7BYZ7Q4LcmcSmnGX2dPD1ovUSbiCNDbWCDecZAd2TFqbMn9Bgx9jHyNgfo4yEednDgrYmk1OGNExIunWJckirYBhYGDQN4Lv39Kb4Xyqe4jV35HvYVZIKBwnSyHIfwJykFeA=
11
+ after_success:
12
+ - coveralls
13
+ addons:
14
+ code_climate:
15
+ repo_token:
16
+ secure: vzwI+AOiJguz+WBpkjrKZg3WRhVoOefFN2QHb1OqREiD9lewxGAD13d2xAphUU8V+rimUBzaSTwj3pdJ3/Ap11Y05IqRcaLE9E+fvWj4sRRHWR5l8A4KLlQKE11erHfBa2EC8jrh00MrtBsNU37e10YvXQhN2XsPQI+1QG8RGUDjZ0yFXVPoDbnzLw7q333nzbz5zpzcBCgfTxljaO6oNG1MzRgs0l/To/oJV9pyHtYkHALIUjlt9racBDG+i+EehrzqmBKHWDKYpOW6Yzy158Fz8w8BVw7dabDXyfxSp9r0YFK0Ca8V1GCvMD3YNh8zG1EgH9cRWgaI1dscof1MAT4YpAy978D0/c0ssKHF3ElAT+3InlirtZr9kMN4lTLwAgGlTsERW6qKc/mroh6axCftY2NFJeWe9rnt+z9GHfUO6tZZ5Y5VY/zngBJkZDyL0sDxCg3IkD7EeCRqbP/IMUkateMn9Ju7zNT0l4Pva6a+vEWOv20+U7EYJ0sBAEsXejo+fy0+lN9tzxF/H2es2HCmwBabcV1qHUHsrSS17+S37djxeW8/MKdepk2jFA6AULVkuITUezWxAxUPNeqED/nSO90iN488CLv6pf7uiAwbv0kooKqsN0HPjI/bqw1R5h2kwBcRrNoHQ63Ndf+UWznVSanF1sYct0GcV/CPmOo=
17
+ cache: bundler
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
- gem 'whatlanguage', :git => "https://github.com/peterc/whatlanguage.git", :ref => "0192301022"
3
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -4,83 +4,23 @@ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
- ## Documentation
7
+ # Status
8
+ - [![Gem Version](https://badge.fury.io/rb/logstash-filter-languagedetect.svg)](http://badge.fury.io/rb/logstash-filter-languagedetect)
9
+ - [![Build Status](https://travis-ci.org/torstenfeld/logstash-filter-languagedetect.svg?branch=master)](https://travis-ci.org/torstenfeld/logstash-filter-languagedetect) (master)
10
+ - [![Coverage Status](https://coveralls.io/repos/torstenfeld/logstash-filter-languagedetect/badge.svg)](https://coveralls.io/r/torstenfeld/logstash-filter-languagedetect)
11
+ - [![Code Climate](https://codeclimate.com/github/torstenfeld/logstash-filter-languagedetect/badges/gpa.svg)](https://codeclimate.com/github/torstenfeld/logstash-filter-languagedetect)
12
+ - [![Dependency Status](https://gemnasium.com/torstenfeld/logstash-filter-languagedetect.svg)](https://gemnasium.com/torstenfeld/logstash-filter-languagedetect)
8
13
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
14
+ # Installation
10
15
 
11
- - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
-
14
- ## Need Help?
15
-
16
- Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
-
18
- ## Developing
19
-
20
- ### 1. Plugin Developement and Testing
21
-
22
- #### Code
23
- - To get started, you'll need JRuby with the Bundler gem installed.
24
-
25
- - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
-
27
- - Install dependencies
28
- ```sh
29
- bundle install
30
- ```
31
-
32
- #### Test
33
-
34
- - Update your dependencies
35
-
36
- ```sh
37
- bundle install
38
- ```
39
-
40
- - Run tests
41
-
42
- ```sh
43
- bundle exec rspec
44
- ```
45
-
46
- ### 2. Running your unpublished Plugin in Logstash
47
-
48
- #### 2.1 Run in a local Logstash clone
49
-
50
- - Edit Logstash `Gemfile` and add the local plugin path, for example:
16
+ - Edit Logstash `Gemfile` and add needed requirements:
51
17
  ```ruby
52
- gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
- ```
54
- - Install plugin
55
- ```sh
56
- bin/plugin install --no-verify
57
- ```
58
- - Run Logstash with your plugin
59
- ```sh
60
- bin/logstash -e 'filter {awesome {}}'
18
+ gem "whatlanguage", :git => "https://github.com/peterc/whatlanguage.git", :ref => "0192301022"
19
+ gem "logstash-filter-languagedetect", ">= 0.1.1", :git => "https://github.com/torstenfeld/logstash-filter-languagedetect.git"
61
20
  ```
62
- At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
21
 
64
- #### 2.2 Run in an installed Logstash
65
22
 
66
- You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
-
68
- - Build your plugin gem
69
- ```sh
70
- gem build logstash-filter-awesome.gemspec
71
- ```
72
- - Install the plugin from the Logstash home
23
+ - Install and update dependencies
73
24
  ```sh
74
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
25
+ bundle install
75
26
  ```
76
- - Start Logstash and proceed to test the plugin
77
-
78
- ## Contributing
79
-
80
- All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
-
82
- Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
83
-
84
- It is more important to the community that you are able to contribute.
85
-
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -65,10 +65,34 @@ class LogStash::Filters::Languagedetect < LogStash::Filters::Base
65
65
  def filter(event)
66
66
 
67
67
  text_to_detect = event[@source]
68
+ lang_found = @wl.language(text_to_detect)
69
+
68
70
  if @useiso
69
- lang_found = @wl.language_iso(text_to_detect)
70
- else
71
- lang_found = @wl.language(text_to_detect)
71
+ iso_codes = {
72
+ nil => nil,
73
+ :arabic => :ar,
74
+ :danish => :da,
75
+ :dutch => :nl,
76
+ :english => :en,
77
+ :farsi => :fa,
78
+ :finnish => :fi,
79
+ :french => :fr,
80
+ :german => :de,
81
+ :greek => :el,
82
+ :hebrew => :he,
83
+ :hungarian => :hu,
84
+ :italian => :it,
85
+ :korean => :ko,
86
+ :norwegian => :no,
87
+ :pinyin => :zh,
88
+ :polish => :pl,
89
+ :portuguese => :pt,
90
+ :russian => :ru,
91
+ :spanish => :es,
92
+ :swedish => :sv
93
+ }
94
+
95
+ lang_found = iso_codes[lang_found]
72
96
  end
73
97
 
74
98
  event[@target] = lang_found.to_s.force_encoding(Encoding::UTF_8)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-languagedetect'
3
- s.version = '0.1.1'
4
- s.version = "#{s.version}.pre.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS_BRANCH'] != 'master'
3
+ s.version = '0.2.0'
4
+ s.version = "#{s.version}.pre.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS'] and ENV['TRAVIS_BRANCH'] != 'master'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This example filter replaces the contents of the message field with the specified value."
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  # Files
14
14
  s.files = `git ls-files`.split($\)
15
- # Tests
15
+ # Tests
16
16
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
17
 
18
18
  # Special flag to let us know this is actually a logstash plugin
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # Gem dependencies
22
22
  s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
23
- s.add_runtime_dependency "whatlanguage", '>= 1.0.6'
23
+ s.add_runtime_dependency "whatlanguage", '~> 1.0.5'
24
24
  s.add_development_dependency 'logstash-devutils'
25
+ s.add_development_dependency 'coveralls', '~> 0.8.1'
25
26
  end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,3 @@
1
1
  require "logstash/devutils/rspec/spec_helper"
2
+ require "coveralls"
3
+ Coveralls.wear!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-languagedetect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torsten Feld
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: whatlanguage
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: 1.0.6
39
+ version: 1.0.5
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ! '>='
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.6
46
+ version: 1.0.5
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: logstash-devutils
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - ! '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: coveralls
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.8.1
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.8.1
61
75
  description: This gem is a logstash plugin required to be installed on top of the
62
76
  Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
63
77
  a stand-alone program
@@ -66,6 +80,7 @@ executables: []
66
80
  extensions: []
67
81
  extra_rdoc_files: []
68
82
  files:
83
+ - .coveralls.yml
69
84
  - .gitignore
70
85
  - .travis.yml
71
86
  - CHANGELOG.md