noaccent 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: '029c57767af236dd6605a6373b781a9bef478a387ae8b74cbce51b80e0fbfcce'
4
+ data.tar.gz: 30849dd92c1dc359b8b25414fa9f668e328b2c454d258374aeee275f90daf859
5
+ SHA512:
6
+ metadata.gz: caefe26d80ed4b6d013a2e7c970151cb4ca20a5d14b69b1f883e0d25c83a05d375b6862aa2a4cd2e51231a6521461fda2cc6cc01a63daf18244043f044e67d53
7
+ data.tar.gz: 88dfcce274e0ac672d597b13d05a9065216a51b6b76058135d775682c33756daee1c129f9c7a1f49b409459188f75cefd45f570dfff9cb24f6a8e3ba77ebc6bf
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Layout/LineLength:
8
+ Max: 200
9
+
10
+ Metrics/AbcSize:
11
+ Max: 30
12
+
13
+ Metrics/BlockLength:
14
+ Max: 50
15
+
16
+ Metrics/MethodLength:
17
+ Max: 20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 YutoYasunaga
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,55 @@
1
+ # NoAccent
2
+
3
+ NoAccent is a simple Ruby gem that helps in removing accents from text. It is particularly useful in handling strings with special characters.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'noaccent'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ gem install noaccent
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Using NoAccent is straightforward:
28
+
29
+ ```ruby
30
+ require 'noaccent'
31
+
32
+ puts NoAccent.cut("Ōsaka") # => "Osaka"
33
+ puts "Ōsaka".cut_accent # => "Osaka"
34
+ ```
35
+
36
+ This gem is useful for removing accents from Vietnamese text:
37
+
38
+ ```ruby
39
+ NoAccent.cut 'Hoàng Sa Trường Sa là của Việt Nam!'
40
+ # => Hoang Sa Truong Sa la cua Viet Nam!
41
+ ```
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/YutoYasunaga/noaccent.
52
+
53
+ ## License
54
+
55
+ 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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
+ require 'rails_best_practices/rake_task'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RuboCop::RakeTask.new
9
+ RailsBestPractices::RakeTask.new
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ task default: %i[rubocop rails_best_practices spec]
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ A_LINE_DOWNCASE = 'àáạảãâầấậẩẫăằắặẳẵäåā'
4
+ A_LINE_UPCASE = 'ÀÁẠẢÃĂẰẮẶẲẴÂẦẤẬẨẪÄÅĀ'
5
+ O_LINE_DOWNCASE = 'òóọỏõôồốộổỗơờớợởỡöō'
6
+ O_LINE_UPCASE = 'ÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÖŌ'
7
+ E_LINE_DOWNCASE = 'èéẹẻẽêềếệểễëē'
8
+ E_LINE_UPCASE = 'ÈÉẸẺẼÊỀẾỆỂỄËĒ'
9
+ U_LINE_DOWNCASE = 'ùúụủũưừứựửữûüū'
10
+ U_LINE_UPCASE = 'ƯỪỨỰỬỮÙÚỤỦŨÛÜŪ'
11
+ I_LINE_DOWNCASE = 'ìíịỉĩîïī'
12
+ I_LINE_UPCASE = 'ÌÍỊỈĨÎÏĪ'
13
+ Y_LINE_DOWNCASE = 'ỳýỵỷỹÿ'
14
+ Y_LINE_UPCASE = 'ỲÝỴỶỸŸ'
15
+ D_LINE_DOWNCASE = 'đð'
16
+ D_LINE_UPCASE = 'Đ'
17
+ C_LINE_DOWNCASE = 'ç'
18
+ C_LINE_UPCASE = 'Ç'
19
+ N_LINE_DOWNCASE = 'ñ'
20
+ N_LINE_UPCASE = 'Ñ'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class String
4
+ def cut_accent
5
+ NoAccent.cut(self)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NoAccent
4
+ VERSION = '0.1.0'
5
+ end
data/lib/noaccent.rb ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'noaccent/version'
4
+ require 'noaccent/accent'
5
+ require 'noaccent/string_extension'
6
+
7
+ module NoAccent
8
+ class Error < StandardError; end
9
+
10
+ def self.cut(string)
11
+ string = string.tr(A_LINE_DOWNCASE, 'a')
12
+ string = string.tr(A_LINE_UPCASE, 'A')
13
+ string = string.tr(O_LINE_DOWNCASE, 'o')
14
+ string = string.tr(O_LINE_UPCASE, 'O')
15
+ string = string.tr(E_LINE_DOWNCASE, 'e')
16
+ string = string.tr(E_LINE_UPCASE, 'E')
17
+ string = string.tr(U_LINE_DOWNCASE, 'u')
18
+ string = string.tr(U_LINE_UPCASE, 'U')
19
+ string = string.tr(I_LINE_DOWNCASE, 'i')
20
+ string = string.tr(I_LINE_UPCASE, 'I')
21
+ string = string.tr(Y_LINE_DOWNCASE, 'y')
22
+ string = string.tr(Y_LINE_UPCASE, 'Y')
23
+ string = string.tr(D_LINE_DOWNCASE, 'd')
24
+ string = string.tr(D_LINE_UPCASE, 'D')
25
+ string = string.tr(C_LINE_DOWNCASE, 'c')
26
+ string = string.tr(C_LINE_UPCASE, 'C')
27
+ string = string.tr(N_LINE_DOWNCASE, 'n')
28
+ string.tr(N_LINE_UPCASE, 'N')
29
+ end
30
+ end
data/noaccent.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/noaccent/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'noaccent'
7
+ spec.version = NoAccent::VERSION
8
+ spec.authors = ['YutoYasunaga']
9
+ spec.email = ['yuto.yasunaga@gmail.com']
10
+
11
+ spec.summary = 'A Ruby gem to remove accents from text'
12
+ spec.description = 'NoAccent is a Ruby gem designed to remove diacritic accents from text, providing cleaner and simpler text processing.'
13
+ spec.homepage = 'https://github.com/YutoYasunaga/noaccent'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/YutoYasunaga/noaccent.git'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) ||
25
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
26
+ end
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
data/sig/noaccent.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module NoAccent
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noaccent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - YutoYasunaga
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-07-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: NoAccent is a Ruby gem designed to remove diacritic accents from text,
14
+ providing cleaner and simpler text processing.
15
+ email:
16
+ - yuto.yasunaga@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/noaccent.rb
27
+ - lib/noaccent/accent.rb
28
+ - lib/noaccent/string_extension.rb
29
+ - lib/noaccent/version.rb
30
+ - noaccent.gemspec
31
+ - sig/noaccent.rbs
32
+ homepage: https://github.com/YutoYasunaga/noaccent
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/YutoYasunaga/noaccent
37
+ source_code_uri: https://github.com/YutoYasunaga/noaccent.git
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.6.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.4.17
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: A Ruby gem to remove accents from text
57
+ test_files: []