diacritics 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 819a11d5ad9fab59051154e2238802053e7df6bb
4
- data.tar.gz: 1873d3de563547dd0888fd89ffdba0137f3a23c1
3
+ metadata.gz: cadcaa152badc5ffa3119d7ea996e0219bb416bd
4
+ data.tar.gz: c0795350eac1c5716818ee3e8c708229d3825800
5
5
  SHA512:
6
- metadata.gz: 44a90379ff5c310542bcbdb0de8bfaff5e2afdf666e1bd012aca1042f28b6b311fa5692d46f10528de81eab38158db9cc7b2486855cb0d4fd8566bd27ada400b
7
- data.tar.gz: babe37ae10a720370805663be0cedd30894592f8e6959a61ffe49e22c75e60e7c03b65de380c5bb69f3a58ca1b4ee30e38f3bde1f1c87f375195cbea32984464
6
+ metadata.gz: a74f4a9b7ad8c0eef3d318fca50350f379f5769bc655a9e95499d619c24dc05d1ad2deb644061258607eaa7f9ee45f9dcb972649f519b1442ae3aad541b3a36d
7
+ data.tar.gz: caca7dd56f5837ac415db9df5f5bcb7eccec00040a002f70971e772b87fdd978c2a6e3657465a2ab521628a3f1f0168c838db041b3f8e512c8404b87aeb0b2cd
data/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --format documentation
@@ -1,6 +1,11 @@
1
1
  AllCops:
2
2
  Excludes:
3
3
  - diacritics.gemspec
4
+ - Guardfile
4
5
  LineLength:
5
6
  Enabled: true
6
7
  Max: 79
8
+ Style/AsciiComments:
9
+ Enabled: false
10
+ Style/FrozenStringLiteralComment:
11
+ Enabled: false
@@ -1 +1 @@
1
- 2.2
1
+ 2.3
@@ -4,4 +4,8 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.0
6
6
  - 2.2.0
7
+ - 2.3.0
7
8
  - jruby-head
9
+ before_install:
10
+ - gem install bundler
11
+ - gem update bundler
data/Gemfile CHANGED
@@ -3,11 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development, :test do
6
- gem 'coveralls', require: false
6
+ # gem 'coveralls', require: false
7
7
  gem 'rspec', '~> 3.4.0'
8
- gem 'guard'
9
- gem 'guard-bundler'
10
- gem 'guard-rspec'
11
- gem 'rb-readline', '~> 0.5.0', require: false
12
- gem 'simplecov', require: false
13
8
  end
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Dependency Status](https://gemnasium.com/fractalsoft/diacritics.png)](https://gemnasium.com/fractalsoft/diacritics)
5
5
  [![Coverage Status](https://coveralls.io/repos/fractalsoft/diacritics/badge.png)](https://coveralls.io/r/fractalsoft/diacritics)
6
6
  [![Stories in Ready](https://badge.waffle.io/fractalsoft/diacritics.png)](http://waffle.io/fractalsoft/diacritics)
7
- [![endorse](https://api.coderwall.com/torrocus/endorsecount.png)](https://coderwall.com/torrocus)
8
7
 
9
8
  Diacritics is a gem which support downcase, upcase and permanent link with diacritical characters.
10
9
 
@@ -49,3 +48,6 @@ and use
49
48
  3. Commit your changes (`git commit -am 'Add some feature'`)
50
49
  4. Push to the branch (`git push origin my-new-feature`)
51
50
  5. Create new Pull Request
51
+
52
+ Please remember about tests. Before you add new characters add test first and check that this test doesn't pass.
53
+ Many of characters are the same in different languages.
data/TODO.md CHANGED
@@ -1,12 +1,9 @@
1
1
  ## Examples containing:
2
2
 
3
- * Czech [Ď, Ě, Ň, Ť, Ů, Ú, Û, "aábcčdďeéěfghiíjklmnňoópqrřsštťuúůvwxyýzž", "AÁBCČDĎEÉĚFGHIÍJKLMNŇOÓPQRŘSŠTŤUÚŮVWXYÝZŽ"]
4
- * French [Œ, Ÿ, Î, Ï, "abcdefghijklmnopqrstuvwxyzàâæçéèêëîïôœùûüÿ", "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ"]
5
3
  * Portuguese [Â, "abcdefghijklmnopqrstuvwxyzáâãàçéêíóôõú", "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÂÃÀÇÉÊÍÓÔÕÚ"]
6
4
  * Russian [Щ, Ъ, Э, "абвгдеёжзийклмнопрстуфхцчшщъыьэюя", "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"]
7
5
  * Greek [Β, Μ, Χ, Ω, Ή, Ύ, Ώ, ΐ, ΰ, Ϊ, Ϋ]
8
6
  * Slovak ["aáäeéiíoóôuúyýbcčdďfghjklĺľmnňpqrŕsštťvwxzž", "AÁÄEÉIÍOÓÔUÚYÝBCČDĎFGHJKLĹĽMNŇPQRŔSŠTŤVWXZŽ"]
9
- * Spanish [ñ Ñ]
10
7
  * Italian ["aàbcdeèéfghiìíîlmnoòópqrstuùúvz", "AÀBCDEÈÉFGHIÌÍÎLMNOÒÓPQRSTUÙÚVZ"]
11
8
  * Romanian ["aăâbcdefghiîjklmnopqrsștțuvwxyz", "AĂÂBCDEFGHIÎJKLMNOPQRSȘTȚUVWXYZ"]
12
9
  * Danish [å, â, ô, Å, Â, Ô]
@@ -5,6 +5,7 @@ module Diacritics
5
5
  private
6
6
 
7
7
  # Characters from many alphabets
8
+ # Get from https://en.wikipedia.org/wiki/Diacritic
8
9
  class Alphabet
9
10
  attr_reader :regexp, :hash
10
11
 
@@ -25,10 +26,10 @@ module Diacritics
25
26
  end
26
27
 
27
28
  def prepare_hash
28
- klass = Diacritics::Alphabet
29
- hash = klass.hashed(@downcase, @upcase)
30
- one = klass.hashed(@downcase, @permanent)
31
- two = klass.hashed(@upcase, @permanent)
29
+ class_name = Diacritics::Alphabet
30
+ hash = class_name.hashed(@downcase, @upcase)
31
+ one = class_name.hashed(@downcase, @permanent)
32
+ two = class_name.hashed(@upcase, @permanent)
32
33
  {
33
34
  downcase: hash.invert,
34
35
  upcase: hash,
@@ -37,7 +38,8 @@ module Diacritics
37
38
  end
38
39
 
39
40
  def prepare_regexp
40
- downcase, upcase = @upcase.join, @downcase.join
41
+ downcase = @upcase.join
42
+ upcase = @downcase.join
41
43
  permanent = (@downcase + @upcase).uniq.join
42
44
  {
43
45
  downcase: /[#{downcase}]/,
@@ -50,23 +52,24 @@ module Diacritics
50
52
  #
51
53
  # ["a", "b"], ["A", "B"] #=> {"a" => "A", "b" => "B"}
52
54
  def self.hashed(one, two)
53
- hash = {}
54
- [one, two].transpose.each { |key, value| hash[key] = value }
55
- hash
55
+ Hash[one.zip two]
56
56
  end
57
57
 
58
58
  def data
59
- {
60
- en: en, de: de, pl: pl, cs: cs, fr: fr, it: it, eo: eo,
61
- is: is, pt: pt, sp: sp, hu: hu, nn: nn, ru: ru, gr: gr
62
- }
59
+ languages.each_with_object({}) do |language, hash|
60
+ hash[language] = send(language)
61
+ end
62
+ end
63
+
64
+ def languages
65
+ [:en, :de, :pl, :cs, :fr, :it, :eo, :is, :pt, :sp, :hu, :nn, :ru, :gr]
63
66
  end
64
67
 
65
68
  def en
66
69
  { # English
67
- downcase: [' ', '?', '.', ','],
68
- upcase: [' ', '?', '.', ','],
69
- permanent: ['-', '', '', '']
70
+ downcase: [' ', '!', ',', '.', ':', '?', '«', '»'],
71
+ upcase: [' ', '!', ',', '.', ':', '?', '«', '»'],
72
+ permanent: ['-', '', '', '', '', '', '', '']
70
73
  }
71
74
  end
72
75
 
@@ -87,15 +90,19 @@ module Diacritics
87
90
  end
88
91
 
89
92
  def cs
90
- { # Czech
91
- downcase: %w(á č í ř š ý ž),
92
- upcase: %w(Á Č Í Ř Š Ý Ž),
93
- permanent: %w(a c i r s y z)
93
+ { # Czech uses acute (á é í ó ú ý), caron (č ď ě ň ř š ť ž), ring (ů)
94
+ # aábcčdďeéěfghiíjklmnňoópqrřsštťuúůvwxyýzž
95
+ # AÁBCČDĎEÉĚFGHIÍJKLMNŇOÓPQRŘSŠTŤUÚŮVWXYÝZŽ
96
+ downcase: %w(á é í ó ú ý č ď ě ň ř š ť ů ž),
97
+ upcase: %w(Á É Í Ó Ú Ý Č Ď Ě Ň Ř Š Ť Ů Ž),
98
+ permanent: %w(a e i o u y c d e n r s t u z)
94
99
  }
95
100
  end
96
101
 
97
102
  def fr
98
103
  { # French
104
+ # abcdefghijklmnopqrstuvwxyzàâæçéèêëîïôœùûüÿ
105
+ # ABCDEFGHIJKLMNOPQRSTUVWXYZÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ
99
106
  downcase: %w(à â é è ë ê ï î ô ù û ü ÿ ç œ æ),
100
107
  upcase: %w(À Â É È Ë Ê Ï Î Ô Ù Û Ü Ÿ Ç Œ Æ),
101
108
  permanent: %w(a a e e e e i i o u u ue y c oe ae)
@@ -104,14 +111,14 @@ module Diacritics
104
111
 
105
112
  def it
106
113
  { # Italian
107
- downcase: %w(ì ù ò),
108
- upcase: %w(Ì Ù Ò),
109
- permanent: %w(i u o)
114
+ downcase: %w(à è é ì î ò ó ù),
115
+ upcase: %w(À È É Ì Î Ò Ó Ù),
116
+ permanent: %w(a e e i i o o u)
110
117
  }
111
118
  end
112
119
 
113
120
  def eo
114
- { # Esperanto
121
+ { # Esperantohas the symbols ŭ, ĉ, ĝ, ĥ, ĵ and ŝ
115
122
  downcase: %w(ĉ ĝ ĥ ĵ ŝ ŭ),
116
123
  upcase: %w(Ĉ Ĝ Ĥ Ĵ Ŝ Ŭ),
117
124
  permanent: %w(c g h j s u)
@@ -127,7 +134,7 @@ module Diacritics
127
134
  end
128
135
 
129
136
  def pt
130
- { # Portugal
137
+ { # Portugal uses á, â, ã, à, ç, é, ê, í, ó, ô, õ and ú
131
138
  downcase: %w(ã ç),
132
139
  upcase: %w(Ã Ç),
133
140
  permanent: %w(a c)
@@ -136,9 +143,9 @@ module Diacritics
136
143
 
137
144
  def sp
138
145
  { # Spanish
139
- downcase: ['¿'],
140
- upcase: ['¿'],
141
- permanent: ['']
146
+ downcase: ['ñ', 'õ', '¿', '¡'],
147
+ upcase: ['Ñ', 'Õ', '¿', '¡'],
148
+ permanent: ['n', 'o', '', '']
142
149
  }
143
150
  end
144
151
 
@@ -15,8 +15,9 @@ module Diacritics
15
15
  end
16
16
 
17
17
  def initialize
18
- @alphabet = Diacritics::Alphabet.new
19
- @hash, @regexp = @alphabet.hash, @alphabet.regexp
18
+ alphabet = Diacritics::Alphabet.new
19
+ @hash = alphabet.hash
20
+ @regexp = alphabet.regexp
20
21
  end
21
22
 
22
23
  def downcase(text)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # Gem version
3
3
  module Diacritics
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.10'.freeze
5
5
  end
@@ -167,6 +167,32 @@ describe Diacritics::String do
167
167
  end
168
168
  end
169
169
 
170
+ context 'Spanish' do
171
+ it_behaves_like 'word processing' do
172
+ subject { 'Whisky bueno: ¡excitad mi frágil pequeña vejez!' }
173
+ let(:result) do
174
+ [
175
+ 'whisky bueno: ¡excitad mi frágil pequeña vejez!',
176
+ 'WHISKY BUENO: ¡EXCITAD MI FRÁGIL PEQUEÑA VEJEZ!',
177
+ 'whisky-bueno-excitad-mi-fragil-pequena-vejez'
178
+ ]
179
+ end
180
+ end
181
+ end
182
+
183
+ context 'Portugués' do
184
+ it_behaves_like 'word processing' do
185
+ subject { 'Luís argüia à Júlia que «brações, fé, chá, óxido, pôr, zângão» eram palavras do português.' }
186
+ let(:result) do
187
+ [
188
+ 'luís argüia à júlia que «brações, fé, chá, óxido, pôr, zângão» eram palavras do português.',
189
+ 'LUÍS ARGÜIA À JÚLIA QUE «BRAÇÕES, FÉ, CHÁ, ÓXIDO, PÔR, ZÂNGÃO» ERAM PALAVRAS DO PORTUGUÊS.',
190
+ 'luis-argueia-a-julia-que-bracoes-fe-cha-oxido-por-zangao-eram-palavras-do-portugues'
191
+ ]
192
+ end
193
+ end
194
+ end
195
+
170
196
  context do
171
197
  it_behaves_like 'word processing' do
172
198
  subject { 'À l’époque de la conquête de la Gaule par les armées' }
@@ -510,7 +536,7 @@ describe Diacritics::String do
510
536
  [
511
537
  'dès noël où un zéphyr haï me vêt de glaçons würmiens je dîne d’exquis rôtis de bœuf au kir à l’aÿ d’âge mûr & cætera !',
512
538
  'DÈS NOËL OÙ UN ZÉPHYR HAÏ ME VÊT DE GLAÇONS WÜRMIENS JE DÎNE D’EXQUIS RÔTIS DE BŒUF AU KIR À L’AŸ D’ÂGE MÛR & CÆTERA !',
513
- 'des-noel-ou-un-zephyr-hai-me-vet-de-glacons-wuermiens-je-dine-d’exquis-rotis-de-boeuf-au-kir-a-l’ay-d’age-mur-&-caetera-!'
539
+ 'des-noel-ou-un-zephyr-hai-me-vet-de-glacons-wuermiens-je-dine-d’exquis-rotis-de-boeuf-au-kir-a-l’ay-d’age-mur-&-caetera-'
514
540
  ]
515
541
  end
516
542
  end
@@ -1,9 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'diacritics'
3
- require 'coveralls'
4
- Coveralls.wear!
5
- require 'simplecov'
6
- SimpleCov.start
3
+ # require 'coveralls'
4
+ # Coveralls.wear!
7
5
 
8
6
  RSpec.configure do |config|
9
7
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diacritics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksander Malaszkiewicz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-29 00:00:00.000000000 Z
12
+ date: 2017-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.4.8
94
+ rubygems_version: 2.5.2
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Support diacritics