web-utils 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/web_utils.rb +3 -3
- data/test/test_web_utils.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8a2315d2048160a727547e8e9244d42dfb06872b8d2e033116284aa951c3e7e
|
4
|
+
data.tar.gz: 48008168ad2f44ff6b8f5b783b03a8f529e59b235b3b619a9975695172b23493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5337eedf0e98063f1a7aabea4650db6c5d8bb7c20f8ab1b65f887d1374c1fb8351ae5fd27f0bcb7d8c9adb8076cfdd42beefa8980bf688cf66788ca98f842d46
|
7
|
+
data.tar.gz: a88b9779b1229f8d499e68b47c466a298f9181d5fd866890057f5a59a0f247647e921ad5a531fa6c550b1db179dc7eb93306c55aa8a48332800704624c94ec68
|
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.3'
|
9
9
|
|
10
10
|
# Most methods are supposed to be as simple as possible
|
11
11
|
# and just cover most cases.
|
@@ -115,9 +115,9 @@ module WebUtils
|
|
115
115
|
def slugify s, force_lower=true
|
116
116
|
s = s.to_s
|
117
117
|
.tr(ACCENTS, WITHOUT_ACCENTS)
|
118
|
-
.tr('.,;:?!/\'"()[]{}<>','-')
|
119
118
|
.gsub(/&/, 'and')
|
120
|
-
.gsub(
|
119
|
+
.gsub(/%/, ' percent')
|
120
|
+
.gsub(/(\-|[^0-9a-zA-Z])+/,'-')
|
121
121
|
.gsub(/(^-|-$)/,'')
|
122
122
|
s = s.downcase if force_lower
|
123
123
|
escape(s)
|
data/test/test_web_utils.rb
CHANGED
@@ -232,13 +232,13 @@ describe WebUtils do
|
|
232
232
|
# For making slug for a document
|
233
233
|
# Possibly used instead of the id
|
234
234
|
|
235
|
-
let(:arg) { "Así es la vida by Daniel Bär & Mickaël ? (100%)" }
|
235
|
+
let(:arg) { "Así es la vida – by Daniel Bär & Mickaël ? (100%) ~ " }
|
236
236
|
it 'Builds a string made of lowercase URL-friendly chars' do
|
237
|
-
assert_equal 'asi-es-la-vida-by-daniel-bar-and-mickael-100
|
237
|
+
assert_equal 'asi-es-la-vida-by-daniel-bar-and-mickael-100-percent', utils.slugify(arg)
|
238
238
|
end
|
239
239
|
describe 'when second argument is false' do
|
240
240
|
it 'Does not force to lowercase' do
|
241
|
-
assert_equal 'Asi-es-la-vida-by-Daniel-Bar-and-Mickael-100
|
241
|
+
assert_equal 'Asi-es-la-vida-by-Daniel-Bar-and-Mickael-100-percent', utils.slugify(arg,false)
|
242
242
|
end
|
243
243
|
end
|
244
244
|
describe 'when argument is nil' do
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|