ruslat 1.0.1 → 1.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: ccb4c8190c8faa4cd39922f2233c0238581e787ee1dec17401c3da00e3a02818
4
- data.tar.gz: 432d43453786f1f7c0335bc0555240cfec0142a9915a1effd568aacf61e0ea4c
3
+ metadata.gz: 7c306235bbffc758b3e67e417be3925864403240266615eed7e8869864d87bf6
4
+ data.tar.gz: cac8dccb9dade2c74c076b8e5b65c905084582856dde1ecd1ad535133930d124
5
5
  SHA512:
6
- metadata.gz: 7e402e50bef7126530534283b20c26994f2f8adf8c6488d8bad40770d7c2fdf0c13384b8045e5ab866e2009e5c3f6c2d4855a04771b0dafc1d4be73289bbb33d
7
- data.tar.gz: 63a67746382d3d29e0df40a6d9be5803895031947e8fc35b7b6b858f3f2d9e6da847e181af8f9a75d562f436d7287d8b09587d510ed7ecc0e654279ec1f5c0da
6
+ metadata.gz: 13e1b496a408991d26a6c25b06608af34c2a2c3b40c2504cbaea2b64e2dbba4560c7738bc4001f80ef317b4a8bfab8f710ef414ee91f0fd92749c7251bdc4fd2
7
+ data.tar.gz: 1f5c451a411c3216f2e26268ad1284b23da2c5ad9a377922b70343e66068956438c199e5bc45580779ea80f9b92a19ce935e20fc24f537e040f4cc9660e50678
data/README.md CHANGED
@@ -30,7 +30,7 @@ Ruslat.rus_to_lat("Привет Мир!") # => "Privet Mir!"
30
30
  Ruslat.lat_to_rus("Privet Mir!") # => "Привет Мир!"
31
31
 
32
32
  Ruslat.rus_to_lat("АЛЁША") # => "ALYoShA"
33
- Ruslat.case_correct("ALYoShA") # => "ALYOSHA"
33
+ Ruslat.lat_case_correct("ALYoShA") # => "ALYOSHA"
34
34
 
35
35
  typo = "CAPA"
36
36
  typo.bytes # => [67, 65, 80, 65]
data/exe/ruslat CHANGED
@@ -1,3 +1,56 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "ruslat"
4
+ require "optparse"
5
+
6
+ options = {
7
+ convert: :rus_lat,
8
+ "typo-correct": true,
9
+ "case-correct": true
10
+ }
11
+
12
+ OptionParser.new do |parser|
13
+ parser.banner = "Usage: ruslat [options] [path]"
14
+
15
+ parser.on("-R", "Convert RUS => LAT (default)") { options[:convert] = :rus_lat }
16
+ parser.on("-L", "Convert LAT => RUS") { options[:convert] = :lat_rus }
17
+
18
+ parser.on("-t", "--text=TEXT", String, "Text to convert")
19
+ # parser.on("-f", "--[no-]filename", "Convert file names")
20
+ # parser.on("-d", "--[no-]dirname", "Convert directory names")
21
+ # parser.on("-r", "--[no-]recursive", "Convert file/directory names recursive")
22
+
23
+ parser.on("-T", "--[no-]typo-correct", "Typo correct (default: true)")
24
+ parser.on("-C", "--[no-]case-correct", "Case correct (default: true)")
25
+
26
+ parser.on("-v", "--[no-]verbose", "Run verbosely")
27
+
28
+ parser.on("-h", "--help", "Prints this page") do
29
+ puts parser
30
+ exit
31
+ end
32
+ end.parse!(into: options)
33
+
34
+ text = if options.key?(:text)
35
+ options[:text].to_s
36
+ elsif ARGV[0] && File.exist?(ARGV[0])
37
+ File.read(ARGV[0])
38
+ elsif !$stdin.tty?
39
+ $stdin.read
40
+ else
41
+ ARGV.join(" ")
42
+ end
43
+
44
+ text.chomp!
45
+
46
+ if options[:convert] == :rus_lat
47
+ text = Ruslat.rus_typo_correct(text) if options[:"typo-correct"]
48
+ text = Ruslat.rus_to_lat(text)
49
+ text = Ruslat.lat_case_correct(text) if options[:"case-correct"]
50
+ elsif options[:convert] == :lat_rus
51
+ text = Ruslat.lat_typo_correct(text) if options[:"typo-correct"]
52
+ text = Ruslat.lat_to_rus(text)
53
+ end
54
+
55
+ $stdout << text
56
+ $stdout << "\n" unless text.empty?
data/lib/ruslat/core.rb CHANGED
@@ -8,8 +8,8 @@ module Ruslat
8
8
  # Обозначения:
9
9
  # * RUSLAT - #rus_to_lat
10
10
  # * LATRUS - #lat_to_rus
11
- # * CASECORRECT - #case_correct
12
- # * LCORRECT - #typo_correct
11
+ # * CASECORRECT - #lat_case_correct
12
+ # * LCORRECT - #rus_typo_correct
13
13
  #
14
14
  # RUSLAT перекодирует кириллицу в латиницу.
15
15
  #
@@ -272,8 +272,8 @@ module Ruslat
272
272
  str
273
273
  end
274
274
 
275
- # Case correct, example: АЛЁША (rus_to_lat)→ ALYoShA (case_correct)→ ALYOSHA
276
- def case_correct(string)
275
+ # Case correct, example: АЛЁША (rus_to_lat)→ ALYoShA (lat_case_correct)→ ALYOSHA
276
+ def lat_case_correct(string)
277
277
  str = string.dup
278
278
  str.gsub!(/([A-Z])h([A-Z])/, &:upcase)
279
279
  str.gsub!(/J([aeou])([A-Z])/, &:upcase)
@@ -288,6 +288,12 @@ module Ruslat
288
288
  str
289
289
  end
290
290
 
291
+ # Deprecated, use `lat_case_correct` instead
292
+ def case_correct(string)
293
+ warn("DEPRECATION WARNING: Usage of `case_correct` deprecated, use `lat_case_correct` instead")
294
+ lat_case_correct(string)
295
+ end
296
+
291
297
  # Typo correct replaces 'cyrillic-look-like' latin symbols to cyrillic ones
292
298
  def rus_typo_correct(string)
293
299
  string.tr(
@@ -302,7 +308,7 @@ module Ruslat
302
308
  rus_typo_correct(*args)
303
309
  end
304
310
 
305
- # Typo correct replaces 'cyrillic-look-like' latin symbols to cyrillic ones
311
+ # Typo correct replaces 'latin-look-like' cyrillic symbols to latin ones
306
312
  def lat_typo_correct(string)
307
313
  string.tr(
308
314
  "асекорихуАВСЕНКМОРТХУ",
@@ -1,3 +1,3 @@
1
1
  module Ruslat
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruslat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliy Sukhachev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2023-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler