logstash-input-yasuri 5.0.3 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/logstash/inputs/yasuri.rb +11 -1
- data/logstash-input-yasuri.gemspec +1 -1
- data/spec/inputs/res/parse_tree.json +17 -0
- data/spec/inputs/yasuri_spec.rb +14 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e24cb2f310e23e273c52bc23bc984555bf682f17
|
4
|
+
data.tar.gz: 13ab2bbbd94c68087ec78d2bbba26a8f423b1b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97a3340efb2b5d13fc2fc76ef39d6888163f108d42ba058890e074fdb86b9ad17edc1ccca0d4e232a234466cbd71d6e82d9ed93f447a212125f0d91d5ed9c7a3
|
7
|
+
data.tar.gz: fe6a775469684d7572cd8db18f9b37eb187b5a4e4faf71da11b66f49237bff496e476bb0f969801af8475915edd079350b820d9d050c44b45794a5805631fa29
|
data/README.md
CHANGED
@@ -52,6 +52,11 @@ 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
|
+
|
55
60
|
### 2. Running your unpublished Plugin in Logstash
|
56
61
|
|
57
62
|
#### 2.1 Run in a local Logstash clone
|
@@ -10,10 +10,16 @@ class LogStash::Inputs::Yasuri < LogStash::Inputs::Base
|
|
10
10
|
|
11
11
|
default :codec, "plain"
|
12
12
|
|
13
|
+
# logstash-input-yasuri require option :parse_tree or :parse_tree_path.
|
14
|
+
# If given both, logstash-input-yasuri use :parse_tree.
|
15
|
+
|
13
16
|
# Parse tree as JSON.
|
14
17
|
# Read https://github.com/tac0x2a/yasuri/blob/master/USAGE.md#construct-parse-tree
|
15
18
|
config :parse_tree, :validate => :string
|
16
19
|
|
20
|
+
# Path to parse tree JSON file.
|
21
|
+
config :parse_tree_path, :validate => :string
|
22
|
+
|
17
23
|
# Target web page url.
|
18
24
|
config :url, :validate => :string
|
19
25
|
|
@@ -26,7 +32,11 @@ class LogStash::Inputs::Yasuri < LogStash::Inputs::Base
|
|
26
32
|
def register
|
27
33
|
@host = Socket.gethostname
|
28
34
|
@agent = Mechanize.new
|
29
|
-
|
35
|
+
|
36
|
+
# If given both, logstash-input-yasuri use :parse_tree.
|
37
|
+
tree = @parse_tree || File.read(@parse_tree_path)
|
38
|
+
|
39
|
+
@tree = Yasuri.json2tree(tree)
|
30
40
|
end # def register
|
31
41
|
|
32
42
|
def run(queue)
|
@@ -0,0 +1,17 @@
|
|
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
|
+
}
|
data/spec/inputs/yasuri_spec.rb
CHANGED
@@ -30,6 +30,14 @@ 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
|
+
|
33
41
|
it "should register" do
|
34
42
|
# register will try to load jars and raise if it cannot find jars or if org.apache.log4j.spi.LoggingEvent class is not present
|
35
43
|
expect {input.register}.to_not raise_error
|
@@ -41,4 +49,10 @@ describe LogStash::Inputs::Yasuri do
|
|
41
49
|
input.inner_run(queue)
|
42
50
|
expect(queue.size).not_to be_zero
|
43
51
|
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
|
44
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-yasuri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.4
|
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-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- README.md
|
109
109
|
- lib/logstash/inputs/yasuri.rb
|
110
110
|
- logstash-input-yasuri.gemspec
|
111
|
+
- spec/inputs/res/parse_tree.json
|
111
112
|
- spec/inputs/yasuri_spec.rb
|
112
113
|
homepage: https://github.com/tac0x2a/logstash-input-yasuri
|
113
114
|
licenses:
|
@@ -131,9 +132,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
132
|
version: '0'
|
132
133
|
requirements: []
|
133
134
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.6.
|
135
|
+
rubygems_version: 2.6.8
|
135
136
|
signing_key:
|
136
137
|
specification_version: 4
|
137
138
|
summary: Web scraping input plugin for logstash.
|
138
139
|
test_files:
|
140
|
+
- spec/inputs/res/parse_tree.json
|
139
141
|
- spec/inputs/yasuri_spec.rb
|