string_ext 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
+ SHA1:
3
+ metadata.gz: 1377790bed7d927442839175faeaa52afb276e6c
4
+ data.tar.gz: 22e7a843305669affe875c741c21a52b362bd020
5
+ SHA512:
6
+ metadata.gz: 1965612dc6f573f994bf62ae8a18ec657ff708f9fd745387811c9ba1a3654d8910e5ac890719061082bec1392fb4e44ce4f75b0afeb8068a43ef6b0792c35732
7
+ data.tar.gz: 28f50bc86906bcb8c94fc0ae0355c6d5ebfb774cd1003ba11405116a22a3ee08cc0cd2ae6dbfb0ed4e86eff5a00d8c6302f6cdcc367b1352cb62923b3ceea36e
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: l5JpQS57ezGj7hioiYFW3E6lBAH76OUDr
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ string_ext
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.4.0
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3.0
8
+ - 2.4.0
9
+ - jruby
10
+ before_install:
11
+ - gem install bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rasti-db.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Gabriel Naiman
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,57 @@
1
+ # StringExt
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/string_ext.svg)](https://rubygems.org/gems/string_ext)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/string_ext.svg?branch=master)](https://travis-ci.org/gabynaiman/string_ext)
5
+ [![Coverage Status](https://coveralls.io/repos/github/gabynaiman/string_ext/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/string_ext?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/gabynaiman/string_ext.svg)](https://codeclimate.com/github/gabynaiman/string_ext)
7
+ [![Dependency Status](https://gemnasium.com/gabynaiman/string_ext.svg)](https://gemnasium.com/gabynaiman/string_ext)
8
+
9
+ String utils for accented and special chars
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'string_ext'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install string_ext
26
+
27
+ ## Usage
28
+
29
+ ```ruby
30
+ StringExt.downcase 'ÁÉÍÓÚÑ' # => 'áéíóúñ'
31
+ StringExt.upcase 'áéíóúñ' # => 'ÁÉÍÓÚÑ'
32
+ StringExt.unaccented 'áÉíÓú' # => 'aEiOu'
33
+ ```
34
+
35
+ ```ruby
36
+ include StringExt
37
+ downcase 'ÁÉÍÓÚÑ' # => 'áéíóúñ'
38
+ upcase 'áéíóúñ' # => 'ÁÉÍÓÚÑ'
39
+ unaccented 'áÉíÓú' # => 'aEiOu'
40
+ ```
41
+
42
+ ```ruby
43
+ module MyModule
44
+ extend StringExt
45
+ downcase 'ÁÉÍÓÚÑ' # => 'áéíóúñ'
46
+ upcase 'áéíóúñ' # => 'ÁÉÍÓÚÑ'
47
+ unaccented 'áÉíÓú' # => 'aEiOu'
48
+ end
49
+ ```
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/string_ext.
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << 'spec'
6
+ t.libs << 'lib'
7
+ t.pattern = ENV['DIR'] ? File.join(ENV['DIR'], '**', '*_spec.rb') : 'spec/**/*_spec.rb'
8
+ t.verbose = false
9
+ t.warning = false
10
+ t.loader = nil if ENV['TEST']
11
+ ENV['TEST'], ENV['LINE'] = ENV['TEST'].split(':') if ENV['TEST'] && !ENV['LINE']
12
+ t.options = ''
13
+ t.options << "--name=/#{ENV['NAME']}/ " if ENV['NAME']
14
+ t.options << "-l #{ENV['LINE']} " if ENV['LINE'] && ENV['TEST']
15
+ end
16
+
17
+ task default: :spec
18
+
19
+ desc 'Pry console'
20
+ task :console do
21
+ require 'string_ext'
22
+ require 'pry'
23
+ ARGV.clear
24
+ Pry.start
25
+ end
data/lib/string_ext.rb ADDED
@@ -0,0 +1,50 @@
1
+ # coding: utf-8
2
+ require_relative 'string_ext/version'
3
+
4
+ module StringExt
5
+
6
+ ACCENTS = {
7
+ 'A' => {
8
+ upcase: 'ÁÀÄÂÃÅĀĂǍ',
9
+ downcase: 'áàäâãåāăǎ'
10
+ },
11
+ 'E' => {
12
+ upcase: 'ÉÈËÊĒĔĖĚ',
13
+ downcase: 'éèëêēĕėě'
14
+ },
15
+ 'I' => {
16
+ upcase: 'ÍÌÏÎĨĬǏ',
17
+ downcase: 'íìïîĩĭǐ'
18
+ },
19
+ 'O' => {
20
+ upcase: 'ÓÒÖÔÕŌŎŐǑ',
21
+ downcase: 'óòöôõōŏőǒ'
22
+ },
23
+ 'U' => {
24
+ upcase: 'ÚÙÜÛŨŪŬŮŰǓ',
25
+ downcase: 'úùüûũūŭůűǔ'
26
+ }
27
+ }
28
+
29
+ CASES = {
30
+ downcase: 'ñç' + ACCENTS.values.map { |a| a[:downcase] }.join,
31
+ upcase: 'ÑÇ' + ACCENTS.values.map { |a| a[:upcase] }.join
32
+ }
33
+
34
+ extend self
35
+
36
+ def upcase(string)
37
+ string.tr(CASES[:downcase], CASES[:upcase]).upcase
38
+ end
39
+
40
+ def downcase(string)
41
+ string.tr(CASES[:upcase], CASES[:downcase]).downcase
42
+ end
43
+
44
+ def unaccented(string)
45
+ ACCENTS.inject(string) do |s, (char, cases)|
46
+ s.tr(cases[:upcase], char).tr(cases[:downcase], char.downcase)
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,3 @@
1
+ module StringExt
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
5
+ SimpleCov.start
@@ -0,0 +1,5 @@
1
+ require 'coverage_helper'
2
+ require 'string_ext'
3
+ require 'minitest/autorun'
4
+ require 'minitest/colorin'
5
+ require 'pry-nav'
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+ require 'minitest_helper'
3
+
4
+ describe StringExt do
5
+
6
+ it 'Upcase' do
7
+ StringExt.upcase('ñçáàäâãåāăǎéèëêēĕėěíìïîĩĭǐóòöôõōŏőǒúùüûũūŭůűǔ').must_equal 'ÑÇÁÀÄÂÃÅĀĂǍÉÈËÊĒĔĖĚÍÌÏÎĨĬǏÓÒÖÔÕŌŎŐǑÚÙÜÛŨŪŬŮŰǓ'
8
+ end
9
+
10
+ it 'Downcase' do
11
+ StringExt.downcase('ÑÇÁÀÄÂÃÅĀĂǍÉÈËÊĒĔĖĚÍÌÏÎĨĬǏÓÒÖÔÕŌŎŐǑÚÙÜÛŨŪŬŮŰǓ').must_equal 'ñçáàäâãåāăǎéèëêēĕėěíìïîĩĭǐóòöôõōŏőǒúùüûũūŭůűǔ'
12
+ end
13
+
14
+ it 'Unaccented' do
15
+ StringExt.unaccented('ÁÀÄÂÃÅĀĂǍÉÈËÊĒĔĖĚÍÌÏÎĨĬǏÓÒÖÔÕŌŎŐǑÚÙÜÛŨŪŬŮŰǓáàäâãåāăǎéèëêēĕėěíìïîĩĭǐóòöôõōŏőǒúùüûũūŭůűǔ').must_equal 'AAAAAAAAAEEEEEEEEIIIIIIIOOOOOOOOOUUUUUUUUUUaaaaaaaaaeeeeeeeeiiiiiiiooooooooouuuuuuuuuu'
16
+ end
17
+
18
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'string_ext/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'string_ext'
8
+ spec.version = StringExt::VERSION
9
+ spec.authors = ['Gabriel Naiman']
10
+ spec.email = ['gabynaiman@gmail.com']
11
+ spec.summary = 'String utils for accented and special chars'
12
+ spec.description = 'String utils for accented and special chars'
13
+ spec.homepage = 'https://github.com/gabynaiman/string_ext'
14
+ spec.license = 'MIT'
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.12'
22
+ spec.add_development_dependency 'rake', '~> 11.0'
23
+ spec.add_development_dependency 'minitest', '~> 5.0'
24
+ spec.add_development_dependency 'minitest-colorin', '~> 0.1'
25
+ spec.add_development_dependency 'minitest-line', '~> 0.6'
26
+ spec.add_development_dependency 'simplecov', '~> 0.12'
27
+ spec.add_development_dependency 'coveralls', '~> 0.8'
28
+ spec.add_development_dependency 'pry-nav', '~> 0.2'
29
+
30
+ if RUBY_VERSION < '2'
31
+ spec.add_development_dependency 'term-ansicolor', '~> 1.3.0'
32
+ spec.add_development_dependency 'tins', '~> 1.6.0'
33
+ spec.add_development_dependency 'json', '~> 1.8'
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string_ext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gabriel Naiman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-colorin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-line
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.12'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.12'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-nav
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.2'
125
+ description: String utils for accented and special chars
126
+ email:
127
+ - gabynaiman@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".ruby-gemset"
135
+ - ".ruby-version"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - lib/string_ext.rb
142
+ - lib/string_ext/version.rb
143
+ - spec/coverage_helper.rb
144
+ - spec/minitest_helper.rb
145
+ - spec/string_ext_spec.rb
146
+ - string_ext.gemspec
147
+ homepage: https://github.com/gabynaiman/string_ext
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.6.8
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: String utils for accented and special chars
171
+ test_files:
172
+ - spec/coverage_helper.rb
173
+ - spec/minitest_helper.rb
174
+ - spec/string_ext_spec.rb