without_accents 0.8.5
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/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.markdown +15 -0
- data/Rakefile +12 -0
- data/lib/without_accents.rb +46 -0
- data/test/without_accents_test.rb +10 -0
- data/without_accents.gemspec +21 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Without Accents
|
2
|
+
|
3
|
+
Turns Ü into U and Î into I. That sorta thing. Great for if you're doing text processing and you want to handle multibyte strings simply or limit text to English characters only.
|
4
|
+
|
5
|
+
This project is not meant to disparage any culture that uses non-English characters, only to make English-only services and products easier to develop.
|
6
|
+
|
7
|
+
## HowTo
|
8
|
+
|
9
|
+
require 'without_accents'
|
10
|
+
"á Ä È ÊìÎòÔÜçñ�".without_accents => # "a A E EiIoOUcn"
|
11
|
+
|
12
|
+
|
13
|
+
Patches welcome, forks celebrated.
|
14
|
+
|
15
|
+
Copyright (c) 2011 [Jack Danger Canty](http://jåck.com). Released under the MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# taken from http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2009-04/msg01041.html
|
4
|
+
|
5
|
+
gem 'utf8_utils'
|
6
|
+
require 'utf8_utils'
|
7
|
+
|
8
|
+
module WithoutAccents
|
9
|
+
|
10
|
+
VERSION = "0.8.5"
|
11
|
+
|
12
|
+
def without_accents
|
13
|
+
|
14
|
+
string = tidy_bytes
|
15
|
+
|
16
|
+
{
|
17
|
+
%w{ á à â ä ã } => 'a',
|
18
|
+
%w{ Ã Ä Â À Á } => 'A',
|
19
|
+
%w{ é è ê ë } => 'e',
|
20
|
+
%w{ Ë É È Ê } => 'E',
|
21
|
+
%w{ í ì î ï } => 'i',
|
22
|
+
%w{ Í Î Ì Ï } => 'I',
|
23
|
+
%w{ ó ò ô ö õ } => 'o',
|
24
|
+
%w{ Õ Ö Ô Ò Ó } => 'O',
|
25
|
+
%w{ ú ù û ü } => 'u',
|
26
|
+
%w{ Ú Û Ù Ü } => 'U',
|
27
|
+
%w{ ç } => 'c',
|
28
|
+
%w{ Ç } => 'C',
|
29
|
+
%w{ ñ } => 'n',
|
30
|
+
%w{ Ñ } => 'N',
|
31
|
+
%w{ ’ ‘ ' } => "'",
|
32
|
+
%w{ ” } => '"',
|
33
|
+
%w{ � } => ''
|
34
|
+
|
35
|
+
}.each do |accents, normal|
|
36
|
+
accents.each do |accent|
|
37
|
+
string.gsub! accent, normal
|
38
|
+
end
|
39
|
+
end
|
40
|
+
string.gsub! '\302\240', ' '
|
41
|
+
string.reverse.reverse
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
String.send :include, WithoutAccents unless String.included_modules.include?(WithoutAccents)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require File.expand_path File.join(File.dirname(__FILE__), '..', 'lib', 'without_accents')
|
4
|
+
|
5
|
+
class WithoutAccentsTest < Test::Unit::TestCase
|
6
|
+
def test_characters_are_replaced
|
7
|
+
assert_equal "a A E EiIoOUcn",
|
8
|
+
"á Ä È ÊìÎòÔÜçñ�".without_accents
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "without_accents"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "without_accents"
|
7
|
+
s.version = WithoutAccents::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jack Danger Canty"]
|
10
|
+
s.email = ["rubygems@6brand.com"]
|
11
|
+
s.homepage = "http://github.com/JackDanger/without_accents"
|
12
|
+
s.summary = %q{Strip accented characters from a text, replacing with their UTF-7-compatible counterparts}
|
13
|
+
s.description = %q{Strip accented characters from a text, replacing with their UTF-7-compatible counterparts}
|
14
|
+
|
15
|
+
s.rubyforge_project = "without_accents"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: without_accents
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 53
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 5
|
10
|
+
version: 0.8.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jack Danger Canty
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-28 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Strip accented characters from a text, replacing with their UTF-7-compatible counterparts
|
23
|
+
email:
|
24
|
+
- rubygems@6brand.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.markdown
|
35
|
+
- Rakefile
|
36
|
+
- lib/without_accents.rb
|
37
|
+
- test/without_accents_test.rb
|
38
|
+
- without_accents.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/JackDanger/without_accents
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: without_accents
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Strip accented characters from a text, replacing with their UTF-7-compatible counterparts
|
73
|
+
test_files:
|
74
|
+
- test/without_accents_test.rb
|