thbar-diacritics_fu 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,5 +1,8 @@
1
+ == 1.0.2 / 2008-12-10
2
+ * Added support for $KCODE "UTF8" with Rails >= 2.2.0 (thanks to Thomas Brian and John Devine for their bug report)
3
+
1
4
  == 1.0.1 / 2008-12-05
2
- * Added support for Rails > 2.2 (thanks Nicolas Fouché!)
5
+ * Added support for Rails >= 2.2.0 (thanks Nicolas Fouché!)
3
6
  * Refactored to check ActiveSupport version
4
7
  * Added missing require activerecord to the lib
5
8
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "diacritics_fu"
3
- s.version = "1.0.1"
4
- s.date = "2008-12-05"
3
+ s.version = "1.0.2"
4
+ s.date = "2008-12-10"
5
5
  s.summary = "Tiny Ruby library to remove accents and other diacritics from a string (relies on ActiveSupport)."
6
6
  s.email = "thibaut.barrere@gmail.com"
7
7
  s.homepage = "http://github.com/thbar/diacritics_fu"
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  "diacritics_fu.gemspec",
16
16
  "lib/diacritics_fu.rb",
17
17
  "lib/diacritics_fu/new_escaper.rb",
18
+ "lib/diacritics_fu/new_escaper_kcode_utf8.rb",
18
19
  "lib/diacritics_fu/old_escaper.rb"]
19
20
  s.test_files = ["spec/diacritics_fu_spec.rb","spec/spec_helper.rb"]
20
21
 
@@ -0,0 +1,5 @@
1
+ module DiacriticsFu
2
+ def self.escape(str)
3
+ ActiveSupport::Multibyte::Chars.new(str).normalize(:d).split(//u).reject { |e| e.wrapped_string[0] > 128 }.join
4
+ end
5
+ end
data/lib/diacritics_fu.rb CHANGED
@@ -1,8 +1,13 @@
1
1
  require 'active_support'
2
2
  require 'active_support/version'
3
3
 
4
+ # hum - I love that kind of things
4
5
  if ActiveSupport::VERSION::STRING >= "2.2.0"
5
- require File.dirname(__FILE__) + '/diacritics_fu/new_escaper'
6
+ if $KCODE == 'UTF8'
7
+ require File.dirname(__FILE__) + '/diacritics_fu/new_escaper_kcode_utf8'
8
+ else
9
+ require File.dirname(__FILE__) + '/diacritics_fu/new_escaper'
10
+ end
6
11
  else
7
12
  require File.dirname(__FILE__) + '/diacritics_fu/old_escaper'
8
- end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thbar-diacritics_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Thibaut Barr\xC3\xA8re"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-05 00:00:00 -08:00
12
+ date: 2008-12-10 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,6 +39,7 @@ files:
39
39
  - diacritics_fu.gemspec
40
40
  - lib/diacritics_fu.rb
41
41
  - lib/diacritics_fu/new_escaper.rb
42
+ - lib/diacritics_fu/new_escaper_kcode_utf8.rb
42
43
  - lib/diacritics_fu/old_escaper.rb
43
44
  has_rdoc: true
44
45
  homepage: http://github.com/thbar/diacritics_fu