unaccent 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 22fd05234b8a82c9fb4528e7490bc96d35d6004891106e64b89a41c3019fb05d
4
+ data.tar.gz: c8878cdf36d7647264676d22b6068398a9c5a4c67dc48a65a7e2033a9d65e97c
5
+ SHA512:
6
+ metadata.gz: 8fddd65833fc29aaaee6dd35088181403803714bd54d0dccfaa499dad55928c2263db27561cdefa0a565d0bb587a64d969f2523a3a87994caa9935b530a1461b
7
+ data.tar.gz: 33b518cba22b0919320a1b4ac65bd4406b2dac1b2cbe17b63448a59ea132967a2014120dc5ca461e74de9fa4cf782ceb9422fe548a56538c204ec723c6549457
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: Build
3
+
4
+ on:
5
+ push:
6
+ branches: [master]
7
+ paths-ignore:
8
+ - 'README.md'
9
+ - 'LICENSE.txt'
10
+ - 'bin/**'
11
+ pull_request:
12
+ branches: [master]
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build:
19
+ strategy:
20
+ matrix:
21
+ os: [ubuntu-latest]
22
+ ruby: ['2.7']
23
+ runs-on: ${{ matrix.os }}
24
+
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true
33
+
34
+ - name: Run tests
35
+ run: |
36
+ bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in buildex.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Jonian Guveli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Unaccent
2
+
3
+ Ruby gem to replace a string's accent characters with ASCII characters. Based on [SixArm Ruby Unaccent](https://github.com/SixArm/sixarm_ruby_unaccent).
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/unaccent.svg)](https://badge.fury.io/rb/unaccent)
6
+ [![Build](https://github.com/hardpixel/unaccent/actions/workflows/build.yml/badge.svg)](https://github.com/hardpixel/unaccent/actions/workflows/build.yml)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/9070ea120ceeddbcc1d2/maintainability)](https://codeclimate.com/github/hardpixel/unaccent/maintainability)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'unaccent'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install unaccent
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require 'unaccent'
29
+
30
+ Unaccent.unaccent('déjà vu') # deja vu
31
+ Unaccent.unaccent('νέα') # νεα
32
+
33
+ require 'unaccent/string'
34
+
35
+ 'déjà vu'.unaccent # deja vu
36
+ 'νέα'.unaccent # νεα
37
+ ```
38
+
39
+ ## Benchmark
40
+
41
+ ```
42
+ IPS Comparison:
43
+ gsub: 33804.1 i/s
44
+ each_char: 16639.9 i/s - 2.03x (± 0.00) slower
45
+ each_char (sixarm): 13708.2 i/s - 2.47x (± 0.00) slower
46
+ scan: 10390.0 i/s - 3.25x (± 0.00) slower
47
+ scan (sixarm): 8765.8 i/s - 3.86x (± 0.00) slower
48
+ split_map: 7800.9 i/s - 4.33x (± 0.00) slower
49
+ split_map (sixarm): 6780.7 i/s - 4.99x (± 0.00) slower
50
+
51
+
52
+ Memory Comparison:
53
+ gsub: 5947 allocated
54
+ each_char: 10704 allocated - 1.80x more
55
+ scan: 15368 allocated - 2.58x more
56
+ split_map: 20582 allocated - 3.46x more
57
+ split_map (sixarm): 23185 allocated - 3.90x more
58
+ each_char (sixarm): 24979 allocated - 4.20x more
59
+ scan (sixarm): 29979 allocated - 5.04x more
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/unaccent.
71
+
72
+ ## License
73
+
74
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
data/bin/benchmark ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+ require 'tempfile'
5
+
6
+ gemfile true, quiet: true do
7
+ source 'https://rubygems.org'
8
+ gemspec
9
+
10
+ gem 'benchmark-ips'
11
+ gem 'benchmark-memory'
12
+ gem 'sixarm_ruby_unaccent'
13
+ end
14
+
15
+ STRINGS = [
16
+ 'String without accents in english',
17
+ 'Streng med aksenter på norsk',
18
+ 'Řetězec s akcenty v češtině',
19
+ 'Chaîne avec accents en français',
20
+ 'Cuerda con acentos en español',
21
+ 'Corda amb accents en català',
22
+ 'Stīga ar akcentiem latviešu valodā',
23
+ 'Türkçe aksanlı dize',
24
+ 'Varg me theks në shqip',
25
+ 'Κείμενο με τόνους στα ελληνικά'
26
+ ]
27
+
28
+ reports = lambda do |x|
29
+ x.report('gsub') do
30
+ STRINGS.each do |str|
31
+ Unaccent.via_gsub(str)
32
+ end
33
+ end
34
+
35
+ x.report('scan') do
36
+ STRINGS.each do |str|
37
+ Unaccent.via_scan(str)
38
+ end
39
+ end
40
+
41
+ x.report('each_char') do
42
+ STRINGS.each do |str|
43
+ Unaccent.via_each_char(str)
44
+ end
45
+ end
46
+
47
+ x.report('split_map') do
48
+ STRINGS.each do |str|
49
+ Unaccent.via_split_map(str)
50
+ end
51
+ end
52
+
53
+
54
+ x.report('scan (sixarm)') do
55
+ STRINGS.each do |str|
56
+ str.unaccent_via_scan
57
+ end
58
+ end
59
+
60
+ x.report('each_char (sixarm)') do
61
+ STRINGS.each do |str|
62
+ str.unaccent_via_each_char
63
+ end
64
+ end
65
+
66
+ x.report('split_map (sixarm)') do
67
+ STRINGS.each do |str|
68
+ str.unaccent_via_split_map
69
+ end
70
+ end
71
+ end
72
+
73
+ Benchmark.ips do |x|
74
+ reports.call(x)
75
+ x.compare!
76
+ end
77
+
78
+ Benchmark.memory do |x|
79
+ reports.call(x)
80
+ x.compare!
81
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'unaccent'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here