greeklish_iso843 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8fdabbc41fcf736259cc0635a62ce9e37ea40b0ddca6279da804de77297ff9b
4
- data.tar.gz: dd0dc66e47ebacb5e6db56367887b6bc27c37f1a414907a26db1e24e13b6238c
3
+ metadata.gz: 46b2cbf0c06d497c6304b9c8cad2c85e29723d741c8f83c74dbb3236463ee4a8
4
+ data.tar.gz: 2b81ed1ae06fd1bee3951879ccc840eedcf0965a17420d63ba10083acb447d50
5
5
  SHA512:
6
- metadata.gz: d46ed5272f19fe1aae1579e9eb8bc2740c99cb96201f42148d5caccc95f1a72300f7bf4778251e7744f9803230756c09451596ee828fe3d3fde2690d1749e74a
7
- data.tar.gz: 7e30e6a280adc1aadc25c30b2afdbf0277fd93f2f156b628faf08f7f934d816a853de8bc140b74717addbb6650fac457dcce9d7421def07ab6c8f6b0c90a5d84
6
+ metadata.gz: e946eb95e8666400056fa2e5a07cc3a4b3924607bbc6d2f717c9c022013200629bddfa2d09f72d40ce15cd913c1f8fede0e03d63de85d5833729252e8432cf3d
7
+ data.tar.gz: b705856436f156c99fb14c316054a2d9d65b953e82acfab9daaeeb61a0dcca8583861c70e222e9264b938f599456408e92d1782916fae62e4f8cea64b997df31
data/CHANGELOG.md CHANGED
@@ -7,11 +7,26 @@ The format is based on [Keep a Changelog][] and this project adheres to
7
7
 
8
8
  ## [Unreleased][]
9
9
 
10
+ ## [0.4.2][] - 2021-05-29
11
+
12
+ ### Changed
13
+
14
+ - Do not raise `UnhandledCaseError` if next character is a symbol when
15
+ converting a pair that ends with `υ` to `v` or `f`. For example, `άνευ` would
16
+ correctly transliterate to `anef` but `άνευ.` would raise due to `.` at the
17
+ end.
18
+ - Fix case for leading `Θ`, `Χ` and `Ψ` when the word is capitalized. For
19
+ example, `ψάθα` would correctly transliterate to `psatha`, but `Ψάθα` would
20
+ incorrectly transliterate to `PSatha`. Now it is transliterated to `Psatha`.
21
+
10
22
  ## [0.4.1][] - 2021-04-29
11
23
 
24
+ ### Changed
25
+
12
26
  - Do not raise `UnhandledCaseError` if next character is whitespace when
13
- converting v or f. For example, `άνευ` would correctly transliterate to `anef`
14
- but `άνευ λόγου` would raise due to the whitespace after `ευ`.
27
+ converting a pair that ends with `υ` to `v` or `f`. For example, `άνευ` would
28
+ correctly transliterate to `anef` but `άνευ λόγου` would raise due to the
29
+ whitespace after `ευ`.
15
30
 
16
31
  ## [0.4.0][] - 2021-04-28
17
32
 
@@ -50,4 +65,6 @@ Initial release.
50
65
  [0.2.0]: https://github.com/agorf/greeklish_iso843/compare/0.1.0...0.2.0
51
66
  [0.3.0]: https://github.com/agorf/greeklish_iso843/compare/0.2.0...0.3.0
52
67
  [0.4.0]: https://github.com/agorf/greeklish_iso843/compare/0.3.0...0.4.0
53
- [Unreleased]: https://github.com/agorf/greeklish_iso843/compare/0.4.0...HEAD
68
+ [0.4.1]: https://github.com/agorf/greeklish_iso843/compare/0.4.0...0.4.1
69
+ [0.4.2]: https://github.com/agorf/greeklish_iso843/compare/0.4.1...0.4.2
70
+ [Unreleased]: https://github.com/agorf/greeklish_iso843/compare/0.4.2...HEAD
@@ -11,8 +11,6 @@ class GreeklishIso843::GreekText
11
11
 
12
12
  GREEK_LETTERS_AFTER_F = 'θκξπστφχψ'.freeze
13
13
 
14
- BLANK_REGEXP = /\A[[:space:]]*\z/.freeze
15
-
16
14
  REPLACEMENTS = {
17
15
  'αι' => 'ai',
18
16
  'αί' => 'ai',
@@ -97,7 +95,7 @@ class GreeklishIso843::GreekText
97
95
 
98
96
  next match if greeklish.nil? # Unhandled case. Return as-is.
99
97
 
100
- fix_case(greeklish, match)
98
+ fix_case(greeklish, match, Regexp.last_match)
101
99
  end
102
100
  end
103
101
 
@@ -118,14 +116,52 @@ class GreeklishIso843::GreekText
118
116
  match # Unhandled case. Return as-is.
119
117
  end
120
118
 
121
- private def fix_case(greeklish, match)
122
- return greeklish if !uppercase?(match[0])
119
+ private def fix_case(greeklish, match, match_data)
120
+ if !uppercase?(match[0])
121
+ return greeklish
122
+ end
123
+
124
+ if match.size == 1
125
+ return fix_case_single_letter_match(greeklish, match_data)
126
+ end
127
+
128
+ if match.size == 2
129
+ return fix_case_two_letter_match(greeklish, match)
130
+ end
131
+
132
+ raise UnhandledCaseError
133
+ end
134
+
135
+ private def fix_case_single_letter_match(greeklish, match_data)
136
+ if greeklish.size == 1
137
+ return greeklish.upcase
138
+ end
123
139
 
124
- if match.size == 1 || uppercase?(match[1])
125
- greeklish.upcase
126
- else
127
- greeklish[0].upcase + greeklish[1].to_s
140
+ if greeklish.size == 2 # match is one of Θ, Χ, Ψ
141
+ return fix_case_th_ch_ps(greeklish, match_data)
128
142
  end
143
+
144
+ raise UnhandledCaseError
145
+ end
146
+
147
+ private def fix_case_two_letter_match(greeklish, match)
148
+ if uppercase?(match[1])
149
+ return greeklish.upcase
150
+ end
151
+
152
+ greeklish[0].upcase + greeklish[1].to_s
153
+ end
154
+
155
+ private def fix_case_th_ch_ps(greeklish, match_data)
156
+ next_char = match_data.post_match[0]
157
+
158
+ if next_char.nil? ||
159
+ next_char !~ REPLACEMENT_KEYS_REGEXP ||
160
+ !uppercase?(next_char)
161
+ return greeklish[0].upcase + greeklish[1].to_s
162
+ end
163
+
164
+ greeklish.upcase
129
165
  end
130
166
 
131
167
  private def convert_mp_or_b(prev_char, next_char)
@@ -156,12 +192,12 @@ class GreeklishIso843::GreekText
156
192
  end
157
193
 
158
194
  private def convert_v_or_f(next_char)
159
- return 'f' if blank?(next_char) || GREEK_LETTERS_AFTER_F[next_char]
195
+ if next_char.nil? ||
196
+ GREEK_LETTERS_AFTER_F[next_char] ||
197
+ next_char !~ REPLACEMENT_KEYS_REGEXP
198
+ return 'f'
199
+ end
160
200
 
161
201
  'v' if GREEK_LETTERS_AFTER_V[next_char]
162
202
  end
163
-
164
- private def blank?(str)
165
- str.nil? || str =~ BLANK_REGEXP
166
- end
167
203
  end
@@ -1,3 +1,3 @@
1
1
  module GreeklishIso843
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greeklish_iso843
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angelos Orfanakos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: rubygems@angelos.dev
@@ -44,7 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.1.4
47
+ rubyforge_project:
48
+ rubygems_version: 2.7.6.2
48
49
  signing_key:
49
50
  specification_version: 4
50
51
  summary: Convert Greek text to Greeklish conforming to ISO 843 (ELOT 743)