diacritics_fu 1.0.3
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/History.txt +13 -0
- data/Manifest.txt +10 -0
- data/README +34 -0
- data/VERSION.yml +4 -0
- data/lib/diacritics_fu.rb +13 -0
- data/lib/diacritics_fu/new_escaper.rb +5 -0
- data/lib/diacritics_fu/new_escaper_kcode_utf8.rb +5 -0
- data/lib/diacritics_fu/old_escaper.rb +5 -0
- data/spec/diacritics_fu_spec.rb +36 -0
- data/spec/spec_helper.rb +5 -0
- metadata +64 -0
data/History.txt
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
+
|
4
|
+
== 1.0.1 / 2008-12-05
|
5
|
+
* Added support for Rails >= 2.2.0 (thanks Nicolas Fouché!)
|
6
|
+
* Refactored to check ActiveSupport version
|
7
|
+
* Added missing require activerecord to the lib
|
8
|
+
|
9
|
+
== 1.0.0 / 2008-10-21
|
10
|
+
* Packaged as a gem.
|
11
|
+
|
12
|
+
== 0.9.0 / 2008-05-13
|
13
|
+
* First public release on GitHub.
|
data/Manifest.txt
ADDED
data/README
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Quick start
|
2
|
+
===========
|
3
|
+
|
4
|
+
DiacriticsFu::escape("éphémère")
|
5
|
+
=> "ephemere"
|
6
|
+
|
7
|
+
DiacriticsFu::escape("räksmörgås")
|
8
|
+
=> "raksmorgas"
|
9
|
+
|
10
|
+
What?
|
11
|
+
=====
|
12
|
+
|
13
|
+
A small library to remove accents from a string. Relies on ActiveSupport.
|
14
|
+
|
15
|
+
Created because I needed a simple way to remove most diacritics from French sentences, while generating slugs (url) for a CMS (either Mephisto or ComatoseCMS).
|
16
|
+
|
17
|
+
Nb: this approach is not the fastest way to achieve this. It's good enough for me though.
|
18
|
+
|
19
|
+
Author
|
20
|
+
======
|
21
|
+
|
22
|
+
Thibaut Barrère (http://blog.logeek.fr)
|
23
|
+
|
24
|
+
Testing
|
25
|
+
=======
|
26
|
+
|
27
|
+
You can run the spec against the latest available ActiveSupport using "rake spec".
|
28
|
+
|
29
|
+
To run the tests against all installed ActiveSupport versions, use "rake spec_multi"
|
30
|
+
|
31
|
+
License
|
32
|
+
=======
|
33
|
+
|
34
|
+
MIT
|
data/VERSION.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/version'
|
3
|
+
|
4
|
+
# hum - I love that kind of things
|
5
|
+
if ActiveSupport::VERSION::STRING >= "2.2.0"
|
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
|
11
|
+
else
|
12
|
+
require File.dirname(__FILE__) + '/diacritics_fu/old_escaper'
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
# allow activation of a specific version of activesupport for testing
|
5
|
+
gem 'activesupport', "= #{ENV['DIACRITICS_FU_ACTIVESUPPORT_VERSION']}" if ENV['DIACRITICS_FU_ACTIVESUPPORT_VERSION']
|
6
|
+
|
7
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
8
|
+
require 'active_support'
|
9
|
+
|
10
|
+
describe DiacriticsFu do
|
11
|
+
|
12
|
+
before(:all) do
|
13
|
+
puts "Testing using ActiveSupport version #{ActiveSupport::VERSION::STRING}"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should remove the accents with grace" do
|
17
|
+
DiacriticsFu::escape("éphémère").should == "ephemere"
|
18
|
+
DiacriticsFu::escape("éêèïîù").should eql("eeeiiu")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should remove more exotic accents" do
|
22
|
+
DiacriticsFu::escape("räksmörgås").should eql("raksmorgas")
|
23
|
+
end
|
24
|
+
|
25
|
+
KNOWN_DIACRITICS = { "a" => "àäâ", "e" => "éèêë", "i" => "îï", "o" => "ôö", "u" => "üû", "c" => "ç",
|
26
|
+
"I" => "ÏÎ", "E" => "ÊË", "n" => "ñ", "O" => "ÔÖ", "Y" => "Ÿ", "y" => "ÿ", "N" => "Ñ" }
|
27
|
+
|
28
|
+
KNOWN_DIACRITICS.each do |expected_replacement,originals|
|
29
|
+
it "should transform any of '#{originals}' into '#{expected_replacement}'" do
|
30
|
+
originals.each_char do |original|
|
31
|
+
DiacriticsFu.escape(original).should eql(expected_replacement)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: diacritics_fu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Thibaut Barr\xC3\xA8re"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-29 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: TODO
|
17
|
+
email: thibaut.barrere@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- History.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- VERSION.yml
|
28
|
+
- lib/diacritics_fu
|
29
|
+
- lib/diacritics_fu/new_escaper.rb
|
30
|
+
- lib/diacritics_fu/new_escaper_kcode_utf8.rb
|
31
|
+
- lib/diacritics_fu/old_escaper.rb
|
32
|
+
- lib/diacritics_fu.rb
|
33
|
+
- spec/diacritics_fu_spec.rb
|
34
|
+
- spec/spec_helper.rb
|
35
|
+
- README
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/thbar/diacritics_fu
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --inline-source
|
41
|
+
- --charset=UTF-8
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: diacritics-fu
|
59
|
+
rubygems_version: 1.3.1
|
60
|
+
signing_key:
|
61
|
+
specification_version: 2
|
62
|
+
summary: A small library to remove accents from a string. Relies on ActiveSupport.
|
63
|
+
test_files: []
|
64
|
+
|