cyrillic 0.2.0 → 0.3.0

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: 84b7f65d75b1416034469c7fbd59f3fd28cd48e9c5808273cec879bef04f0145
4
- data.tar.gz: a0cc60903905063f13f7d4ae390ad22cd3cce194911eb05808a0f67d112eaead
3
+ metadata.gz: 6a5904094fb9d492197e816b4dd0270aa4245e64fe3388b5a8177bef6deb01fd
4
+ data.tar.gz: 2fd71ce5f7e37778beae85554c5bcfc6277b348278d931219efddbbae6175020
5
5
  SHA512:
6
- metadata.gz: 4c4fc3f26c1d6d8cf58eddd82ca7e84767277e53fa06db85f757c1fa994abf35216bb19c0776807708380abf0db038ee213d2d88d6f9a146c61d3976f74e486a
7
- data.tar.gz: 98581c63c2d61c5775a690ee1c278aeb180445f9f94d328efc3445ff398ff223678fcbd9de1cea9a63d51a824c4bd64b028d04da6b2997a9ac3400ec9f8e6f6b
6
+ metadata.gz: ea05ab8fbb717eec3902faca17b7c2783fb8e5e2dd5feab4ef003f0d979d1e91dadc001cde2fdc06d86eb8beaaf503621b61df8b23137e47b798c61cf384eba0
7
+ data.tar.gz: dfd8f00970bb557ed16b6d7db598365f6110ebc8815f9ab088ef164a392bc075d94c285859eb80a021d71645c27c76495454dd1f0f9f2688205f3ebc17731852
data/.rubocop.yml ADDED
@@ -0,0 +1,50 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ Exclude:
5
+ - 'bin/**/*'
6
+ - 'pkg/**/*'
7
+ - 'vendor/**/*'
8
+ - 'coverage/**/*'
9
+
10
+ Layout/LineLength:
11
+ AllowedPatterns:
12
+ - '^\s*assert_equal'
13
+ - '^\s*#'
14
+ - '^\s*"'
15
+ - 'spec\.description'
16
+ - 'k = %w\['
17
+ - 'v = %w\['
18
+
19
+ Style/StringLiterals:
20
+ Enabled: false
21
+
22
+ Style/Documentation:
23
+ Enabled: false
24
+
25
+ Style/AsciiComments:
26
+ Enabled: false
27
+
28
+ Gemspec/DevelopmentDependencies:
29
+ Enabled: false
30
+
31
+ Metrics/AbcSize:
32
+ Enabled: false
33
+
34
+ Metrics/MethodLength:
35
+ Enabled: false
36
+
37
+ Metrics/CyclomaticComplexity:
38
+ Enabled: false
39
+
40
+ Metrics/PerceivedComplexity:
41
+ Enabled: false
42
+
43
+ Metrics/BlockLength:
44
+ Enabled: false
45
+
46
+ Metrics/ModuleLength:
47
+ Enabled: false
48
+
49
+ Metrics/CollectionLiteralLength:
50
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.3.0] - 2026-09-17
11
+
12
+ ### Added
13
+ - CLI executable `exe/cyrillic` supporting direct arguments, files, piped STDIN, and scheme flag (`-s`).
14
+ - Integration tests for CLI arguments, flags, files, and STDIN input.
15
+ - GitHub Actions CI workflow for modern Ruby versions (`3.3`, `3.4`, `head`) on `main` branch.
16
+ - Automated GitHub Actions release workflow for building and publishing gem on git tag push.
17
+ - Dependabot configuration for automated Bundler and GitHub Actions dependency updates.
18
+ - Precompiled and cached regular expressions for character tables for improved performance.
19
+ - Case-insensitive scheme resolution (e.g. `:iso9`, `"ISO9"`, `:de`, `"UA_PASSPORT"`).
20
+ - Informative `ArgumentError` when an unknown transliteration scheme is specified.
21
+ - Standard gem metadata URIs (`source_code_uri`, `changelog_uri`, `bug_tracker_uri`, `rubygems_mfa_required`).
22
+ - Comprehensive YARD documentation with examples for `Cyrillic.transliterate` and `Cyrillic.t`.
23
+ - SimpleCov test coverage tracking achieving 100% line coverage.
24
+ - Unit tests for edge cases (nil, empty strings, scheme normalization, error handling).
25
+
26
+ ### Changed
27
+ - Namespaced scheme modules under `Cyrillic` (`Cyrillic::Iso9`, `Cyrillic::Mongolian`, `Cyrillic::Ukrainian`, `Cyrillic::UaPassport`, `Cyrillic::De`) with backwards-compatible top-level aliases.
28
+ - Set minimum required Ruby version to `>= 3.3.0` in gemspec.
29
+ - Update development dependencies (rubocop, rake, rdoc, irb, minitest, simplecov).
30
+ - Untrack `Gemfile.lock` and add to `.gitignore` following gem development best practices.
31
+ - Add `.gitattributes` for consistent LF line endings and diff drivers.
32
+ - Integrate RuboCop code style checks into default `rake` task.
33
+ - Update copyright year to 2018-2026 in `LICENSE.txt`.
34
+
35
+ ### Fixed
36
+ - Eliminate mutable string literal warnings under Ruby 3.4+ in Ukrainian Passport transliteration.
37
+ - Fix character mappings and duplicate key warnings in ISO 9 table (`ӵ` and `ҿ`).
38
+
39
+ ### Removed
40
+ - Legacy `.travis.yml` configuration.
41
+ - Empty 0-byte placeholder files from `lib/cyrillic/`.
42
+
43
+ ## [0.2.0] - 2025-11-09
44
+
45
+ ### Added
46
+ - ISO 9 transliteration support (`:iso9`).
47
+ - Mongolian transliteration support (`:mongolian`).
48
+ - Ukrainian transliteration support (`:ukrainian`).
49
+ - Ukrainian passport transliteration standard support (`:ua_passport`).
50
+ - German transliteration standard support (`:de`).
51
+
52
+ ## [0.1.0] - 2018-04-05
53
+
54
+ ### Added
55
+ - Initial release.
56
+ - Core Cyrillic transliteration to Roman (Latin) script.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 rovetz
3
+ Copyright (c) 2018-2026 rovetz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,26 +1,26 @@
1
- # Cyrillic -> Latin: Cyrillic.t("Кириллица") => "Kirillitsa"
1
+ # Cyrillic
2
2
 
3
+ [![Ruby](https://github.com/rovetz/cyrillic/actions/workflows/ruby.yml/badge.svg)](https://github.com/rovetz/cyrillic/actions/workflows/ruby.yml)
3
4
  [![Gem Version](https://badge.fury.io/rb/cyrillic.svg)](https://badge.fury.io/rb/cyrillic)
4
- [![Build Status](https://travis-ci.org/rovetz/cyrillic.svg?branch=main)](https://travis-ci.org/rovetz/cyrillic)
5
5
  [![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- **Cyrillic** is a Ruby gem for the romanization (transliteration) of Cyrillic script into the Latin alphabet. It provides a simple and flexible way to convert Cyrillic text using various international and language-specific standards.
7
+ **Cyrillic** is a Ruby gem for romanization (transliteration) of Cyrillic script into the Roman (Latin) alphabet. It provides a simple and flexible interface with support for international and national standards.
8
8
 
9
- ## Features
9
+ ## Supported Schemes
10
10
 
11
- This gem supports multiple transliteration standards:
12
-
13
- * `generic` (Default)
14
- * `iso9`
15
- * `ukrainian`
16
- * `mongolian`
11
+ * `:cyrillic` (Default generic Cyrillic transliteration)
12
+ * `:iso9` (ISO 9:1995 standard)
13
+ * `:ukrainian` (Ukrainian national standard)
14
+ * `:ua_passport` (Ukrainian international passport transliteration standard)
15
+ * `:mongolian` (Mongolian Cyrillic MNS 5217:2012)
16
+ * `:de` (German Duden/phonetic transliteration)
17
17
 
18
18
  ## Installation
19
19
 
20
20
  Add this line to your application's Gemfile:
21
21
 
22
22
  ```ruby
23
- gem 'cyrillic'
23
+ gem "cyrillic"
24
24
  ```
25
25
 
26
26
  And then execute:
@@ -33,53 +33,73 @@ Or install it yourself as:
33
33
 
34
34
  ## Usage
35
35
 
36
- The gem provides a simple interface through the `Cyrillic.t` (or `Cyrillic.transliterate`) method.
37
-
38
- ### Basic Usage
39
-
40
- By default, it uses a generic transliteration scheme.
41
-
42
36
  ```ruby
43
37
  require "cyrillic"
44
38
 
39
+ # Default Cyrillic transliteration
40
+ Cyrillic.transliterate("Кириллица")
41
+ # => "KirilliTSa"
42
+
43
+ # Short alias .t
45
44
  Cyrillic.t("Кириллица")
46
- #=> "Kirillitsa"
47
- ```
45
+ # => "KirilliTSa"
48
46
 
49
- ### Specifying a Standard
47
+ # ISO 9:1995 scheme
48
+ Cyrillic.t("Не важно, как медленно ты продвигаешься", :iso9)
49
+ # => "Ne važno, kak medlenno ty prodvigaešʹsâ"
50
50
 
51
- You can specify a transliteration standard by passing a symbol as the second argument.
51
+ # Ukrainian scheme
52
+ Cyrillic.t("Київ", :ukrainian)
53
+ # => "Kyiv"
52
54
 
53
- #### ISO 9
55
+ # Ukrainian passport scheme
56
+ Cyrillic.t("Борщагівка", :ua_passport)
57
+ # => "Borshchahivka"
54
58
 
55
- ```ruby
56
- Cyrillic.transliterate("Кириллица", :iso9)
57
- #=> "Kirillica"
59
+ # Mongolian scheme
60
+ Cyrillic.t("Монгол хэл", :mongolian)
61
+ # => "Mongol khel"
62
+
63
+ # German transliteration scheme
64
+ Cyrillic.t("Чайковский", :de)
65
+ # => "Tschajkowskij"
58
66
  ```
59
67
 
60
- #### Ukrainian
68
+ ### Command Line Interface (CLI)
61
69
 
62
- ```ruby
63
- Cyrillic.transliterate("Кирилиця", :ukrainian)
64
- #=> "Kyrylytsia"
65
- ```
70
+ You can also use `cyrillic` directly from your terminal:
66
71
 
67
- #### Mongolian
72
+ ```bash
73
+ # Direct argument
74
+ $ cyrillic "Кириллица"
75
+ KirilliTSa
68
76
 
69
- ```ruby
70
- Cyrillic.t("Монгол хэл", :mongolian)
71
- #=> "Mongol khel"
72
- ```
77
+ # Piped input (STDIN)
78
+ $ echo "Кириллица" | cyrillic
79
+ KirilliTSa
73
80
 
74
- ## Development
81
+ # File input
82
+ $ cyrillic text.txt
75
83
 
76
- After checking out the repo, run `bin/setup` to install development dependencies.
84
+ # Specify transliteration scheme
85
+ $ cyrillic -s iso9 "Транслитерация"
86
+ Transliteraciâ
77
87
 
78
- To run the test suite, use the `rake` command:
88
+ $ cyrillic -s ukrainian "Київ"
89
+ Kyiv
90
+
91
+ $ cyrillic -s ua_passport "Борщагівка"
92
+ Borshchahivka
93
+
94
+ $ cyrillic -s de "Весна"
95
+ Wesna
96
+ ```
97
+
98
+ ## Development
79
99
 
80
- $ rake
100
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run tests and code style checks (RuboCop). You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
101
 
82
- You can also run `bin/console` for an interactive prompt that will allow you to experiment with the gem.
102
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
103
 
84
104
  ## Contributing
85
105
 
@@ -91,4 +111,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
91
111
 
92
112
  ## Code of Conduct
93
113
 
94
- Everyone interacting in the Cyrillic project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rovetz/cyrillic/blob/master/CODE_OF_CONDUCT.md).
114
+ Everyone interacting in the Cyrillic project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rovetz/cyrillic/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
3
6
 
4
7
  Rake::TestTask.new(:test) do |t|
5
8
  t.libs << "test"
@@ -7,4 +10,6 @@ Rake::TestTask.new(:test) do |t|
7
10
  t.test_files = FileList["test/**/*_test.rb"]
8
11
  end
9
12
 
10
- task :default => :test
13
+ RuboCop::RakeTask.new(:rubocop)
14
+
15
+ task default: %i[test rubocop]
data/cyrillic.gemspec CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
4
6
  require "cyrillic/version"
5
7
 
6
8
  Gem::Specification.new do |spec|
@@ -10,17 +12,30 @@ Gem::Specification.new do |spec|
10
12
  spec.email = ["zakbox@gmail.com"]
11
13
 
12
14
  spec.summary = "Romanization (transliteration) of Cyrillic"
13
- spec.description = "Romanization (transliteration) of Cyrillic. Converts Cyrillic text to the Roman (Latin) script"
15
+ spec.description = "Converts Cyrillic text to the Roman (Latin) script"
14
16
  spec.homepage = "https://github.com/rovetz/cyrillic"
15
17
  spec.license = "MIT"
18
+ spec.required_ruby_version = ">= 3.3.0"
19
+
20
+ spec.metadata["source_code_uri"] = "https://github.com/rovetz/cyrillic"
21
+ spec.metadata["changelog_uri"] = "https://github.com/rovetz/cyrillic/blob/main/CHANGELOG.md"
22
+ spec.metadata["bug_tracker_uri"] = "https://github.com/rovetz/cyrillic/issues"
23
+ spec.metadata["rubygems_mfa_required"] = "true"
16
24
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").select { |f| File.file?(f) }.reject do |f|
27
+ (File.expand_path(f) == __FILE__) ||
28
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github Gemfile])
29
+ end
19
30
  end
20
31
  spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.executables = ["cyrillic"]
22
33
  spec.require_paths = ["lib"]
23
34
 
24
- spec.add_development_dependency "rake", "~> 13.0"
25
- spec.add_development_dependency "minitest", "~> 5.0"
35
+ spec.add_development_dependency "irb"
36
+ spec.add_development_dependency "minitest", ">= 5.25"
37
+ spec.add_development_dependency "rake", ">= 13.2"
38
+ spec.add_development_dependency "rdoc"
39
+ spec.add_development_dependency "rubocop", ">= 1.64"
40
+ spec.add_development_dependency "simplecov", ">= 0.22"
26
41
  end
data/exe/cyrillic ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "optparse"
5
+ require "cyrillic"
6
+
7
+ scheme = nil
8
+
9
+ parser = OptionParser.new do |opts|
10
+ opts.banner = "Usage: cyrillic [options] [text | file...]"
11
+ opts.separator ""
12
+ opts.separator "Transliterate Cyrillic script to Roman (Latin) script."
13
+ opts.separator ""
14
+ opts.separator "Examples:"
15
+ opts.separator " cyrillic 'Кириллица'"
16
+ opts.separator " echo 'Кириллица' | cyrillic"
17
+ opts.separator " cyrillic text.txt"
18
+ opts.separator " cyrillic -s iso9 'Транслитерация'"
19
+ opts.separator " cyrillic -s ukrainian 'Київ'"
20
+ opts.separator " cyrillic -s ua_passport 'Борщагівка'"
21
+ opts.separator " cyrillic -s mongolian 'Монгол'"
22
+ opts.separator " cyrillic -s de 'Весна'"
23
+ opts.separator ""
24
+ opts.separator "Options:"
25
+
26
+ opts.on("-s", "--scheme SCHEME", %w[default cyrillic iso9 mongolian ukrainian ua_passport de],
27
+ "Transliteration scheme (default, cyrillic, iso9, mongolian, ukrainian, ua_passport, de)") do |s|
28
+ scheme = s == "default" ? nil : s.to_sym
29
+ end
30
+
31
+ opts.on("-v", "--version", "Show version") do
32
+ puts "cyrillic #{Cyrillic::VERSION}"
33
+ exit
34
+ end
35
+
36
+ opts.on("-h", "--help", "Show this help message") do
37
+ puts opts
38
+ exit
39
+ end
40
+ end
41
+
42
+ parser.parse!
43
+
44
+ transliterate = lambda do |text|
45
+ Cyrillic.transliterate(text, scheme || :cyrillic)
46
+ end
47
+
48
+ if ARGV.empty?
49
+ if $stdin.tty?
50
+ puts parser
51
+ exit 1
52
+ else
53
+ $stdin.each_line do |line|
54
+ puts transliterate.call(line.chomp)
55
+ end
56
+ end
57
+ else
58
+ ARGV.each do |arg|
59
+ if File.file?(arg)
60
+ File.foreach(arg) do |line|
61
+ puts transliterate.call(line.chomp)
62
+ end
63
+ else
64
+ puts transliterate.call(arg)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cyrillic
4
+ module De
5
+ k = %w[А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я].freeze
6
+ v = %w[A B W G D E Jo Sch S I J K L M N O P R S T U F Ch Z Tsch Sch Schtsch "" Y "" E Ju Ja a b w g d e jo sch s i j k l m n o p r s t u f ch z tsch sch schtsch "" y "" e ju ja].freeze
7
+
8
+ CHARACTER_TABLE = k.zip(v).to_h.freeze
9
+ REGEXP = Regexp.union(CHARACTER_TABLE.keys).freeze
10
+ end
11
+ end
12
+
13
+ De = Cyrillic::De unless defined?(De)