slugifier 1.1.1 → 1.1.2
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 +4 -4
- data/lib/slugifier.rb +13 -15
- 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: d1bec5a5c0eff53f51bb0911dfbd3ce6a615f019
|
4
|
+
data.tar.gz: f18032dfa9ae6a99749ef8b109ca826bcce9a7a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf700cde9ed520c68abfec4c0031cd82f0dd25bddcaa1cd82494e3ee966b933a6d3b670f3bec871403ac3640a1eee3b5a71b4d4f3c674eaf76db2e71d4f9f960
|
7
|
+
data.tar.gz: 64c98ba75db1d44759dae974b00cbc3b53d806d8d31825a623c1f6a893fc80dc00439e8de9066d3b84a9e1e8a2bc9a95ada225fdeef3960e5f09d43ff23d7997
|
data/lib/slugifier.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Slugifier
|
2
|
+
extend self
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
string
|
4
|
+
UNWANTED_CHARACTERS = /([^a-z0-9])+/
|
5
|
+
|
6
|
+
def slugify(string)
|
7
|
+
normalize(string).tap { |s| s.gsub!(UNWANTED_CHARACTERS, "-") }
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def normalize(string)
|
13
|
+
transliterate(string).tap do |s|
|
14
|
+
s.downcase!
|
15
|
+
s.strip!
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def transliterate(string)
|
20
20
|
transliteration = string.dup
|
21
21
|
table.each { |character, translit| transliteration.gsub!(character, translit) }
|
22
22
|
transliteration
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def table
|
26
26
|
{
|
27
27
|
# Latin
|
28
28
|
"°" => "0", "æ" => "ae", "ǽ" => "ae", "À" => "A", "Á" => "A", "Â" => "A", "Ã" => "A", "Å" => "A", "Ǻ" => "A",
|
@@ -111,6 +111,4 @@ class Slugifier
|
|
111
111
|
"¹" => "1", "²" => "2", "³" => "3", "¶" => "P"
|
112
112
|
}
|
113
113
|
end
|
114
|
-
|
115
|
-
private_class_method :normalize, :transliterate, :table
|
116
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Gimenez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|