gost_translit 0.0.1 → 0.0.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: 48f17d4cc768844b03c5769e9e0c8921faf2ca6f70c3928c576ad12811cec8c3
4
- data.tar.gz: 43ea36c1fe5485616d08c35b0c769d3b703a4d2ede713e8ea96af8ec0e91f1fd
3
+ metadata.gz: 8a524e2ba64716799fd77662f20d4631242047b3bfe13b6de42a6cf9889c309b
4
+ data.tar.gz: 5b0d8e3a3170b0122ea7bba0591f4ef92ebd31911d290547c4499df211ea4320
5
5
  SHA512:
6
- metadata.gz: e55e9989a6eee8192fc1a550748982ef7b38b2e09fc101ce7bafde406f1acf294bab6ace6f2e55a096307f52ff0cab699f6605eec986833fb5ecbbe8277583f6
7
- data.tar.gz: b9b5210af713249fb3dd984df0aa9536eca742bc98043e92f8c265b539dd77e7afb55711993f77f4ac5409b96bb4e52b84ecb69998bfd8f82d92b5e922f18fdf
6
+ metadata.gz: c92ee1044566b41af1a8dd8d6017550765b52591b585c40f91fc60e3c8a6bd55cca38a8471b549f7ed72c4bcb74d7aaaed5e230eb7cbec8b6d5d2f5e058d1a35
7
+ data.tar.gz: a52f9401e7700f0b7eda1a4fb9f887257b27f50acd60698b8598f54b79533c2d212aeffbb4d74e3deabdce96f70e2e3ea926306219384611f31eb4a717296dfb
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,25 @@ 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
+ }.freeze
56
57
 
57
58
  LATIN_MAPPING = Hash[
58
- GostTranslit::RU_MAPPING.invert.collect { |k, v| [ k.to_s, v.to_s ] }
59
- ].merge!('c' => 'ц')
59
+ GostTranslit::RU_MAPPING.invert.collect { |k, v| [k.to_s, v.to_s] }
60
+ ].merge!('c' => 'ц').freeze
60
61
 
61
62
  class << self
62
63
  def to_latin(string)
@@ -65,7 +66,7 @@ module GostTranslit
65
66
  words.map! do |word|
66
67
  translit_word = word.downcase
67
68
  .split('')
68
- .map { |l| RU_MAPPING[l.to_sym] || l}
69
+ .map { |l| RU_MAPPING[l.to_sym] || l }
69
70
  .join
70
71
 
71
72
  translit_word.gsub!(/(cz)(?=[i|e|j|y])/, 'c')
@@ -78,7 +79,7 @@ module GostTranslit
78
79
 
79
80
  words.map! do |word|
80
81
  translit_word = word.downcase
81
- LATIN_REPLACING_MAPPING.each { |k,v| translit_word.gsub!(k, v) }
82
+ LATIN_REPLACING_MAPPING.each { |k, v| translit_word.gsub!(k, v) }
82
83
 
83
84
  translit_word = translit_word.split('')
84
85
  .map! { |l| LATIN_MAPPING[l] || l }
@@ -117,15 +117,13 @@ RSpec.describe GostTranslit do
117
117
  end
118
118
  end
119
119
 
120
- describe '.translit' do
120
+ describe '.convert' do
121
121
  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)
122
+ expect(subject.convert(latin_text)).to eq(cyrillic_text)
125
123
  end
126
124
 
127
125
  it 'translit cyrillic text to latin' do
128
- expect(subject.translit(cyrillic_text)).to eq(latin_text)
126
+ expect(subject.convert(cyrillic_text)).to eq(latin_text)
129
127
  end
130
128
  end
131
129
  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.2
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: 2021-07-29 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.2.15
62
+ signing_key:
64
63
  specification_version: 4
65
64
  summary: GOST 7.79-2000 type b transliteration
66
65
  test_files: []