accent-buster 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/accent-buster.gemspec +3 -0
- data/lib/accent-buster.rb +3 -0
- data/lib/accent-buster/string_extension.rb +20 -18
- data/lib/accent-buster/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92de494461848c93cbc4edb566f1628665631af7
|
4
|
+
data.tar.gz: 4fa2724528fb23df070692969f5a2337d46cce59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e93e149c1d9009f153997b06ef6fc8d6fed01594040445bdbd65af66231a2c27eb587625b40c3ce72ce79c805fe91e596dd1becebff4b3f5370fec6c3bbcc6e
|
7
|
+
data.tar.gz: f1692695e4d56162e4f88fae5df06d6f8460a434289e7c28517896467f58617ea4ebcd653f5fa308a6b675146e05f6af8a446bba3b58fb85a3961e9545c60061
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ I made it because I don't want to add "ActiveSupport" to the projects everytime
|
|
6
6
|
|
7
7
|
This lib will have NO MORE than the very strictly necessary to replace diacritics, currently, it has 2 methods: "String#accent_buster" and "String#accent_buster!" (note the bang).
|
8
8
|
|
9
|
+
Accent Buster uses refinements, so, ruby 2.0+ only.
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application's Gemfile:
|
@@ -22,12 +24,15 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
```ruby
|
28
|
+
# Refinements!
|
29
|
+
using AccentBuster::StringExtension
|
30
|
+
|
31
|
+
'ação'.accent_buster # => 'acao'
|
32
|
+
x = 'é você?'
|
33
|
+
x.accent_buster!
|
34
|
+
# => x = 'e voce'
|
35
|
+
```
|
31
36
|
|
32
37
|
## Contributing
|
33
38
|
|
data/accent-buster.gemspec
CHANGED
@@ -4,6 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'accent-buster/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
+
# We are using refinements
|
8
|
+
spec.required_ruby_version = '>= 2.0'
|
9
|
+
|
7
10
|
spec.name = "accent-buster"
|
8
11
|
spec.version = AccentBuster::VERSION
|
9
12
|
spec.authors = ["Ronie Uliana"]
|
data/lib/accent-buster.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module AccentBuster::StringExtension
|
2
|
+
refine String do
|
3
|
+
# Convert diacritics chars to their non-diacritic equivalents.
|
4
|
+
#
|
5
|
+
# Works for latin languages only.
|
6
|
+
#
|
7
|
+
# Returns a copy of the string with diacritics removed.
|
8
|
+
def accent_buster
|
9
|
+
self.tr('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
# Convert diacritics chars to their non-diacritic equivalents.
|
13
|
+
#
|
14
|
+
# Works for latin languages only.
|
15
|
+
#
|
16
|
+
# Convert the string in place.
|
17
|
+
#
|
18
|
+
# Returns the string or nil if no changes were made.
|
19
|
+
def accent_buster!
|
20
|
+
self.tr!('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accent-buster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronie Uliana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Add "String#accent_buster" that replaces diacritics marks by their non-diacritic
|
@@ -46,7 +46,7 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- .gitignore
|
49
|
+
- ".gitignore"
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
52
52
|
- README.md
|
@@ -65,17 +65,17 @@ require_paths:
|
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '0'
|
70
|
+
version: '2.0'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.2.0
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: 'Add "String#accent_buster" that replaces diacritics marks by their non-diacritic
|