yasuri 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f667fce1e95bc5a16e350a1227abdde1a6db8514
4
- data.tar.gz: 68cb3c5754f9636f9ae2c677feccfd62183c0af5
3
+ metadata.gz: 312332da9f3a5d1f905c8734bf3376d01a8b40d4
4
+ data.tar.gz: 57d1f6e6a621dab337c47ad085eab5e49c14fb2b
5
5
  SHA512:
6
- metadata.gz: ddb2760495645509953e05748ac617148f1a69916f955f4781fef4565dcb030d44a204d2999e5510c3dc43af6500c654886fe8eeb5694d339c76e8eb7fa195ba
7
- data.tar.gz: 2ae5d067c108a7137739c3df51001abfbc6002bda5eeeec1e3632e3e57154e8f856effd0c0017b587768feb84c76b73889582ec526e07697c95d8ba140bb8e9a
6
+ metadata.gz: 9d03f0f22f4e4363612cce8da98ee03b5ef481f96742e033dc1d68ce87d65863d6979bad71b7f2482e7473a09bd8e65dd000e6a3f7ab37f220707bb3c3f0cbd9
7
+ data.tar.gz: 29e5a7a8f658ef8b6ee1073d1b72cd61212f8aac8cf6bb8c80807c25e0e453ef488845ec1163b9b9299c189e2d983f67ed4df21adb64f40468819cb2e82d1086
@@ -1,3 +1,3 @@
1
1
  module Yasuri
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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
- end
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.8
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-01 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler