viljushka 0.1.1
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.
- data/LICENSE +23 -0
- data/README.md +26 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/features/convert_latin_to_cyrillic.feature +97 -0
- data/features/step_definitions/convert_latin_to_cyrillic_steps.rb +15 -0
- data/features/support/env.rb +4 -0
- data/lib/viljushka/boc.rb +45 -0
- data/lib/viljushka.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/viljushka_spec.rb +72 -0
- metadata +64 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009 Dalibor Nasevic
|
|
4
|
+
Copyright (c) 2012 Aleksandar Simić
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
'Software'), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
### Description
|
|
2
|
+
|
|
3
|
+
Character conversion from Latin alphabet to Serbian Cyrillic script
|
|
4
|
+
and vice versa
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
$ gem install viljushka
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
require 'viljushka'
|
|
17
|
+
puts 'ćirilica'.to_cyr
|
|
18
|
+
puts 'ćirilica'.po_vuku
|
|
19
|
+
puts 'латиница'.to_lat
|
|
20
|
+
puts 'латиница'.po_gaju
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Note
|
|
24
|
+
|
|
25
|
+
The idea for this gem comes from Dalibor Nasevic, who originally
|
|
26
|
+
created it for Macedonian Cyrillic
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rspec/core/rake_task'
|
|
2
|
+
require 'cucumber/rake/task'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
desc 'Default: run specs.'
|
|
6
|
+
task :default => :spec
|
|
7
|
+
|
|
8
|
+
desc "Run specs"
|
|
9
|
+
RSpec::Core::RakeTask.new
|
|
10
|
+
|
|
11
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
|
12
|
+
t.cucumber_opts = "features --format pretty"
|
|
13
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,97 @@
|
|
|
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 Latin characters to Cyrillic
|
|
5
|
+
|
|
6
|
+
Scenario Outline: User enters Latin characters
|
|
7
|
+
When user writes <Latin> character
|
|
8
|
+
Then that character will be converted into <Cyrillic>
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
| Latin | Cyrillic |
|
|
12
|
+
| a | а |
|
|
13
|
+
| A | А |
|
|
14
|
+
| b | б |
|
|
15
|
+
| B | Б |
|
|
16
|
+
| v | в |
|
|
17
|
+
| V | В |
|
|
18
|
+
| g | г |
|
|
19
|
+
| G | Г |
|
|
20
|
+
| d | д |
|
|
21
|
+
| D | Д |
|
|
22
|
+
| ð | ђ |
|
|
23
|
+
| Ð | Ђ |
|
|
24
|
+
| dj | ђ |
|
|
25
|
+
| Dj | Ђ |
|
|
26
|
+
| DJ | Ђ |
|
|
27
|
+
| e | е |
|
|
28
|
+
| E | Е |
|
|
29
|
+
| ž | ж |
|
|
30
|
+
| Ž | Ж |
|
|
31
|
+
| z | з |
|
|
32
|
+
| Z | З |
|
|
33
|
+
| i | и |
|
|
34
|
+
| I | И |
|
|
35
|
+
| j | ј |
|
|
36
|
+
| J | Ј |
|
|
37
|
+
| k | к |
|
|
38
|
+
| K | К |
|
|
39
|
+
| l | л |
|
|
40
|
+
| L | Л |
|
|
41
|
+
| lj | љ |
|
|
42
|
+
| LJ | Љ |
|
|
43
|
+
| Lj | Љ |
|
|
44
|
+
| m | м |
|
|
45
|
+
| M | М |
|
|
46
|
+
| n | н |
|
|
47
|
+
| N | Н |
|
|
48
|
+
| nj | њ |
|
|
49
|
+
| NJ | Њ |
|
|
50
|
+
| Nj | Њ |
|
|
51
|
+
| o | о |
|
|
52
|
+
| O | О |
|
|
53
|
+
| p | п |
|
|
54
|
+
| P | П |
|
|
55
|
+
| r | р |
|
|
56
|
+
| R | Р |
|
|
57
|
+
| s | с |
|
|
58
|
+
| S | С |
|
|
59
|
+
| t | т |
|
|
60
|
+
| T | Т |
|
|
61
|
+
| Ć | Ћ |
|
|
62
|
+
| ć | ћ |
|
|
63
|
+
| u | у |
|
|
64
|
+
| U | У |
|
|
65
|
+
| f | ф |
|
|
66
|
+
| F | Ф |
|
|
67
|
+
| h | х |
|
|
68
|
+
| H | Х |
|
|
69
|
+
| c | ц |
|
|
70
|
+
| C | Ц |
|
|
71
|
+
| č | ч |
|
|
72
|
+
| Č | Ч |
|
|
73
|
+
| ch | ч |
|
|
74
|
+
| CH | Ч |
|
|
75
|
+
| Ch | Ч |
|
|
76
|
+
| dz | џ |
|
|
77
|
+
| DZ | Џ |
|
|
78
|
+
| Dz | Џ |
|
|
79
|
+
| dž | џ |
|
|
80
|
+
| DŽ | Џ |
|
|
81
|
+
| Dž | Џ |
|
|
82
|
+
| š | ш |
|
|
83
|
+
| Š | Ш |
|
|
84
|
+
| sh | ш |
|
|
85
|
+
| SH | Ш |
|
|
86
|
+
| Sh | Ш |
|
|
87
|
+
|
|
88
|
+
Scenario Outline: User writes sentences in Latin characters
|
|
89
|
+
When user writes <Latin> text
|
|
90
|
+
Then that text will be converted into <Cyrillic>
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
| Latin | Cyrillic |
|
|
94
|
+
| abeceda | абецеда |
|
|
95
|
+
| Cela rechenica | Цела реченица |
|
|
96
|
+
| Cela rečenica | Цела реченица |
|
|
97
|
+
| Džečćž | Џечћж |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
When /^user writes (.*) character$/ do |latin|
|
|
2
|
+
@text = latin
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then /^that character will be converted into (.*)?$/ do |cyrillic|
|
|
6
|
+
@text.to_cyr.should == cyrillic
|
|
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 |cyrillic|
|
|
14
|
+
@text.to_cyr.should == cyrillic
|
|
15
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
module Viljushka
|
|
3
|
+
module Boc
|
|
4
|
+
|
|
5
|
+
# Including officially 'non valid' (read: used on the internet, by
|
|
6
|
+
# people who can't be bothered to set up their keyboard layouts)
|
|
7
|
+
# Serbian Latin characters as well as the official letters
|
|
8
|
+
Latin = %w(DJ Dj dj DZ Dz dz DŽ Dž dž ZH Zh zh LJ Lj lj NJ Nj nj 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 Č č Š š)
|
|
9
|
+
Cyrillic = %w(Ђ Ђ ђ Џ Џ џ Џ Џ џ Ж Ж ж Љ Љ љ Њ Њ њ Ч Ч ч Ш Ш ш А а Б б В в Г г Д д Ђ ђ Е е Ж ж З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т Ћ ћ У у Ф ф Х х Ц ц Ч ч Ш ш)
|
|
10
|
+
|
|
11
|
+
def to_cyr
|
|
12
|
+
convert(self.dup, Latin, Cyrillic)
|
|
13
|
+
end
|
|
14
|
+
alias_method :po_vuku, :to_cyr
|
|
15
|
+
|
|
16
|
+
def to_cyr!
|
|
17
|
+
convert(self, Latin, Cyrillic)
|
|
18
|
+
end
|
|
19
|
+
alias_method :po_vuku!, :to_cyr!
|
|
20
|
+
|
|
21
|
+
def to_lat
|
|
22
|
+
convert(self.dup, Cyrillic, Latin)
|
|
23
|
+
end
|
|
24
|
+
alias_method :po_gaju, :to_lat
|
|
25
|
+
|
|
26
|
+
def to_lat!
|
|
27
|
+
convert(self, Cyrillic, Latin)
|
|
28
|
+
end
|
|
29
|
+
alias_method :po_gaju!, :to_lat!
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
def convert(text, from, to)
|
|
33
|
+
from.each_with_index do |char, i|
|
|
34
|
+
text.gsub!(char, to[i])
|
|
35
|
+
end
|
|
36
|
+
text
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Add to_cyr method to all Strings
|
|
43
|
+
class String
|
|
44
|
+
include Viljushka::Boc
|
|
45
|
+
end
|
data/lib/viljushka.rb
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe "Viljushka::Boc" do
|
|
6
|
+
|
|
7
|
+
it "should change original string when using to_cyr!" do
|
|
8
|
+
string = 'Milisav'
|
|
9
|
+
string.to_cyr!.should == 'Милисав'
|
|
10
|
+
string.should == 'Милисав'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
it "should not change original string when using to_cyr" do
|
|
15
|
+
string = 'Darinka'
|
|
16
|
+
string.to_cyr.should == 'Даринка'
|
|
17
|
+
string.should == 'Darinka'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "Вук Караџић" do
|
|
21
|
+
context "when using 'po_vuku!'" do
|
|
22
|
+
it "should change original string" do
|
|
23
|
+
string = 'Debelo jer'
|
|
24
|
+
string.to_cyr!.should == 'Дебело јер'
|
|
25
|
+
string.should == 'Дебело јер'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "when using 'po_vuku'" do
|
|
30
|
+
it "should not change original string" do
|
|
31
|
+
string = 'Debelo jer'
|
|
32
|
+
string.to_cyr.should == 'Дебело јер'
|
|
33
|
+
string.should == 'Debelo jer'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should change original string when using to_lat!" do
|
|
39
|
+
string = 'Руменка'
|
|
40
|
+
string.to_lat!.should == 'Rumenka'
|
|
41
|
+
string.should == 'Rumenka'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should not change original string when using to_lat" do
|
|
45
|
+
string = 'Изворка'
|
|
46
|
+
string.to_lat.should == 'Izvorka'
|
|
47
|
+
string.should == 'Изворка'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context "Ljudevit Gaj" do
|
|
51
|
+
context "when using 'po_gaju!'" do
|
|
52
|
+
it "should change original string" do
|
|
53
|
+
string = 'дивно'
|
|
54
|
+
string.po_gaju!.should == 'divno'
|
|
55
|
+
string.should == 'divno'
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "when using 'po_gaju'" do
|
|
60
|
+
it "should not change original string" do
|
|
61
|
+
string = 'дивно'
|
|
62
|
+
string.po_gaju.should == 'divno'
|
|
63
|
+
string.should == 'дивно'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should convert Serbian characters" do
|
|
69
|
+
"chicha".to_cyr.should == 'чича'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: viljushka
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Aleksandar Simić
|
|
9
|
+
- Dalibor Nasevic
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2012-01-22 00:00:00.000000000Z
|
|
14
|
+
dependencies: []
|
|
15
|
+
description: Character conversion from Latin alphabet to Serbian Cyrillic script and
|
|
16
|
+
vice versa
|
|
17
|
+
email: asimic@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- README.md
|
|
23
|
+
- Rakefile
|
|
24
|
+
- LICENSE
|
|
25
|
+
- VERSION
|
|
26
|
+
- lib/viljushka.rb
|
|
27
|
+
- lib/viljushka/boc.rb
|
|
28
|
+
- spec/spec_helper.rb
|
|
29
|
+
- spec/viljushka_spec.rb
|
|
30
|
+
- features/convert_latin_to_cyrillic.feature
|
|
31
|
+
- features/step_definitions/convert_latin_to_cyrillic_steps.rb
|
|
32
|
+
- features/support/env.rb
|
|
33
|
+
homepage: http://github.com/dalibor/cyrillizer
|
|
34
|
+
licenses: []
|
|
35
|
+
post_install_message:
|
|
36
|
+
rdoc_options:
|
|
37
|
+
- --charset=UTF-8
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
none: false
|
|
48
|
+
requirements:
|
|
49
|
+
- - ! '>='
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
requirements: []
|
|
53
|
+
rubyforge_project:
|
|
54
|
+
rubygems_version: 1.8.10
|
|
55
|
+
signing_key:
|
|
56
|
+
specification_version: 3
|
|
57
|
+
summary: Character conversion from Latin alphabet to Serbian Cyrillic script and vice
|
|
58
|
+
versa
|
|
59
|
+
test_files:
|
|
60
|
+
- spec/spec_helper.rb
|
|
61
|
+
- spec/viljushka_spec.rb
|
|
62
|
+
- features/convert_latin_to_cyrillic.feature
|
|
63
|
+
- features/step_definitions/convert_latin_to_cyrillic_steps.rb
|
|
64
|
+
- features/support/env.rb
|