yasuri 0.0.9 → 0.0.10

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: 312332da9f3a5d1f905c8734bf3376d01a8b40d4
4
- data.tar.gz: 57d1f6e6a621dab337c47ad085eab5e49c14fb2b
3
+ metadata.gz: f70e0281f160fbabc3bff893ce607fb400d4b352
4
+ data.tar.gz: 768589a35a856f392eadf6d3eaa1410cf8d97fb0
5
5
  SHA512:
6
- metadata.gz: 9d03f0f22f4e4363612cce8da98ee03b5ef481f96742e033dc1d68ce87d65863d6979bad71b7f2482e7473a09bd8e65dd000e6a3f7ab37f220707bb3c3f0cbd9
7
- data.tar.gz: 29e5a7a8f658ef8b6ee1073d1b72cd61212f8aac8cf6bb8c80807c25e0e453ef488845ec1163b9b9299c189e2d983f67ed4df21adb64f40468819cb2e82d1086
6
+ metadata.gz: 795dec45d612eb40f55aee0fce492979cade151d7f553e0f8e9a77e7ab39f55f3db015c20b6f13f447d991861c8b9c3bf9f25111a1af918ca055002f67491a76
7
+ data.tar.gz: 74452e32d9c91ceac9cc4d43963d3f0b68692474239770a55c14c52e6d9f266e28d768c1368211140dc8925acc9e41ce97bf91790fb19cc56366505f1db74894
@@ -1,3 +1,3 @@
1
1
  module Yasuri
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -20,7 +20,10 @@ module Yasuri
20
20
  node = page.search(@xpath)
21
21
  text = node.text.to_s
22
22
 
23
- text = text[@truncate, 0] if @truncate
23
+ if @truncate
24
+ matches = @truncate.match(text)
25
+ text = matches ? matches[1] || matches[0] || text : ""
26
+ end
24
27
 
25
28
  text.to_s
26
29
  end
@@ -46,6 +46,12 @@ describe 'Yasuri' do
46
46
  expect(actual).to eq "Hello"
47
47
  end
48
48
 
49
+ it "return first captured if matched given capture pattern" do
50
+ node = Yasuri.text_title '/html/body/p[1]', /H(.+)i/
51
+ actual = node.inject(@agent, @index_page)
52
+ expect(actual).to eq "ello,Yasur"
53
+ end
54
+
49
55
  it "can be truncated with regexp" do
50
56
  node = Yasuri.text_title '/html/body/p[1]', /[^,]+$/
51
57
  actual = node.inject(@agent, @index_page)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yasuri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAC