remove_accents 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-p448@remove_accents --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in uniq_logger.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ remove_accents (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ celluloid (0.16.0)
10
+ timers (~> 4.0.0)
11
+ coderay (1.1.0)
12
+ diff-lcs (1.2.5)
13
+ ffi (1.9.8)
14
+ formatador (0.2.5)
15
+ guard (2.12.5)
16
+ formatador (>= 0.2.4)
17
+ listen (~> 2.7)
18
+ lumberjack (~> 1.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-rspec (4.5.0)
26
+ guard (~> 2.1)
27
+ guard-compat (~> 1.1)
28
+ rspec (>= 2.99.0, < 4.0)
29
+ hitimes (1.2.2)
30
+ listen (2.10.0)
31
+ celluloid (~> 0.16.0)
32
+ rb-fsevent (>= 0.9.3)
33
+ rb-inotify (>= 0.9)
34
+ lumberjack (1.0.9)
35
+ method_source (0.8.2)
36
+ nenv (0.2.0)
37
+ notiffany (0.0.6)
38
+ nenv (~> 0.1)
39
+ shellany (~> 0.0)
40
+ pry (0.10.1)
41
+ coderay (~> 1.1.0)
42
+ method_source (~> 0.8.1)
43
+ slop (~> 3.4)
44
+ rake (10.4.2)
45
+ rb-fsevent (0.9.4)
46
+ rb-inotify (0.9.5)
47
+ ffi (>= 0.5.0)
48
+ rspec (3.2.0)
49
+ rspec-core (~> 3.2.0)
50
+ rspec-expectations (~> 3.2.0)
51
+ rspec-mocks (~> 3.2.0)
52
+ rspec-core (3.2.2)
53
+ rspec-support (~> 3.2.0)
54
+ rspec-expectations (3.2.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.2.0)
57
+ rspec-mocks (3.2.1)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.2.0)
60
+ rspec-support (3.2.2)
61
+ shellany (0.0.1)
62
+ slop (3.6.0)
63
+ thor (0.19.1)
64
+ timers (4.0.1)
65
+ hitimes
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler (~> 1.7)
72
+ guard
73
+ guard-rspec
74
+ rake (~> 10.0)
75
+ remove_accents!
76
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,56 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+
5
+ # Note: The cmd option is now required due to the increasing number of ways
6
+ # rspec may be run, below are examples of the most common uses.
7
+ # * bundler: 'bundle exec rspec'
8
+ # * bundler binstubs: 'bin/rspec'
9
+ # * spring: 'bin/rspec' (This will use spring if running and you have
10
+ # installed the spring binstubs per the docs)
11
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
12
+ # * 'just' rspec: 'rspec'
13
+
14
+ guard :rspec, cmd: "bundle exec rspec" do
15
+ require "guard/rspec/dsl"
16
+ dsl = Guard::RSpec::Dsl.new(self)
17
+
18
+ # Feel free to open issues for suggestions and improvements
19
+
20
+ # RSpec files
21
+ rspec = dsl.rspec
22
+ watch(rspec.spec_helper) { rspec.spec_dir }
23
+ watch(rspec.spec_support) { rspec.spec_dir }
24
+ watch(rspec.spec_files)
25
+
26
+ # Ruby files
27
+ ruby = dsl.ruby
28
+ dsl.watch_spec_files_for(ruby.lib_files)
29
+
30
+ # Rails files
31
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
32
+ dsl.watch_spec_files_for(rails.app_files)
33
+ dsl.watch_spec_files_for(rails.views)
34
+
35
+ watch(rails.controllers) do |m|
36
+ [
37
+ rspec.spec.("routing/#{m[1]}_routing"),
38
+ rspec.spec.("controllers/#{m[1]}_controller"),
39
+ rspec.spec.("acceptance/#{m[1]}")
40
+ ]
41
+ end
42
+
43
+ # Rails config changes
44
+ watch(rails.spec_helper) { rspec.spec_dir }
45
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
46
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
47
+
48
+ # Capybara features specs
49
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
50
+
51
+ # Turnip features and steps
52
+ watch(%r{^spec/acceptance/(.+)\.feature$})
53
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
54
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
55
+ end
56
+ end
data/LICENSE ADDED
@@ -0,0 +1,340 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Marco Metz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ Removing Accents In a Ruby String
2
+ =================================
3
+
4
+ In short, you can use this extension to the String class to convert "àéêîôûù" to "aeeiouu".
5
+
6
+ It's fairly easy to convert a string to a URL-safe version. Both PHP and Ruby have a way to do this, but what happens in this case is that extended characters are escaped rather than being replaced and that's often not what I want.
7
+
8
+ If you're like me, you've probably had many occasions where you wanted to get a 7bits ASCII version of a string where the accents are converted to the base letter. For example, you want to give each user his page at : [domain.com]/[name]. When the name is "Steve Smith", that's not a problem, but what if the name is "François Léveillé" ?
9
+
10
+ What you want in this case is "francois_leveille" or "francoisleveille" and this is where this script will help you.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'uniq_logger'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install uniq_logger
27
+
28
+ ## Usage
29
+
30
+
31
+ ===========
32
+
33
+ # Set a sample string to test things out
34
+ ```ruby
35
+ mystring = "Ceci Est UN test : éàòù"
36
+ ```
37
+
38
+ # The removeaccents method simple removes the accents and returns the string
39
+ ```ruby
40
+ mystring.removeaccents
41
+ ```
42
+
43
+ # The urlize method not only calls removeaccents,
44
+ # but also a bunch of others to make it truly URL-ready.
45
+ mystring.urlize
46
+
47
+ # You can customize urlize with options:
48
+ # :downcase => true
49
+ # will convert entire string to lowercase
50
+ # :convert_spaces => true
51
+ # will convert space to underscore
52
+ # :regexp => //
53
+ # matching characters will be removed
54
+
55
+ mystring.urlize({:downcase => true})
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,86 @@
1
+ # RemoveAccents version 1.0.3 (c) 2008-2009 Solutions Informatiques Techniconseils inc.
2
+ #
3
+ # This module adds 2 methods to the string class.
4
+ # Up-to-date version and documentation available at:
5
+ #
6
+ # http://www.techniconseils.ca/en/scripts-remove-accents-ruby.php
7
+ #
8
+ # This script is available under the following license :
9
+ # Creative Commons Attribution-Share Alike 2.5.
10
+ #
11
+ # See full license and details at :
12
+ # http://creativecommons.org/licenses/by-sa/2.5/ca/
13
+ #
14
+ # Version history:
15
+ # * 1.0.3 : July 23 2009
16
+ # Corrected some incorrect character codes. Source is now wikipedia at:
17
+ # http://en.wikipedia.org/wiki/ISO/IEC_8859-1#Related_character_maps
18
+ # Thanks to Raimon Fernandez for pointing out the incorrect codes.
19
+ # * 1.0.2 : October 29 2008
20
+ # Slightly optimized version of urlize - Jonathan Grenier (jgrenier@techniconseils.ca)
21
+ # * 1.0.1 : October 29 2008
22
+ # First public revision - Jonathan Grenier (jgrenier@techniconseils.ca)
23
+ #
24
+
25
+ class String
26
+ # The extended characters map used by removeaccents. The accented characters
27
+ # are coded here using their numerical equivalent to sidestep encoding issues.
28
+ # These correspond to ISO-8859-1 encoding.
29
+ # ACCENTS_MAPPING = {
30
+ # 'E' => [200,201,202,203],
31
+ # 'e' => [232,233,234,235],
32
+ # 'A' => [192,193,194,195,196,197],
33
+ # 'a' => [224,225,226,227,228,229,230],
34
+ # 'C' => [199],
35
+ # 'c' => [231],
36
+ # 'O' => [210,211,212,213,214,216],
37
+ # 'o' => [242,243,244,245,246,248],
38
+ # 'I' => [204,205,206,207],
39
+ # 'i' => [236,237,238,239],
40
+ # 'U' => [217,218,219,220],
41
+ # 'u' => [249,250,251,252],
42
+ # 'N' => [209],
43
+ # 'n' => [241],
44
+ # 'Y' => [221],
45
+ # 'y' => [253,255],
46
+ # 'AE' => [306],
47
+ # 'ae' => [346],
48
+ # 'OE' => [188],
49
+ # 'oe' => [189],
50
+ # 'ss' => [223]
51
+ # }
52
+
53
+
54
+ # Remove the accents from the string. Uses String::ACCENTS_MAPPING as the source map.
55
+ def removeaccents
56
+ str = String.new(self)
57
+ String::ACCENTS_MAPPING.each {|letter,accents|
58
+ packed = accents.pack('U*')
59
+ rxp = Regexp.new("[#{packed}]", nil, 'U')
60
+ str.gsub!(rxp, letter)
61
+ }
62
+
63
+ str
64
+ end
65
+
66
+
67
+ # Convert a string to a format suitable for a URL without ever using escaped characters.
68
+ # It calls strip, removeaccents, downcase (optional) then removes the spaces (optional)
69
+ # and finally removes any characters matching the default regexp (/[^-_A-Za-z0-9]/).
70
+ #
71
+ # Options
72
+ #
73
+ # * :downcase => call downcase on the string (defaults to true)
74
+ # * :convert_spaces => Convert space to underscore (defaults to false)
75
+ # * :regexp => The regexp matching characters that will be converting to an empty string (defaults to /[^-_A-Za-z0-9]/)
76
+ def urlize(options = {})
77
+ options[:downcase] ||= true
78
+ options[:convert_spaces] ||= false
79
+ options[:regexp] ||= /[^-_A-Za-z0-9]/
80
+
81
+ str = self.strip.removeaccents
82
+ str.downcase! if options[:downcase]
83
+ str.gsub!(/\ /,'_') if options[:convert_spaces]
84
+ str.gsub(options[:regexp], '')
85
+ end
86
+ end
@@ -0,0 +1,51 @@
1
+ module RemoveAccents
2
+ class Base
3
+ def initialize(opts={}, &block)
4
+ Configuration.configure_with_path
5
+ end
6
+
7
+ def config
8
+ Configuration.config
9
+ end
10
+
11
+ end
12
+ end
13
+
14
+ class String
15
+ # The extended characters map used by removeaccents. The accented characters
16
+ # are coded here using their numerical equivalent to sidestep encoding issues.
17
+ # These correspond to ISO-8859-1 encoding.
18
+
19
+ # Remove the accents from the string. Uses String::ACCENTS_MAPPING as the source map.
20
+ def removeaccents
21
+ str = String.new(self)
22
+ RemoveAccents.new.config["replacements"].each {|letter,accents|
23
+ packed = accents.pack('U*')
24
+ rxp = Regexp.new("[#{packed}]", nil)
25
+ str.gsub!(rxp, letter)
26
+ }
27
+
28
+ str
29
+ end
30
+
31
+
32
+ # Convert a string to a format suitable for a URL without ever using escaped characters.
33
+ # It calls strip, removeaccents, downcase (optional) then removes the spaces (optional)
34
+ # and finally removes any characters matching the default regexp (/[^-_A-Za-z0-9]/).
35
+ #
36
+ # Options
37
+ #
38
+ # * :downcase => call downcase on the string (defaults to true)
39
+ # * :convert_spaces => Convert space to underscore (defaults to false)
40
+ # * :regexp => The regexp matching characters that will be converting to an empty string (defaults to /[^-_A-Za-z0-9]/)
41
+ def urlize(options = {})
42
+ options[:downcase] ||= false
43
+ options[:convert_spaces] ||= false
44
+ options[:regexp] ||= /[^-_A-Za-z0-9]/
45
+
46
+ str = self.strip.removeaccents
47
+ str.downcase! if options[:downcase]
48
+ str.gsub!(/\ /,'_') if options[:convert_spaces]
49
+ str.gsub(options[:regexp], '')
50
+ end
51
+ end
@@ -0,0 +1,60 @@
1
+ module RemoveAccents
2
+ class Configuration
3
+ @config = {
4
+ "replacements" => {
5
+ 'E' => [200,201,202,203],
6
+ 'e' => [232,233,234,235],
7
+ 'A' => [192,193,194,195,196,197],
8
+ 'a' => [224,225,226,227,228,229,230],
9
+ 'C' => [199],
10
+ 'c' => [231],
11
+ 'O' => [210,211,212,213,214,216],
12
+ 'o' => [242,243,244,245,246,248],
13
+ 'I' => [204,205,206,207],
14
+ 'i' => [236,237,238,239],
15
+ 'U' => [217,218,219,220],
16
+ 'u' => [249,250,251,252],
17
+ 'N' => [209],
18
+ 'n' => [241],
19
+ 'Y' => [221],
20
+ 'y' => [253,255],
21
+ 'AE' => [306],
22
+ 'ae' => [346],
23
+ 'OE' => [188],
24
+ 'oe' => [189],
25
+ 'ss' => [223]
26
+ }
27
+ }
28
+
29
+ @valid_config_keys = @config.keys
30
+
31
+ # Configure through hash
32
+ def self.configure(opts = {})
33
+ opts.each {|k,v| @config[k.to_s] = v if @valid_config_keys.include? k.to_s}
34
+ end
35
+
36
+ # Configure through yaml file
37
+ def self.configure_with_path
38
+ if defined?(::Rails).nil?
39
+ path_to_yaml_file = "../config/remove_accents.yml"
40
+ else
41
+ path_to_yaml_file = "#{::Rails.root}/config/remove_accents.yml"
42
+ end
43
+ begin
44
+ config = YAML::load(IO.read(path_to_yaml_file))
45
+ rescue Errno::ENOENT
46
+ #puts "YAML configuration file couldn't be found. Using defaults."
47
+ return
48
+ rescue Psych::SyntaxError
49
+ puts "YAML configuration file contains invalid syntax. Using defaults."
50
+ return
51
+ end
52
+
53
+ configure(config)
54
+ end
55
+
56
+ def self.config
57
+ @config
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module RemoveAccents
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'csv'
2
+ require 'yaml'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require "remove_accents/configuration"
7
+ require "remove_accents/version"
8
+
9
+ module RemoveAccents
10
+
11
+ def self.new
12
+ RemoveAccents::Base.new
13
+ end
14
+
15
+ end
16
+
17
+
18
+ require 'remove_accents/base'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'remove_accents/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "remove_accents"
8
+ spec.version = RemoveAccents::VERSION
9
+ spec.authors = ["Marco Metz"]
10
+ spec.email = ["marco.metz@gmail.com"]
11
+ spec.summary = %q{String class to convert "àéêîôûù" to "aeeiouu"}
12
+ spec.description = %q{You can use this extension to the String class to convert "àéêîôûù" to "aeeiouu".}
13
+ spec.homepage = "https://github.com/ikuseiGmbH/Remove-Accents-Ruby-Script"
14
+ spec.license = "GNU GENERAL PUBLIC LICENSE"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard"
25
+ spec.add_development_dependency 'guard-rspec'
26
+ #spec.add_development_dependency 'pry'
27
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'remove_accents'
3
+
4
+ describe RemoveAccents do
5
+ it 'has a version' do
6
+ expect(RemoveAccents::VERSION).to match(/\d+\.\d+\.\d+/)
7
+ end
8
+ end
9
+
10
+ describe RemoveAccents::Base do
11
+ before(:each) do
12
+ @logger = RemoveAccents.new
13
+ end
14
+
15
+ it 'has a valid configuration' do
16
+ expect(@logger.config["log_rotator"]).to eq("none")
17
+ expect(@logger.config["global_logger"]).to eq(true)
18
+ expect(@logger.config["csv"]["encoding"]).to eq("UTF8")
19
+ expect(@logger.config["csv"]["col_sep"]).to eq(";")
20
+ expect(@logger.config["logfile_destination"]).to eq("local")
21
+ end
22
+
23
+ end
@@ -0,0 +1,71 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ =begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+ # Many RSpec users commonly either run the entire suite or an individual
28
+ # file, and it's useful to allow more verbose output when running an
29
+ # individual spec file.
30
+ if config.files_to_run.one?
31
+ # Use the documentation formatter for detailed output,
32
+ # unless a formatter has already been configured
33
+ # (e.g. via a command-line flag).
34
+ config.default_formatter = 'doc'
35
+ end
36
+ # Print the 10 slowest examples and example groups at the
37
+ # end of the spec run, to help surface which specs are running
38
+ # particularly slow.
39
+ config.profile_examples = 10
40
+ # Run specs in random order to surface order dependencies. If you find an
41
+ # order dependency and want to debug it, you can fix the order by providing
42
+ # the seed, which is printed after each run.
43
+ # --seed 1234
44
+ config.order = :random
45
+ # Seed global randomization in this process using the `--seed` CLI option.
46
+ # Setting this allows you to use `--seed` to deterministically reproduce
47
+ # test failures related to randomization by passing the same `--seed` value
48
+ # as the one that triggered the failure.
49
+ Kernel.srand config.seed
50
+ # rspec-expectations config goes here. You can use an alternate
51
+ # assertion/expectation library such as wrong or the stdlib/minitest
52
+ # assertions if you prefer.
53
+ config.expect_with :rspec do |expectations|
54
+ # Enable only the newer, non-monkey-patching expect syntax.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ expectations.syntax = :expect
58
+ end
59
+ # rspec-mocks config goes here. You can use an alternate test double
60
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
61
+ config.mock_with :rspec do |mocks|
62
+ # Enable only the newer, non-monkey-patching expect syntax.
63
+ # For more details, see:
64
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
65
+ mocks.syntax = :expect
66
+ # Prevents you from mocking or stubbing a method that does not exist on
67
+ # a real object. This is generally recommended.
68
+ mocks.verify_partial_doubles = true
69
+ end
70
+ =end
71
+ end
@@ -0,0 +1,85 @@
1
+ #Use following replacements
2
+
3
+ replacements:
4
+ E:
5
+ - 200
6
+ - 201
7
+ - 202
8
+ - 203
9
+ e:
10
+ - 232
11
+ - 233
12
+ - 234
13
+ - 235
14
+ A:
15
+ - 192
16
+ - 193
17
+ - 194
18
+ - 195
19
+ - 196
20
+ - 197
21
+ a:
22
+ - 224
23
+ - 225
24
+ - 226
25
+ - 227
26
+ - 228
27
+ - 229
28
+ - 230
29
+ C:
30
+ - 199
31
+ c:
32
+ - 231
33
+ O:
34
+ - 210
35
+ - 211
36
+ - 212
37
+ - 213
38
+ - 214
39
+ - 216
40
+ o:
41
+ - 242
42
+ - 243
43
+ - 244
44
+ - 245
45
+ - 246
46
+ - 248
47
+ I:
48
+ - 204
49
+ - 205
50
+ - 206
51
+ - 207
52
+ i:
53
+ - 236
54
+ - 237
55
+ - 238
56
+ - 239
57
+ U:
58
+ - 217
59
+ - 218
60
+ - 219
61
+ - 220
62
+ u:
63
+ - 249
64
+ - 250
65
+ - 251
66
+ - 252
67
+ N:
68
+ - 209
69
+ n:
70
+ - 241
71
+ Y:
72
+ - 221
73
+ y:
74
+ - 253
75
+ - 255
76
+ AE:
77
+ - 306
78
+ ae:
79
+ - 346
80
+ OE:
81
+ - 188
82
+ oe:
83
+ - 189
84
+ ss:
85
+ - 223
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remove_accents
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marco Metz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-04-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: You can use this extension to the String class to convert "àéêîôûù" to
95
+ "aeeiouu".
96
+ email:
97
+ - marco.metz@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .rvmrc
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - Guardfile
106
+ - LICENSE
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/extend_string.rb
111
+ - lib/remove_accents.rb
112
+ - lib/remove_accents/base.rb
113
+ - lib/remove_accents/configuration.rb
114
+ - lib/remove_accents/version.rb
115
+ - remove_accents.gemspec
116
+ - spec/lib/remove_accents_spec.rb
117
+ - spec/spec_helper.rb
118
+ - template/remove_accents.yml
119
+ homepage: https://github.com/ikuseiGmbH/Remove-Accents-Ruby-Script
120
+ licenses:
121
+ - GNU GENERAL PUBLIC LICENSE
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.26
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: String class to convert "àéêîôûù" to "aeeiouu"
144
+ test_files:
145
+ - spec/lib/remove_accents_spec.rb
146
+ - spec/spec_helper.rb