cyrillizer 0.1.0 → 0.2.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 +7 -0
- data/.rspec +1 -0
- data/CHANGELOG +5 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +24 -0
- data/{README.rdoc → README.md} +20 -26
- data/Rakefile +1 -13
- data/cyrillizer.gemspec +15 -49
- data/lib/alphabets/macedonian.yml +63 -0
- data/lib/alphabets/russian.yml +66 -0
- data/lib/alphabets/uzbek.yml +71 -0
- data/lib/cyrillizer.rb +6 -3
- data/lib/cyrillizer/alphabet.rb +22 -0
- data/lib/cyrillizer/converter.rb +14 -17
- data/lib/cyrillizer/version.rb +3 -0
- data/spec/cyrillizer/alphabet_spec.rb +32 -0
- data/spec/cyrillizer/converter_spec.rb +78 -0
- data/spec/spec_helper.rb +0 -9
- metadata +56 -58
- data/VERSION +0 -1
- data/features/convert_latin_to_cyrillic.feature +0 -92
- data/features/step_definitions/convert_latin_to_cyrillic_steps.rb +0 -15
- data/features/support/env.rb +0 -6
- data/spec/cyrillizer_spec.rb +0 -29
- data/spec/spec.opts +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b48240a55e70c74a2aaf39e2f741f47efedbdc87
|
4
|
+
data.tar.gz: aeeeea838f9b9a3b0337dbadf0d4364bb005e416
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5df6c9cabd7fb4a999208cb6a2198f16304a19203ab0dd31d92df083da65ae37f850328b766a484137dea99d7b301285586426fad6a7088bb79f81eb3c805093
|
7
|
+
data.tar.gz: fad3dfa63209b7aa0ea88745e65b6e051149132c250464f2f51bb9ec46a1b936041ba2970a9af37cbe504836eb6943efdcf20344ab958b53355e16221ad924ce
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cyrillizer (0.2.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
rspec (2.14.1)
|
11
|
+
rspec-core (~> 2.14.0)
|
12
|
+
rspec-expectations (~> 2.14.0)
|
13
|
+
rspec-mocks (~> 2.14.0)
|
14
|
+
rspec-core (2.14.5)
|
15
|
+
rspec-expectations (2.14.2)
|
16
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
17
|
+
rspec-mocks (2.14.3)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
cyrillizer!
|
24
|
+
rspec
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,46 +1,40 @@
|
|
1
|
-
|
1
|
+
# cyrillizer
|
2
2
|
|
3
|
-
|
3
|
+
Character conversion from latin to cyrillic and vice versa.
|
4
4
|
|
5
|
-
|
5
|
+
Please contribute conversion alphabets if yours is missing.
|
6
6
|
|
7
|
-
|
7
|
+
## INSTALL
|
8
8
|
|
9
|
-
|
9
|
+
gem install cyrillizer
|
10
10
|
|
11
|
-
|
11
|
+
## USAGE
|
12
12
|
|
13
|
-
$KCODE = 'UTF8'
|
14
|
-
require 'rubygems'
|
15
13
|
require 'cyrillizer'
|
16
|
-
puts 'kirilica'.to_cyr
|
17
|
-
puts 'латиница'.to_lat
|
14
|
+
puts 'kirilica'.to_cyr # => 'кирилица'
|
15
|
+
puts 'латиница'.to_lat # => 'latinica'
|
18
16
|
|
19
|
-
|
17
|
+
Or change conversion language:
|
20
18
|
|
21
|
-
|
22
|
-
puts '
|
23
|
-
puts '
|
24
|
-
|
25
|
-
== INSTALL:
|
26
|
-
|
27
|
-
[sudo] gem install cyrillizer
|
19
|
+
Cyrillizer.language = :russian
|
20
|
+
puts "пульт управления" # => "pul't upravleniya"
|
21
|
+
puts "pul't upravleniya" # => "пульт управления"
|
28
22
|
|
29
|
-
|
23
|
+
## TESTS
|
30
24
|
|
31
|
-
|
32
|
-
|
25
|
+
bundle install
|
26
|
+
rspec spec
|
33
27
|
|
34
|
-
|
28
|
+
## CONTRIBUTORS
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
- Vitaly Zemlyansky ([@vzemlyansky](https://github.com/vzemlyansky))
|
31
|
+
- Peco Danajlovski ([@Vortex](https://github.com/Vortex))
|
38
32
|
|
39
|
-
|
33
|
+
## LICENSE:
|
40
34
|
|
41
35
|
(The MIT License)
|
42
36
|
|
43
|
-
Copyright (c) 2009 Dalibor Nasevic
|
37
|
+
Copyright (c) 2009-2013 Dalibor Nasevic
|
44
38
|
|
45
39
|
Permission is hereby granted, free of charge, to any person obtaining
|
46
40
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
require 'jeweler'
|
3
|
-
Jeweler::Tasks.new do |gemspec|
|
4
|
-
gemspec.name = "cyrillizer"
|
5
|
-
gemspec.summary = "Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa"
|
6
|
-
gemspec.description = "Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa"
|
7
|
-
gemspec.email = "dalibor.nasevic@gmail.com"
|
8
|
-
gemspec.homepage = "http://github.com/dalibor/cyrillizer"
|
9
|
-
gemspec.authors = ["Dalibor Nasevic"]
|
10
|
-
end
|
11
|
-
rescue LoadError
|
12
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
13
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
data/cyrillizer.gemspec
CHANGED
@@ -1,54 +1,20 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/cyrillizer/version', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Dalibor Nasevic"]
|
6
|
+
gem.email = ["dalibor.nasevic@gmail.com"]
|
7
|
+
gem.description = %q{Character conversion from latin to cyrillic.}
|
8
|
+
gem.summary = %q{Character conversion from latin to cyrillic and vice versa.}
|
9
|
+
gem.homepage = "http://github.com/dalibor/cyrillizer"
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".gitignore",
|
20
|
-
"CHANGELOG",
|
21
|
-
"README.rdoc",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"cyrillizer.gemspec",
|
25
|
-
"features/convert_latin_to_cyrillic.feature",
|
26
|
-
"features/step_definitions/convert_latin_to_cyrillic_steps.rb",
|
27
|
-
"features/support/env.rb",
|
28
|
-
"lib/cyrillizer.rb",
|
29
|
-
"lib/cyrillizer/converter.rb",
|
30
|
-
"spec/cyrillizer_spec.rb",
|
31
|
-
"spec/spec.opts",
|
32
|
-
"spec/spec_helper.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/dalibor/cyrillizer}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
38
|
-
s.summary = %q{Character conversion from latin alphabet to Macedonian cyrillic alphabet and vice versa}
|
39
|
-
s.test_files = [
|
40
|
-
"spec/spec_helper.rb",
|
41
|
-
"spec/cyrillizer_spec.rb"
|
42
|
-
]
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "cyrillizer"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Cyrillizer::VERSION
|
17
|
+
gem.license = "MIT"
|
43
18
|
|
44
|
-
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
else
|
50
|
-
end
|
51
|
-
else
|
52
|
-
end
|
19
|
+
gem.add_development_dependency "rspec"
|
53
20
|
end
|
54
|
-
|
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
'Џ': 'Dzh'
|
3
|
+
'џ': 'dzh'
|
4
|
+
'Ѓ': 'Gj'
|
5
|
+
'ѓ': 'gj'
|
6
|
+
'Ж': 'Zh'
|
7
|
+
'ж': 'zh'
|
8
|
+
'Ѕ': 'Dz'
|
9
|
+
'ѕ': 'dz'
|
10
|
+
'Љ': 'Lj'
|
11
|
+
'љ': 'lj'
|
12
|
+
'Њ': 'Nj'
|
13
|
+
'њ': 'nj'
|
14
|
+
'Ќ': 'Kj'
|
15
|
+
'ќ': 'kj'
|
16
|
+
'Ч': 'Ch'
|
17
|
+
'ч': 'ch'
|
18
|
+
'Ш': 'Sh'
|
19
|
+
'ш': 'sh'
|
20
|
+
'А': 'A'
|
21
|
+
'а': 'a'
|
22
|
+
'Б': 'B'
|
23
|
+
'б': 'b'
|
24
|
+
'В': 'V'
|
25
|
+
'в': 'v'
|
26
|
+
'Г': 'G'
|
27
|
+
'г': 'g'
|
28
|
+
'Д': 'D'
|
29
|
+
'д': 'd'
|
30
|
+
'Е': 'E'
|
31
|
+
'е': 'e'
|
32
|
+
'З': 'Z'
|
33
|
+
'з': 'z'
|
34
|
+
'И': 'I'
|
35
|
+
'и': 'i'
|
36
|
+
'Ј': 'J'
|
37
|
+
'ј': 'j'
|
38
|
+
'К': 'K'
|
39
|
+
'к': 'k'
|
40
|
+
'Л': 'L'
|
41
|
+
'л': 'l'
|
42
|
+
'М': 'M'
|
43
|
+
'м': 'm'
|
44
|
+
'Н': 'N'
|
45
|
+
'н': 'n'
|
46
|
+
'О': 'O'
|
47
|
+
'о': 'o'
|
48
|
+
'П': 'P'
|
49
|
+
'п': 'p'
|
50
|
+
'Р': 'R'
|
51
|
+
'р': 'r'
|
52
|
+
'С': 'S'
|
53
|
+
'с': 's'
|
54
|
+
'Т': 'T'
|
55
|
+
'т': 't'
|
56
|
+
'У': 'U'
|
57
|
+
'у': 'u'
|
58
|
+
'Ф': 'F'
|
59
|
+
'ф': 'f'
|
60
|
+
'Х': 'H'
|
61
|
+
'х': 'h'
|
62
|
+
'Ц': 'C'
|
63
|
+
'ц': 'c'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
'Э': 'E'
|
3
|
+
'э': 'e'
|
4
|
+
'Щ': 'Shch'
|
5
|
+
'щ': 'Shch'
|
6
|
+
'Ц': 'Ts'
|
7
|
+
'ц': 'ts'
|
8
|
+
'Ч': 'Ch'
|
9
|
+
'ч': 'ch'
|
10
|
+
'Ш': 'Sh'
|
11
|
+
'ш': 'sh'
|
12
|
+
'Ю': 'Yu'
|
13
|
+
'ю': 'yu'
|
14
|
+
'Я': 'Ya'
|
15
|
+
'я': 'ya'
|
16
|
+
'Ё': 'Ye'
|
17
|
+
'ё': 'ye'
|
18
|
+
'Ж': 'Zh'
|
19
|
+
'ж': 'zh'
|
20
|
+
'А': 'A'
|
21
|
+
'а': 'a'
|
22
|
+
'Б': 'B'
|
23
|
+
'б': 'b'
|
24
|
+
'В': 'V'
|
25
|
+
'в': 'v'
|
26
|
+
'Г': 'G'
|
27
|
+
'г': 'g'
|
28
|
+
'Д': 'D'
|
29
|
+
'д': 'd'
|
30
|
+
'Е': 'e'
|
31
|
+
'е': 'e'
|
32
|
+
'З': 'Z'
|
33
|
+
'з': 'z'
|
34
|
+
'И': 'I'
|
35
|
+
'и': 'i'
|
36
|
+
'Й': 'Y'
|
37
|
+
'й': 'y'
|
38
|
+
'К': 'k'
|
39
|
+
'к': 'k'
|
40
|
+
'Л': 'L'
|
41
|
+
'л': 'l'
|
42
|
+
'М': 'M'
|
43
|
+
'м': 'm'
|
44
|
+
'Н': 'N'
|
45
|
+
'н': 'n'
|
46
|
+
'О': 'o'
|
47
|
+
'о': 'o'
|
48
|
+
'П': 'P'
|
49
|
+
'п': 'p'
|
50
|
+
'Р': 'R'
|
51
|
+
'р': 'r'
|
52
|
+
'С': 'S'
|
53
|
+
'с': 's'
|
54
|
+
'Т': 'T'
|
55
|
+
'т': 't'
|
56
|
+
'У': 'U'
|
57
|
+
'у': 'u'
|
58
|
+
'Ф': 'F'
|
59
|
+
'ф': 'f'
|
60
|
+
'Х': 'H'
|
61
|
+
'х': 'h'
|
62
|
+
'Ъ': "'"
|
63
|
+
'ъ': "'"
|
64
|
+
'Ь': "'"
|
65
|
+
'ь': "'"
|
66
|
+
'ы': "y"
|
@@ -0,0 +1,71 @@
|
|
1
|
+
---
|
2
|
+
'Ў': 'Oʻ'
|
3
|
+
'ў': 'oʻ'
|
4
|
+
'Қ': 'Q'
|
5
|
+
'қ': 'q'
|
6
|
+
'Ғ': 'Gʻ'
|
7
|
+
'ғ': 'gʻ'
|
8
|
+
'Ҳ': 'H'
|
9
|
+
'ҳ': 'h'
|
10
|
+
'Э': 'E'
|
11
|
+
'э': 'e'
|
12
|
+
'Ц': 'S'
|
13
|
+
'ц': 's'
|
14
|
+
'Ч': 'Ch'
|
15
|
+
'ч': 'ch'
|
16
|
+
'Ш': 'Sh'
|
17
|
+
'ш': 'sh'
|
18
|
+
'Ю': 'Yu'
|
19
|
+
'ю': 'yu'
|
20
|
+
'Я': 'Ya'
|
21
|
+
'я': 'ya'
|
22
|
+
'Ё': 'Yo'
|
23
|
+
'ё': 'yo'
|
24
|
+
'Ж': 'J'
|
25
|
+
'ж': 'j'
|
26
|
+
'А': 'A'
|
27
|
+
'а': 'a'
|
28
|
+
'Б': 'B'
|
29
|
+
'б': 'b'
|
30
|
+
'В': 'V'
|
31
|
+
'в': 'v'
|
32
|
+
'Г': 'G'
|
33
|
+
'г': 'g'
|
34
|
+
'Д': 'D'
|
35
|
+
'д': 'd'
|
36
|
+
'Е': 'e'
|
37
|
+
'е': 'e'
|
38
|
+
'З': 'Z'
|
39
|
+
'з': 'z'
|
40
|
+
'И': 'I'
|
41
|
+
'и': 'i'
|
42
|
+
'Й': 'Y'
|
43
|
+
'й': 'y'
|
44
|
+
'К': 'k'
|
45
|
+
'к': 'k'
|
46
|
+
'Л': 'L'
|
47
|
+
'л': 'l'
|
48
|
+
'М': 'M'
|
49
|
+
'м': 'm'
|
50
|
+
'Н': 'N'
|
51
|
+
'н': 'n'
|
52
|
+
'О': 'o'
|
53
|
+
'о': 'o'
|
54
|
+
'П': 'P'
|
55
|
+
'п': 'p'
|
56
|
+
'Р': 'R'
|
57
|
+
'р': 'r'
|
58
|
+
'С': 'S'
|
59
|
+
'с': 's'
|
60
|
+
'Т': 'T'
|
61
|
+
'т': 't'
|
62
|
+
'У': 'U'
|
63
|
+
'у': 'u'
|
64
|
+
'Ф': 'F'
|
65
|
+
'ф': 'f'
|
66
|
+
'Х': 'X'
|
67
|
+
'х': 'x'
|
68
|
+
'Ъ': 'ʻ'
|
69
|
+
'ъ': 'ʻ'
|
70
|
+
'Ь': 'ʻ'
|
71
|
+
'ь': 'ʻ'
|
data/lib/cyrillizer.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
-
|
4
1
|
require 'cyrillizer/converter'
|
2
|
+
require 'cyrillizer/alphabet'
|
3
|
+
|
4
|
+
# Add conversion methods to all strings
|
5
|
+
class String
|
6
|
+
include Cyrillizer::Converter
|
7
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Cyrillizer
|
6
|
+
attr_writer :language
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def language
|
10
|
+
@language ||= :macedonian
|
11
|
+
end
|
12
|
+
|
13
|
+
def language=(language)
|
14
|
+
@language = language
|
15
|
+
@alphabet = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def alphabet
|
19
|
+
@alphabet ||= YAML.load_file(File.join(File.dirname(__FILE__), "../alphabets/#{language.to_s}.yml"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/cyrillizer/converter.rb
CHANGED
@@ -1,38 +1,35 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
|
+
|
2
3
|
module Cyrillizer
|
3
4
|
module Converter
|
4
5
|
|
5
|
-
Latin = %w(DZH Dzh dzh GJ Gj gj ZH Zh zh DZ Dz dz LJ Lj lj NJ Nj nj KJ Kj kj CH Ch ch SH Sh sh A a B b V v G g D d E e Z z I i J j K k L l M m N n O o P p R r S s T t U u F f H h C c)
|
6
|
-
Cyrillic = %w(Џ Џ џ Ѓ Ѓ ѓ Ж Ж ж Ѕ Ѕ ѕ Љ Љ љ Њ Њ њ Ќ Ќ ќ Ч Ч ч Ш Ш ш А а Б б В в Г г Д д Е е З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т У у Ф ф Х х Ц ц)
|
7
|
-
|
8
6
|
def to_cyr
|
9
|
-
code(self.dup,
|
7
|
+
code(self.dup, alphabet.invert)
|
10
8
|
end
|
11
9
|
|
12
10
|
def to_cyr!
|
13
|
-
code(self,
|
11
|
+
code(self, alphabet.invert)
|
14
12
|
end
|
15
13
|
|
16
14
|
def to_lat
|
17
|
-
code(self.dup,
|
15
|
+
code(self.dup, alphabet)
|
18
16
|
end
|
19
17
|
|
20
18
|
def to_lat!
|
21
|
-
code(self,
|
19
|
+
code(self, alphabet)
|
22
20
|
end
|
23
21
|
|
24
22
|
private
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
|
24
|
+
def code(text, alphabet)
|
25
|
+
alphabet.each do |from, to|
|
26
|
+
text.gsub!(from, to)
|
28
27
|
end
|
29
|
-
|
28
|
+
text
|
30
29
|
end
|
31
30
|
|
31
|
+
def alphabet
|
32
|
+
Cyrillizer.alphabet
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
|
-
|
35
|
-
# Add to_cyr method to all Strings
|
36
|
-
class String
|
37
|
-
include Cyrillizer::Converter
|
38
|
-
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Cyrillizer do
|
6
|
+
describe ".language" do
|
7
|
+
it "defaults to macedonian" do
|
8
|
+
Cyrillizer.language.should == :macedonian
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".language=" do
|
13
|
+
before :each do
|
14
|
+
Cyrillizer.language = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
Cyrillizer.language = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can change language" do
|
22
|
+
Cyrillizer.language = :russian
|
23
|
+
Cyrillizer.language.should == :russian
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".alphabet" do
|
28
|
+
it "can load alphabet for a language" do
|
29
|
+
Cyrillizer.alphabet["Џ"].should == "Dzh"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Cyrillizer::Converter do
|
6
|
+
let(:string) { 'anything' }
|
7
|
+
|
8
|
+
|
9
|
+
describe "#to_cyr" do
|
10
|
+
it "converts latin to cyrillic" do
|
11
|
+
"Cela rechenica na latinica".to_cyr.should == "Цела реченица на латиница"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "converts letters with multiple characters" do
|
15
|
+
"Kjeljav Dzhip".to_cyr.should == "Ќељав Џип"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "it copies string before changing" do
|
19
|
+
string.to_cyr.object_id.should_not == string.object_id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#to_cyr!" do
|
24
|
+
it "converts latin to cyrilic" do
|
25
|
+
"Cela rechenica na latinica".to_cyr!.should == "Цела реченица на латиница"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "changes original string" do
|
29
|
+
string.to_cyr!.object_id.should == string.object_id
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#to_lat" do
|
34
|
+
it "converts cyrillic to latin" do
|
35
|
+
"Цела реченица на латиница".to_lat.should == "Cela rechenica na latinica"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "converts letters with multiple characters" do
|
39
|
+
"Ќељав Џип".to_lat.should == "Kjeljav Dzhip"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "it copies string before changing" do
|
43
|
+
string.to_lat.object_id.should_not == string.object_id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#to_lat!" do
|
48
|
+
it "converts cyrilic to latin" do
|
49
|
+
"Цела реченица на латиница".to_lat!.should == "Cela rechenica na latinica"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "changes original string" do
|
53
|
+
string.to_lat!.object_id.should == string.object_id
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "conversion" do
|
58
|
+
it "converts to latin" do
|
59
|
+
"Цела реченица на латиница".to_lat.should == "Cela rechenica na latinica"
|
60
|
+
"Ќељав Џип".to_lat.should == "Kjeljav Dzhip"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "using a different language" do
|
65
|
+
before :each do
|
66
|
+
Cyrillizer.language = :russian
|
67
|
+
end
|
68
|
+
|
69
|
+
after :each do
|
70
|
+
Cyrillizer.language = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "can convert from different language" do
|
74
|
+
"пульт управления".to_lat.should == "pul't upravleniya"
|
75
|
+
"pul't upravleniya".to_cyr.should == "пульт управления"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,81 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyrillizer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Dalibor Nasevic
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
date: 2014-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Character conversion from latin to cyrillic.
|
28
|
+
email:
|
29
|
+
- dalibor.nasevic@gmail.com
|
24
30
|
executables: []
|
25
|
-
|
26
31
|
extensions: []
|
27
|
-
|
28
|
-
|
29
|
-
-
|
30
|
-
|
31
|
-
- .gitignore
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
32
36
|
- CHANGELOG
|
33
|
-
-
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- README.md
|
34
40
|
- Rakefile
|
35
|
-
- VERSION
|
36
41
|
- cyrillizer.gemspec
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
42
|
+
- lib/alphabets/macedonian.yml
|
43
|
+
- lib/alphabets/russian.yml
|
44
|
+
- lib/alphabets/uzbek.yml
|
40
45
|
- lib/cyrillizer.rb
|
46
|
+
- lib/cyrillizer/alphabet.rb
|
41
47
|
- lib/cyrillizer/converter.rb
|
42
|
-
-
|
43
|
-
- spec/
|
48
|
+
- lib/cyrillizer/version.rb
|
49
|
+
- spec/cyrillizer/alphabet_spec.rb
|
50
|
+
- spec/cyrillizer/converter_spec.rb
|
44
51
|
- spec/spec_helper.rb
|
45
|
-
has_rdoc: true
|
46
52
|
homepage: http://github.com/dalibor/cyrillizer
|
47
|
-
licenses:
|
48
|
-
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
49
56
|
post_install_message:
|
50
|
-
rdoc_options:
|
51
|
-
|
52
|
-
require_paths:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
53
59
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
|
56
|
-
requirements:
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
57
62
|
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
version: "0"
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
|
-
requirements:
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
66
67
|
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
segments:
|
70
|
-
- 0
|
71
|
-
version: "0"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
72
70
|
requirements: []
|
73
|
-
|
74
71
|
rubyforge_project:
|
75
|
-
rubygems_version:
|
72
|
+
rubygems_version: 2.2.0
|
76
73
|
signing_key:
|
77
|
-
specification_version:
|
78
|
-
summary: Character conversion from latin
|
79
|
-
test_files:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Character conversion from latin to cyrillic and vice versa.
|
76
|
+
test_files:
|
77
|
+
- spec/cyrillizer/alphabet_spec.rb
|
78
|
+
- spec/cyrillizer/converter_spec.rb
|
80
79
|
- spec/spec_helper.rb
|
81
|
-
- spec/cyrillizer_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
@@ -1,92 +0,0 @@
|
|
1
|
-
Feature: Convert Latin To Cyrilic
|
2
|
-
In order to use appropriate alphabet
|
3
|
-
As an administrator
|
4
|
-
I want to be able to convert all latic characters to cyrilic
|
5
|
-
|
6
|
-
Scenario Outline: User enters latic characters
|
7
|
-
When user writes <latin> character
|
8
|
-
Then that character will be converted into <cyrilic>
|
9
|
-
|
10
|
-
Examples:
|
11
|
-
| latin | cyrilic |
|
12
|
-
| a | а |
|
13
|
-
| A | А |
|
14
|
-
| b | б |
|
15
|
-
| B | Б |
|
16
|
-
| v | в |
|
17
|
-
| V | В |
|
18
|
-
| g | г |
|
19
|
-
| G | Г |
|
20
|
-
| d | д |
|
21
|
-
| D | Д |
|
22
|
-
| gj | ѓ |
|
23
|
-
| GJ | Ѓ |
|
24
|
-
| Gj | Ѓ |
|
25
|
-
| e | е |
|
26
|
-
| E | Е |
|
27
|
-
| zh | ж |
|
28
|
-
| ZH | Ж |
|
29
|
-
| Zh | Ж |
|
30
|
-
| z | з |
|
31
|
-
| Z | З |
|
32
|
-
| dz | ѕ |
|
33
|
-
| DZ | Ѕ |
|
34
|
-
| Dz | Ѕ |
|
35
|
-
| i | и |
|
36
|
-
| I | И |
|
37
|
-
| j | ј |
|
38
|
-
| J | Ј |
|
39
|
-
| k | к |
|
40
|
-
| K | К |
|
41
|
-
| l | л |
|
42
|
-
| L | Л |
|
43
|
-
| lj | љ |
|
44
|
-
| LJ | Љ |
|
45
|
-
| Lj | Љ |
|
46
|
-
| m | м |
|
47
|
-
| M | М |
|
48
|
-
| n | н |
|
49
|
-
| N | Н |
|
50
|
-
| nj | њ |
|
51
|
-
| NJ | Њ |
|
52
|
-
| Nj | Њ |
|
53
|
-
| o | о |
|
54
|
-
| O | О |
|
55
|
-
| p | п |
|
56
|
-
| P | П |
|
57
|
-
| r | р |
|
58
|
-
| R | Р |
|
59
|
-
| s | с |
|
60
|
-
| S | С |
|
61
|
-
| t | т |
|
62
|
-
| T | Т |
|
63
|
-
| kj | ќ |
|
64
|
-
| KJ | Ќ |
|
65
|
-
| Kj | Ќ |
|
66
|
-
| u | у |
|
67
|
-
| U | У |
|
68
|
-
| f | ф |
|
69
|
-
| F | Ф |
|
70
|
-
| h | х |
|
71
|
-
| H | Х |
|
72
|
-
| c | ц |
|
73
|
-
| C | Ц |
|
74
|
-
| ch | ч |
|
75
|
-
| CH | Ч |
|
76
|
-
| Ch | Ч |
|
77
|
-
| dzh | џ |
|
78
|
-
| DZH | Џ |
|
79
|
-
| Dzh | Џ |
|
80
|
-
| sh | ш |
|
81
|
-
| SH | Ш |
|
82
|
-
| Sh | Ш |
|
83
|
-
|
84
|
-
Scenario Outline: User writes sentences in latic characters
|
85
|
-
When user writes <latin> text
|
86
|
-
Then that text will be converted into <cyrilic>
|
87
|
-
|
88
|
-
Examples:
|
89
|
-
| latin | cyrilic |
|
90
|
-
| abeceda | абецеда |
|
91
|
-
| Cela rechenica | Цела реченица |
|
92
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
When /^user writes (.*) character$/ do |latin|
|
2
|
-
@text = latin
|
3
|
-
end
|
4
|
-
|
5
|
-
Then /^that character will be converted into (.*)?$/ do |cyrilic|
|
6
|
-
@text.to_cyr.should == cyrilic
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^user writes (.*) text$/ do |latin|
|
10
|
-
@text = latin
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^that text will be converted into (.*)?$/ do |cyrilic|
|
14
|
-
@text.to_cyr.should == cyrilic
|
15
|
-
end
|
data/features/support/env.rb
DELETED
data/spec/cyrillizer_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "Convertor" do
|
4
|
-
|
5
|
-
it "should change original string when using to_cyr!" do
|
6
|
-
string = 'orginalen'
|
7
|
-
string.to_cyr!.should == 'оргинален'
|
8
|
-
string.should == 'оргинален'
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not change original string when using to_cyr" do
|
12
|
-
string = 'orginalen'
|
13
|
-
string.to_cyr.should == 'оргинален'
|
14
|
-
string.should == 'orginalen'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should change original string when using to_lat!" do
|
18
|
-
string = 'оргинален'
|
19
|
-
string.to_lat!.should == 'orginalen'
|
20
|
-
string.should == 'orginalen'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should not change original string when using to_lat" do
|
24
|
-
string = 'оргинален'
|
25
|
-
string.to_lat.should == 'orginalen'
|
26
|
-
string.should == 'оргинален'
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
data/spec/spec.opts
DELETED