ohm-contrib 0.0.40 → 0.0.41
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.
- data/lib/ohm/contrib.rb +1 -1
- data/lib/ohm/contrib/slug.rb +18 -3
- metadata +3 -3
data/lib/ohm/contrib.rb
CHANGED
data/lib/ohm/contrib/slug.rb
CHANGED
@@ -11,13 +11,28 @@ module Ohm
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def slug(str = to_s)
|
14
|
-
|
14
|
+
ret = iconv(str)
|
15
|
+
ret.gsub!("'", "")
|
16
|
+
ret.gsub!(/\p{^Alnum}/u, " ")
|
17
|
+
ret.strip!
|
18
|
+
ret.gsub!(/\s+/, "-")
|
19
|
+
ret.downcase
|
15
20
|
end
|
16
21
|
module_function :slug
|
17
22
|
|
23
|
+
def iconv(str)
|
24
|
+
begin
|
25
|
+
require "iconv"
|
26
|
+
|
27
|
+
Iconv.iconv("ascii//translit//ignore", "utf-8", str)[0]
|
28
|
+
rescue LoadError
|
29
|
+
return str
|
30
|
+
end
|
31
|
+
end
|
32
|
+
module_function :iconv
|
33
|
+
|
18
34
|
def to_param
|
19
35
|
"#{ id }-#{ slug }"
|
20
36
|
end
|
21
37
|
end
|
22
|
-
end
|
23
|
-
|
38
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 41
|
9
|
+
version: 0.0.41
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Cyril David
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-22 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|