logstash-input-yasuri 2.0.7 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -5
- data/lib/logstash/inputs/yasuri.rb +5 -19
- data/logstash-input-yasuri.gemspec +2 -3
- data/spec/inputs/yasuri_spec.rb +0 -14
- metadata +5 -21
- data/spec/inputs/res/parse_tree.json +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01514669c8c47d9e53f8b7fa8a3a0129e1c9a5cb
|
4
|
+
data.tar.gz: a1078fac99cb7a486d365ce283e164756f585773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b160f2e2a878ccb774a4445ca7383468d9f3624de9a3ce82c31768f55ef4a4a90bc7413bbf2b613426762e9378a2c0a6e6466bd3428526320d037914fb1b7e5
|
7
|
+
data.tar.gz: 115196cd90bb7e3a86314280433f1bb2788241c8c160c235b8dca2655a4b447519a07633e7da09af13644f2eba4ea31d46516404615c28e920801b80560dc694
|
data/README.md
CHANGED
@@ -52,11 +52,6 @@ gem build logstash-input-yasuri
|
|
52
52
|
# generate logstash-input-yasuri-x.x.x.gem
|
53
53
|
```
|
54
54
|
|
55
|
-
- publish gem
|
56
|
-
```sh
|
57
|
-
bundle exec rake publish_gem
|
58
|
-
```
|
59
|
-
|
60
55
|
### 2. Running your unpublished Plugin in Logstash
|
61
56
|
|
62
57
|
#### 2.1 Run in a local Logstash clone
|
@@ -2,7 +2,6 @@
|
|
2
2
|
require "logstash/inputs/base"
|
3
3
|
require "logstash/namespace"
|
4
4
|
require "socket" # for Socket.gethostname
|
5
|
-
require "rufus-scheduler"
|
6
5
|
require "mechanize"
|
7
6
|
require "yasuri"
|
8
7
|
|
@@ -11,47 +10,35 @@ class LogStash::Inputs::Yasuri < LogStash::Inputs::Base
|
|
11
10
|
|
12
11
|
default :codec, "plain"
|
13
12
|
|
14
|
-
# logstash-input-yasuri require option :parse_tree or :parse_tree_path.
|
15
|
-
# If given both, logstash-input-yasuri use :parse_tree.
|
16
|
-
|
17
13
|
# Parse tree as JSON.
|
18
14
|
# Read https://github.com/tac0x2a/yasuri/blob/master/USAGE.md#construct-parse-tree
|
19
15
|
config :parse_tree, :validate => :string
|
20
16
|
|
21
|
-
# Path to parse tree JSON file.
|
22
|
-
config :parse_tree_path, :validate => :string
|
23
|
-
|
24
17
|
# Target web page url.
|
25
18
|
config :url, :validate => :string
|
26
19
|
|
27
20
|
# Split each results to individual events (struct or pages)
|
28
21
|
config :split, :default => false
|
29
22
|
|
30
|
-
config :
|
23
|
+
config :interval, :validate => :number, :default => 60
|
31
24
|
|
32
25
|
public
|
33
26
|
def register
|
34
27
|
@host = Socket.gethostname
|
35
28
|
@agent = Mechanize.new
|
36
|
-
@
|
37
|
-
|
38
|
-
# If given both, logstash-input-yasuri use :parse_tree.
|
39
|
-
tree = @parse_tree || File.read(@parse_tree_path)
|
40
|
-
|
41
|
-
@tree = Yasuri.json2tree(tree)
|
29
|
+
@tree = Yasuri.json2tree(@parse_tree)
|
42
30
|
end # def register
|
43
31
|
|
44
32
|
def run(queue)
|
45
33
|
# we can abort the loop if stop? becomes true
|
46
|
-
|
34
|
+
while !stop?
|
47
35
|
# because the sleep interval can be big, when shutdown happens
|
48
36
|
# we want to be able to abort the sleep
|
49
37
|
# Stud.stoppable_sleep will frequently evaluate the given block
|
50
38
|
# and abort the sleep(@interval) if the return value is true
|
51
39
|
inner_run(queue)
|
52
|
-
|
53
|
-
|
54
|
-
@scheduler.join
|
40
|
+
Stud.stoppable_sleep(@interval) { stop? }
|
41
|
+
end # loop
|
55
42
|
end # def run
|
56
43
|
|
57
44
|
def stop
|
@@ -60,7 +47,6 @@ class LogStash::Inputs::Yasuri < LogStash::Inputs::Base
|
|
60
47
|
# * close sockets (unblocking blocking reads/accepts)
|
61
48
|
# * cleanup temporary files
|
62
49
|
# * terminate spawned threads
|
63
|
-
@scheduler.shutdown
|
64
50
|
end
|
65
51
|
|
66
52
|
def inner_run(queue)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-yasuri'
|
3
|
-
s.version = '
|
3
|
+
s.version = '5.0.3'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Web scraping input plugin for logstash."
|
6
6
|
s.description = "Web scraping input plugin for logstash."
|
@@ -18,10 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
19
19
|
|
20
20
|
# Gem dependencies
|
21
|
-
s.add_runtime_dependency 'logstash-core-plugin-api', '~>
|
21
|
+
s.add_runtime_dependency 'logstash-core-plugin-api', '~> 2'
|
22
22
|
s.add_runtime_dependency 'stud', '>= 0.0.22'
|
23
23
|
s.add_runtime_dependency 'yasuri', '~> 1.9'
|
24
|
-
s.add_runtime_dependency 'rufus-scheduler', '>= 0'
|
25
24
|
|
26
25
|
s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
|
27
26
|
s.add_development_dependency 'logstash-codec-plain'
|
data/spec/inputs/yasuri_spec.rb
CHANGED
@@ -30,14 +30,6 @@ describe LogStash::Inputs::Yasuri do
|
|
30
30
|
)
|
31
31
|
}
|
32
32
|
|
33
|
-
let(:input_from_parse_tree_file) {
|
34
|
-
input_from_parse_tree_file = LogStash::Plugin.lookup("input", "yasuri").new(
|
35
|
-
"split" => true,
|
36
|
-
"url" => "https://news.ycombinator.com/",
|
37
|
-
"parse_tree_path" => "spec/inputs/res/parse_tree.json"
|
38
|
-
)
|
39
|
-
}
|
40
|
-
|
41
33
|
it "should register" do
|
42
34
|
# register will try to load jars and raise if it cannot find jars or if org.apache.log4j.spi.LoggingEvent class is not present
|
43
35
|
expect {input.register}.to_not raise_error
|
@@ -49,10 +41,4 @@ describe LogStash::Inputs::Yasuri do
|
|
49
41
|
input.inner_run(queue)
|
50
42
|
expect(queue.size).not_to be_zero
|
51
43
|
end
|
52
|
-
|
53
|
-
it "enqueues some events from input_from_parse_tree_file" do
|
54
|
-
input_from_parse_tree_file.register
|
55
|
-
input_from_parse_tree_file.inner_run(queue)
|
56
|
-
expect(queue.size).not_to be_zero
|
57
|
-
end
|
58
44
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-yasuri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tac0x2a
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 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: '
|
18
|
+
version: '2'
|
19
19
|
name: logstash-core-plugin-api
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.9'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
|
-
name: rufus-scheduler
|
62
|
-
prerelease: false
|
63
|
-
type: :runtime
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
requirement: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
@@ -122,7 +108,6 @@ files:
|
|
122
108
|
- README.md
|
123
109
|
- lib/logstash/inputs/yasuri.rb
|
124
110
|
- logstash-input-yasuri.gemspec
|
125
|
-
- spec/inputs/res/parse_tree.json
|
126
111
|
- spec/inputs/yasuri_spec.rb
|
127
112
|
homepage: https://github.com/tac0x2a/logstash-input-yasuri
|
128
113
|
licenses:
|
@@ -146,10 +131,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
131
|
version: '0'
|
147
132
|
requirements: []
|
148
133
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.6.
|
134
|
+
rubygems_version: 2.6.6
|
150
135
|
signing_key:
|
151
136
|
specification_version: 4
|
152
137
|
summary: Web scraping input plugin for logstash.
|
153
138
|
test_files:
|
154
|
-
- spec/inputs/res/parse_tree.json
|
155
139
|
- spec/inputs/yasuri_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"node": "struct",
|
3
|
-
"name": "titles",
|
4
|
-
"path": "//td[@class='title'][not(@align)]",
|
5
|
-
"children": [
|
6
|
-
{
|
7
|
-
"node": "text",
|
8
|
-
"name": "title",
|
9
|
-
"path": "./a"
|
10
|
-
},
|
11
|
-
{
|
12
|
-
"node": "text",
|
13
|
-
"name": "url",
|
14
|
-
"path": "./a/@href"
|
15
|
-
}
|
16
|
-
]
|
17
|
-
}
|