web-utils 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/web_utils.rb +3 -3
- data/test/test_web_utils.rb +3 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8df71a71864afc54ccfe22398682022e6cf090910aae975b32eed9d35e9286e8
|
4
|
+
data.tar.gz: c703eab7a05aeb5012c2329ae97baf37deca08adc54a5a271764bbba7e8b1af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e299b79e26e7115969862e9fda94cab8adc13fae528ddf9b7ec3aa4e9259f415942e0b957c41e6ff8531b9d56f09ae2f40cbb66c26ea15edb39cdbefad0680
|
7
|
+
data.tar.gz: 932b896280ae5139b81c78c610fff132516d5ed9559dc87c65b51779d61b8f77a22825ccd79acda14fdb27fb9e20e2aed3a68327b2c3160fed582ca3842b535f
|
data/lib/web_utils.rb
CHANGED
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
|
6
6
|
module WebUtils
|
7
7
|
|
8
|
-
VERSION = '0.1.
|
8
|
+
VERSION = '0.1.2'
|
9
9
|
|
10
10
|
# Most methods are supposed to be as simple as possible
|
11
11
|
# and just cover most cases.
|
@@ -182,7 +182,7 @@ module WebUtils
|
|
182
182
|
module_function :generate_random_id
|
183
183
|
|
184
184
|
def nl2br s, br='<br>'
|
185
|
-
s.to_s.gsub(/\n/,br)
|
185
|
+
s.to_s.gsub(/\r?\n/,br)
|
186
186
|
end
|
187
187
|
module_function :nl2br
|
188
188
|
|
@@ -211,7 +211,7 @@ module WebUtils
|
|
211
211
|
gsub(EMAIL_REGEX) do |str|
|
212
212
|
"<a href='mailto:#{$1.downcase}'>#{$1}</a>"
|
213
213
|
end
|
214
|
-
nl2br(replaced,br)
|
214
|
+
nl2br(replaced,br)
|
215
215
|
end
|
216
216
|
module_function :automatic_html
|
217
217
|
|
data/test/test_web_utils.rb
CHANGED
@@ -354,11 +354,11 @@ describe WebUtils do
|
|
354
354
|
|
355
355
|
describe '#nl2br' do
|
356
356
|
it 'Puts unclosed tags by default' do
|
357
|
-
assert_equal '<br>Hello<br>world<br>', utils.nl2br("\nHello\nworld\n")
|
357
|
+
assert_equal '<br>Hello<br>world<br>', utils.nl2br("\nHello\r\nworld\n")
|
358
358
|
end
|
359
359
|
describe 'with 2nd argument' do
|
360
360
|
it 'Replaces the tag' do
|
361
|
-
assert_equal '<br/>Hello<br/>world<br/>', utils.nl2br("\nHello\nworld\n",'<br/>')
|
361
|
+
assert_equal '<br/>Hello<br/>world<br/>', utils.nl2br("\nHello\r\nworld\n",'<br/>')
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
@@ -409,7 +409,7 @@ describe WebUtils do
|
|
409
409
|
describe '#automatic_html' do
|
410
410
|
it 'Automates links and line breaks' do
|
411
411
|
input = "Hello\nme@site.co.uk\nNot the begining me@site.co.uk\nme@site.co.uk not the end\nwww.site.co.uk\nVisit www.site.co.uk\nwww.site.co.uk rules\nhttp://www.site.co.uk\nVisit http://www.site.co.uk\nhttp://www.site.co.uk rules"
|
412
|
-
output = "Hello<br><a href='mailto:me
|
412
|
+
output = "Hello<br><a href='mailto:me@site.co.uk'>me@site.co.uk</a><br>Not the begining <a href='mailto:me@site.co.uk'>me@site.co.uk</a><br><a href='mailto:me@site.co.uk'>me@site.co.uk</a> not the end<br><a href='//www.site.co.uk' target='_blank'>www.site.co.uk</a><br>Visit <a href='//www.site.co.uk' target='_blank'>www.site.co.uk</a><br><a href='//www.site.co.uk' target='_blank'>www.site.co.uk</a> rules<br><a href='http://www.site.co.uk' target='_blank'>http://www.site.co.uk</a><br>Visit <a href='http://www.site.co.uk' target='_blank'>http://www.site.co.uk</a><br><a href='http://www.site.co.uk' target='_blank'>http://www.site.co.uk</a> rules"
|
413
413
|
assert_equal output, utils.automatic_html(input)
|
414
414
|
end
|
415
415
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -85,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.6.13
|
88
|
+
rubygems_version: 3.0.2
|
90
89
|
signing_key:
|
91
90
|
specification_version: 4
|
92
91
|
summary: Web Utils
|