gost_translit 0.0.1 → 0.0.3

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
  SHA256:
3
- metadata.gz: 48f17d4cc768844b03c5769e9e0c8921faf2ca6f70c3928c576ad12811cec8c3
4
- data.tar.gz: 43ea36c1fe5485616d08c35b0c769d3b703a4d2ede713e8ea96af8ec0e91f1fd
3
+ metadata.gz: 80e1f2eb8357c5f3dc4e417d9154617a5dc9dba185f257e2cb712456219a4211
4
+ data.tar.gz: 44ceffbd1c5e63b4faf10f9920d96786e94c1c91cfee2ab1475e613d3f9e76b3
5
5
  SHA512:
6
- metadata.gz: e55e9989a6eee8192fc1a550748982ef7b38b2e09fc101ce7bafde406f1acf294bab6ace6f2e55a096307f52ff0cab699f6605eec986833fb5ecbbe8277583f6
7
- data.tar.gz: b9b5210af713249fb3dd984df0aa9536eca742bc98043e92f8c265b539dd77e7afb55711993f77f4ac5409b96bb4e52b84ecb69998bfd8f82d92b5e922f18fdf
6
+ metadata.gz: a4ab1874fbd964eb936498447c43ff29115affa1ab98354b3ce8dd384addb28b8c69562b388fef2c5ab9e4a5c2b22c0a6c81943964413a6788d3a9981eede111
7
+ data.tar.gz: b9b8483aaa570ccaac7d13adecd86075109f27522c89284f2e39f651b2a132a72beb36967e57cd48febb9464ea85778d6d521cfa55b8dbff99f9ab39ac913168
data/lib/gost_translit.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Main module
3
4
  module GostTranslit
4
- UPPER_REGEXP = /[[:upper:]]/
5
- LOWER_REGEXP = /[[:lower:]]/
5
+ UPPER_REGEXP = /[[:upper:]]/.freeze
6
+ LOWER_REGEXP = /[[:lower:]]/.freeze
6
7
 
7
8
  RU_MAPPING = {
8
9
  'а': 'a',
@@ -38,25 +39,26 @@ module GostTranslit
38
39
  'э': 'e`',
39
40
  'ю': 'yu',
40
41
  'я': 'ya'
41
- }
42
+ }.freeze
42
43
 
43
44
  LATIN_REPLACING_MAPPING = {
44
45
  'shh' => 'щ',
45
- 'sh' => 'ш',
46
- 'yu' => 'ю',
47
- 'ya' => 'я',
48
- '``' => 'ъ',
49
- 'y`' => 'ы',
50
- 'e`' => 'э',
51
- 'ch' => 'ч',
52
- 'cz' => 'ц',
53
- 'zh' => 'ж',
54
- 'yo' => 'ё'
55
- }
46
+ 'sh' => 'ш',
47
+ 'yu' => 'ю',
48
+ 'ya' => 'я',
49
+ '``' => 'ъ',
50
+ 'y`' => 'ы',
51
+ 'e`' => 'э',
52
+ 'ch' => 'ч',
53
+ 'cz' => 'ц',
54
+ 'zh' => 'ж',
55
+ 'yo' => 'ё',
56
+ 'q' => 'к'
57
+ }.freeze
56
58
 
57
59
  LATIN_MAPPING = Hash[
58
- GostTranslit::RU_MAPPING.invert.collect { |k, v| [ k.to_s, v.to_s ] }
59
- ].merge!('c' => 'ц')
60
+ GostTranslit::RU_MAPPING.invert.collect { |k, v| [k.to_s, v.to_s] }
61
+ ].merge!('c' => 'ц').freeze
60
62
 
61
63
  class << self
62
64
  def to_latin(string)
@@ -65,7 +67,7 @@ module GostTranslit
65
67
  words.map! do |word|
66
68
  translit_word = word.downcase
67
69
  .split('')
68
- .map { |l| RU_MAPPING[l.to_sym] || l}
70
+ .map { |l| RU_MAPPING[l.to_sym] || l }
69
71
  .join
70
72
 
71
73
  translit_word.gsub!(/(cz)(?=[i|e|j|y])/, 'c')
@@ -78,7 +80,7 @@ module GostTranslit
78
80
 
79
81
  words.map! do |word|
80
82
  translit_word = word.downcase
81
- LATIN_REPLACING_MAPPING.each { |k,v| translit_word.gsub!(k, v) }
83
+ LATIN_REPLACING_MAPPING.each { |k, v| translit_word.gsub!(k, v) }
82
84
 
83
85
  translit_word = translit_word.split('')
84
86
  .map! { |l| LATIN_MAPPING[l] || l }
@@ -86,6 +86,10 @@ RSpec.describe GostTranslit do
86
86
  it 'changed to "ц" from "cz"' do
87
87
  expect(subject.to_cyrillic('czaplya')).to eq('цапля')
88
88
  end
89
+
90
+ it 'changed to "к" from "q"' do
91
+ expect(subject.to_cyrillic('Qatar')).to eq('Катар')
92
+ end
89
93
  end
90
94
  end
91
95
 
@@ -117,15 +121,13 @@ RSpec.describe GostTranslit do
117
121
  end
118
122
  end
119
123
 
120
- describe '.translit' do
124
+ describe '.convert' do
121
125
  it 'translit latin text to cyrillic' do
122
- puts subject.translit(latin_text)
123
- puts cyrillic_text
124
- expect(subject.translit(latin_text)).to eq(cyrillic_text)
126
+ expect(subject.convert(latin_text)).to eq(cyrillic_text)
125
127
  end
126
128
 
127
129
  it 'translit cyrillic text to latin' do
128
- expect(subject.translit(cyrillic_text)).to eq(latin_text)
130
+ expect(subject.convert(cyrillic_text)).to eq(latin_text)
129
131
  end
130
132
  end
131
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gost_translit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viacheslav Soldatov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-15 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -30,7 +30,7 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.7.0
33
- description:
33
+ description:
34
34
  email:
35
35
  - syntaxys0dll@gmail.com
36
36
  executables: []
@@ -43,7 +43,7 @@ homepage: https://github.com/Syntaxys-dll/gost_7_79_2000_b_translit
43
43
  licenses:
44
44
  - MIT
45
45
  metadata: {}
46
- post_install_message:
46
+ post_install_message:
47
47
  rdoc_options: []
48
48
  require_paths:
49
49
  - lib
@@ -58,9 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.7.6.2
63
- signing_key:
61
+ rubygems_version: 3.4.10
62
+ signing_key:
64
63
  specification_version: 4
65
64
  summary: GOST 7.79-2000 type b transliteration
66
65
  test_files: []