yasuri 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yasuri/version.rb +1 -1
- data/lib/yasuri/yasuri_struct_node.rb +3 -2
- data/spec/yasuri_struct_node_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 312332da9f3a5d1f905c8734bf3376d01a8b40d4
|
4
|
+
data.tar.gz: 57d1f6e6a621dab337c47ad085eab5e49c14fb2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d03f0f22f4e4363612cce8da98ee03b5ef481f96742e033dc1d68ce87d65863d6979bad71b7f2482e7473a09bd8e65dd000e6a3f7ab37f220707bb3c3f0cbd9
|
7
|
+
data.tar.gz: 29e5a7a8f658ef8b6ee1073d1b72cd61212f8aac8cf6bb8c80807c25e0e453ef488845ec1163b9b9299c189e2d983f67ed4df21adb64f40468819cb2e82d1086
|
data/lib/yasuri/version.rb
CHANGED
@@ -8,13 +8,14 @@ module Yasuri
|
|
8
8
|
include Node
|
9
9
|
def inject(agent, page, opt = {})
|
10
10
|
sub_tags = page.search(@xpath)
|
11
|
-
sub_tags.map do |sub_tag|
|
11
|
+
tree = sub_tags.map do |sub_tag|
|
12
12
|
child_results_kv = @children.map do |child_node|
|
13
13
|
child_name = Yasuri.NodeName(child_node.name, opt)
|
14
14
|
[child_name, child_node.inject(agent, sub_tag, opt)]
|
15
15
|
end
|
16
16
|
Hash[child_results_kv]
|
17
17
|
end
|
18
|
-
|
18
|
+
tree.size == 1 ? tree.first : tree
|
19
|
+
end # inject
|
19
20
|
end
|
20
21
|
end
|
@@ -57,6 +57,16 @@ describe 'Yasuri' do
|
|
57
57
|
expect(actual).to match expected
|
58
58
|
end
|
59
59
|
|
60
|
+
it 'return single result without array' do
|
61
|
+
node = Yasuri::StructNode.new('/html/body/table[1]/tr[1]', "table_first_tr", [
|
62
|
+
Yasuri::TextNode.new('./td[1]', "title"),
|
63
|
+
Yasuri::TextNode.new('./td[2]', "pub_date"),
|
64
|
+
])
|
65
|
+
expected = @table_1996.first
|
66
|
+
actual = node.inject(@agent, @page)
|
67
|
+
expect(actual).to match expected
|
68
|
+
end
|
69
|
+
|
60
70
|
it 'return empty text if no match node' do
|
61
71
|
no_match_xpath = '/html/body/table[1]/t'
|
62
72
|
node = Yasuri::StructNode.new(no_match_xpath, "table", [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yasuri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|