ohm-contrib 0.0.40 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Ohm
2
2
  module Contrib
3
- VERSION = "0.0.40"
3
+ VERSION = "0.0.41"
4
4
  end
5
5
 
6
6
  autoload :ActiveModelExtension, "ohm/contrib/active_model_extension"
@@ -11,13 +11,28 @@ module Ohm
11
11
  end
12
12
 
13
13
  def slug(str = to_s)
14
- str.gsub("'", "").gsub(/\p{^Alnum}/u, " ").strip.gsub(/\s+/, "-").downcase
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
- - 40
9
- version: 0.0.40
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-10 00:00:00 +08:00
17
+ date: 2010-11-22 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency