logstash-input-rss 0.1.4 → 2.0.1

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: 17bd99754667eeb1a14e5644c9bbee42b36f7662
4
- data.tar.gz: 4234132155000c65aad31aae2b2e0bffd6225e7a
3
+ metadata.gz: 3052f6479914280e303878361fb7b0e2d8aba99b
4
+ data.tar.gz: fce5d598d3b75be9e043bc13287d116df35e5bc4
5
5
  SHA512:
6
- metadata.gz: 058123631f8790cf09782ef85728bc3cb193fbacd069e0904f52580ef8914eb53b2247ccab732cdef215bdd23a6f54f03533dad7eece2f9a9f5c38eb1f93df12
7
- data.tar.gz: 119f51991290cc49118b3bae85185427c4f7a768f767f554321378792ed8470a1d62b3352d0277e8b61559a18da388d15a01ad1a08b15a72ab36d1491f590544
6
+ metadata.gz: b69f1ca6e81488667aa9e2fc82ba73067cde200392d71f8c10ec9f24cdfc9bce29bc7ba3206ff345ad8697c240b9506caab04cdd380b8e0f620e3e52772cab61
7
+ data.tar.gz: 239bd0fc9ec8098e94847ef84fd5b50058b480a8e57547702c3f0370d5a72e5beb969d0583a1f49fb609ba1eb0d75c5939bfbd2b8ec5313b7da8d385204e3f72
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 2.0.0
2
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
+ - Dependency on logstash-core update to 2.0
5
+
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/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
7
  ## Documentation
8
8
 
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/).
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.elastic.co/guide/en/logstash/current/).
10
10
 
11
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
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
16
- Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
17
 
18
18
  ## Developing
19
19
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -2,6 +2,9 @@
2
2
  require "logstash/inputs/base"
3
3
  require "logstash/namespace"
4
4
  require "socket" # for Socket.gethostname
5
+ require "stud/interval"
6
+ require "faraday"
7
+ require "rss"
5
8
 
6
9
  # Run command line tools and capture the whole output as an event.
7
10
  #
@@ -25,57 +28,20 @@ class LogStash::Inputs::Rss < LogStash::Inputs::Base
25
28
 
26
29
  public
27
30
  def register
28
- require "faraday"
29
- require "rss"
30
31
  @logger.info("Registering RSS Input", :url => @url, :interval => @interval)
31
32
  end # def register
32
33
 
33
34
  public
34
35
  def run(queue)
35
- loop do
36
+ @run_thread = Thread.current
37
+ while !stop?
36
38
  start = Time.now
37
39
  @logger.info? && @logger.info("Polling RSS", :url => @url)
38
40
 
39
41
  # Pull down the RSS feed using FTW so we can make use of future cache functions
40
42
  response = Faraday.get @url
41
- body = response.body
42
- # @logger.debug("Body", :body => body)
43
- # Parse the RSS feed
44
- feed = RSS::Parser.parse(body)
45
- feed.items.each do |item|
46
- # Put each item into an event
47
- @logger.debug("Item", :item => item.author)
48
- case feed.feed_type
49
- when 'rss'
50
- @codec.decode(item.description) do |event|
51
- event["Feed"] = @url
52
- event["published"] = item.pubDate
53
- event["title"] = item.title
54
- event["link"] = item.link
55
- event["author"] = item.author
56
- decorate(event)
57
- queue << event
58
- end
59
- when 'atom'
60
- if ! item.content.nil?
61
- content = item.content.content
62
- else
63
- content = item.summary.content
64
- end
65
- @codec.decode(content) do |event|
66
- event["Feed"] = @url
67
- event["updated"] = item.updated.content
68
- event["title"] = item.title.content
69
- event["link"] = item.link.href
70
- event["author"] = item.author.name.content
71
- unless item.published.nil?
72
- event["published"] = item.published.content
73
- end
74
- decorate(event)
75
- queue << event
76
- end
77
- end
78
- end
43
+ handle_response(response)
44
+
79
45
  duration = Time.now - start
80
46
  @logger.info? && @logger.info("Command completed", :command => @command,
81
47
  :duration => duration)
@@ -88,8 +54,53 @@ class LogStash::Inputs::Rss < LogStash::Inputs::Base
88
54
  :command => @command, :duration => duration,
89
55
  :interval => @interval)
90
56
  else
91
- sleep(sleeptime)
57
+ Stud.stoppable_sleep(sleeptime) { stop? }
92
58
  end
93
59
  end # loop
94
- end # def run
60
+ end
61
+
62
+ def handle_response(response)
63
+ body = response.body
64
+ # @logger.debug("Body", :body => body)
65
+ # Parse the RSS feed
66
+ feed = RSS::Parser.parse(body)
67
+ feed.items.each do |item|
68
+ # Put each item into an event
69
+ @logger.debug("Item", :item => item.author)
70
+ case feed.feed_type
71
+ when 'rss'
72
+ @codec.decode(item.description) do |event|
73
+ event["Feed"] = @url
74
+ event["published"] = item.pubDate
75
+ event["title"] = item.title
76
+ event["link"] = item.link
77
+ event["author"] = item.author
78
+ decorate(event)
79
+ queue << event
80
+ end
81
+ when 'atom'
82
+ if ! item.content.nil?
83
+ content = item.content.content
84
+ else
85
+ content = item.summary.content
86
+ end
87
+ @codec.decode(content) do |event|
88
+ event["Feed"] = @url
89
+ event["updated"] = item.updated.content
90
+ event["title"] = item.title.content
91
+ event["link"] = item.link.href
92
+ event["author"] = item.author.name.content
93
+ unless item.published.nil?
94
+ event["published"] = item.published.content
95
+ end
96
+ decorate(event)
97
+ queue << event
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def stop
104
+ Stud.stop!(@run_thread) if @run_thread
105
+ end
95
106
  end # class LogStash::Inputs::Exec
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-rss'
4
- s.version = '0.1.4'
4
+ s.version = '2.0.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Poll an RSS/Atom feed."
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"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
14
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -20,10 +20,11 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
24
-
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
25
24
  s.add_runtime_dependency 'logstash-codec-plain'
26
25
  s.add_runtime_dependency 'addressable'
26
+ s.add_runtime_dependency 'faraday'
27
+ s.add_runtime_dependency 'stud', "~> 0.0.22"
27
28
 
28
29
  s.add_development_dependency 'logstash-devutils'
29
30
  end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/inputs/rss"
4
+
5
+ describe LogStash::Inputs::Rss do
6
+ describe "stopping" do
7
+ let(:config) { {"url" => "localhost", "interval" => 10} }
8
+ before do
9
+ allow(Faraday).to receive(:get)
10
+ allow(subject).to receive(:handle_response)
11
+ end
12
+ it_behaves_like "an interruptible input plugin"
13
+ end
14
+ end
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - '>='
17
17
  - !ruby/object:Gem::Version
18
- version: 1.4.0
18
+ version: 2.0.0.snapshot
19
19
  - - <
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0
21
+ version: 3.0.0
22
22
  name: logstash-core
23
23
  prerelease: false
24
24
  type: :runtime
@@ -26,10 +26,10 @@ dependencies:
26
26
  requirements:
27
27
  - - '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.4.0
29
+ version: 2.0.0.snapshot
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
@@ -58,6 +58,34 @@ dependencies:
58
58
  - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: faraday
68
+ prerelease: false
69
+ type: :runtime
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ~>
79
+ - !ruby/object:Gem::Version
80
+ version: 0.0.22
81
+ name: stud
82
+ prerelease: false
83
+ type: :runtime
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 0.0.22
61
89
  - !ruby/object:Gem::Dependency
62
90
  requirement: !ruby/object:Gem::Requirement
63
91
  requirements:
@@ -78,11 +106,12 @@ executables: []
78
106
  extensions: []
79
107
  extra_rdoc_files: []
80
108
  files:
109
+ - CHANGELOG.md
81
110
  - CONTRIBUTORS
82
111
  - Gemfile
83
112
  - LICENSE
113
+ - NOTICE.TXT
84
114
  - README.md
85
- - Rakefile
86
115
  - lib/logstash/inputs/rss.rb
87
116
  - logstash-input-rss.gemspec
88
117
  - spec/inputs/rss_spec.rb
@@ -108,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
137
  version: '0'
109
138
  requirements: []
110
139
  rubyforge_project:
111
- rubygems_version: 2.1.9
140
+ rubygems_version: 2.4.8
112
141
  signing_key:
113
142
  specification_version: 4
114
143
  summary: Poll an RSS/Atom feed.
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- @files=[]
2
-
3
- task :default do
4
- system("rake -T")
5
- end
6
-
7
- require "logstash/devutils/rake"