viljushka 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -5
- data/lib/viljushka/boc.rb +16 -5
- data/lib/viljushka/version.rb +1 -1
- data/spec/viljushka_spec.rb +97 -32
- metadata +5 -8
- data/CHANGELOG +0 -13
- data/spec/downcase_spec.rb +0 -16
- data/spec/uppercase_spec.rb +0 -16
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
### Description
|
2
2
|
|
3
|
-
Character conversion from
|
4
|
-
and
|
5
|
-
|
6
|
-
It adds **downcase**, **upcase** & **capitalize** methods that
|
7
|
-
understand Serbian Cyrillic & Latin case
|
3
|
+
Character conversion to and from and String operations for Latin
|
4
|
+
alphabet and Serbian Cyrillic script.
|
8
5
|
|
6
|
+
Methods **#downcase**, **#downcase!**, **#upcase**, **#upcase!** &
|
7
|
+
**#capitalize** are Serbian Cyrillic & Latin case compatible as well
|
8
|
+
as maintaining their previous functionality on A-Z ASCII character
|
9
|
+
set.
|
9
10
|
|
10
11
|
### Install
|
11
12
|
|
data/lib/viljushka/boc.rb
CHANGED
@@ -9,15 +9,23 @@ module Viljushka
|
|
9
9
|
Low = %w(dž ž ć č š a b c d e f g h i j k l m n o p q r s t u v w x y z а б в г д ђ е ж з и ј к л м н љ њ о п р с т ћ у ф х ц ч џ ш)
|
10
10
|
|
11
11
|
def method_missing(arg)
|
12
|
-
if arg.to_s =~
|
12
|
+
if arg.to_s =~ /^(to_cyr|po_vuku)$/
|
13
13
|
convert(self.dup, Latin, Cyrillic)
|
14
|
-
elsif arg.to_s =~
|
14
|
+
elsif arg.to_s =~ /^(to_cyr|po_vuku)!$/
|
15
|
+
convert(self, Latin, Cyrillic)
|
16
|
+
elsif arg.to_s =~ /^(to_lat|po_gaju)$/
|
15
17
|
convert(self.dup, Cyrillic, Latin)
|
16
|
-
elsif arg.to_s =~
|
18
|
+
elsif arg.to_s =~ /^(to_lat|po_gaju)!$/
|
19
|
+
convert(self, Cyrillic, Latin)
|
20
|
+
elsif arg.to_s =~ /^downcase$/
|
17
21
|
convert(self.dup, Up, Low)
|
18
|
-
elsif arg.to_s =~
|
22
|
+
elsif arg.to_s =~ /^downcase!$/
|
23
|
+
convert(self, Up, Low)
|
24
|
+
elsif arg.to_s =~ /^upcase$/
|
19
25
|
convert(self.dup, Low, Up)
|
20
|
-
elsif arg.to_s =~
|
26
|
+
elsif arg.to_s =~ /^upcase!$/
|
27
|
+
convert(self, Low, Up)
|
28
|
+
elsif arg.to_s =~ /^capitalize$/
|
21
29
|
arr = self.scan(/./)
|
22
30
|
convert(arr.shift, Low, Up) + convert(arr.join, Up, Low)
|
23
31
|
else
|
@@ -33,13 +41,16 @@ module Viljushka
|
|
33
41
|
end
|
34
42
|
text
|
35
43
|
end
|
44
|
+
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
39
48
|
|
40
49
|
class String
|
41
50
|
remove_method(:downcase)
|
51
|
+
remove_method(:downcase!)
|
42
52
|
remove_method(:upcase)
|
53
|
+
remove_method(:upcase!)
|
43
54
|
remove_method(:capitalize)
|
44
55
|
include Viljushka::Boc
|
45
56
|
end
|
data/lib/viljushka/version.rb
CHANGED
data/spec/viljushka_spec.rb
CHANGED
@@ -1,89 +1,154 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe "Viljushka::Boc" do
|
6
6
|
|
7
7
|
context "#to_cyr!" do
|
8
|
-
|
9
|
-
string =
|
10
|
-
string.to_cyr!.should ==
|
11
|
-
string.should ==
|
8
|
+
it "should change the original string" do
|
9
|
+
string = "Milisav"
|
10
|
+
string.to_cyr!.should == "Милисав"
|
11
|
+
string.should == "Милисав"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
|
16
16
|
context "#to_cyr" do
|
17
17
|
it "should not change the original string" do
|
18
|
-
string =
|
19
|
-
string.to_cyr.should ==
|
20
|
-
string.should ==
|
18
|
+
string = "Darinka"
|
19
|
+
string.to_cyr.should == "Даринка"
|
20
|
+
string.should == "Darinka"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context "Вук Караџић" do
|
25
25
|
context "when using #po_vuku!" do
|
26
|
-
|
27
|
-
string =
|
28
|
-
string.to_cyr!.should ==
|
29
|
-
string.should ==
|
26
|
+
it "should change the original string" do
|
27
|
+
string = "Debelo jer"
|
28
|
+
string.to_cyr!.should == "Дебело јер"
|
29
|
+
string.should == "Дебело јер"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "when using #po_vuku" do
|
34
34
|
it "should not change the original string" do
|
35
|
-
string =
|
36
|
-
string.po_vuku.should ==
|
37
|
-
string.should ==
|
35
|
+
string = "Debelo jer"
|
36
|
+
string.po_vuku.should == "Дебело јер"
|
37
|
+
string.should == "Debelo jer"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
context "#to_lat!" do
|
43
|
-
|
44
|
-
string =
|
45
|
-
string.to_lat!.should ==
|
46
|
-
string.should ==
|
43
|
+
it "should change the original string" do
|
44
|
+
string = "Руменка"
|
45
|
+
string.to_lat!.should == "Rumenka"
|
46
|
+
string.should == "Rumenka"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context "#to_lat" do
|
51
51
|
it "should not change the original string" do
|
52
|
-
string =
|
53
|
-
string.to_lat.should ==
|
54
|
-
string.should ==
|
52
|
+
string = "Изворка"
|
53
|
+
string.to_lat.should == "Izvorka"
|
54
|
+
string.should == "Изворка"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "Ljudevit Gaj" do
|
59
59
|
context "#po_gaju!" do
|
60
|
-
|
61
|
-
string =
|
62
|
-
string.po_gaju!.should ==
|
63
|
-
string.should ==
|
60
|
+
it "should change the original string" do
|
61
|
+
string = "дивно"
|
62
|
+
string.po_gaju!.should == "divno"
|
63
|
+
string.should == "divno"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context "#po_gaju" do
|
68
68
|
it "should not change the original string" do
|
69
|
-
string =
|
70
|
-
string.po_gaju.should ==
|
71
|
-
string.should ==
|
69
|
+
string = "дивно"
|
70
|
+
string.po_gaju.should == "divno"
|
71
|
+
string.should == "дивно"
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should convert Serbian characters" do
|
77
|
-
"čiča".to_cyr.should ==
|
77
|
+
"čiča".to_cyr.should == "чича"
|
78
78
|
end
|
79
79
|
|
80
|
+
context "#upcase" do
|
81
|
+
context "with alphabet" do
|
82
|
+
subject { "abcdefghijklmnopqrstuvwxyz".upcase }
|
83
|
+
it { should eql "ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
|
84
|
+
end
|
85
|
+
|
86
|
+
context "with Serbian Cyrillic" do
|
87
|
+
subject { "абвгдђежзијклљмнњопрстћуфхцчџш".upcase }
|
88
|
+
it { should eql "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ" }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#upcase!" do
|
93
|
+
context "with alphabet" do
|
94
|
+
it "should modify the string permanently" do
|
95
|
+
string = "abcdefghijklmnopqrstuvwxyz"
|
96
|
+
string.upcase!.should == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
97
|
+
string.should == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "with Serbian Cyrillic" do
|
102
|
+
it "should modify the string permanently" do
|
103
|
+
cyr = "абвгдђежзијклљмнњопрстћуфхцчџш"
|
104
|
+
cyr.upcase!.should == "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ"
|
105
|
+
cyr.should == "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#downcase" do
|
111
|
+
context "with alphabet" do
|
112
|
+
subject { "ABCDEFGHIJKLMNOPQRSTUVWXYZ".downcase }
|
113
|
+
it { should eql "abcdefghijklmnopqrstuvwxyz" }
|
114
|
+
end
|
115
|
+
|
116
|
+
context "with Serbian Cyrillic" do
|
117
|
+
subject { "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ".downcase }
|
118
|
+
it { should eql "абвгдђежзијклљмнњопрстћуфхцчџш" }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
describe "#downcase!" do
|
124
|
+
context "with alphabet" do
|
125
|
+
it "should modify the string permanently" do
|
126
|
+
string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
127
|
+
string.downcase!.should == "abcdefghijklmnopqrstuvwxyz"
|
128
|
+
string.should == "abcdefghijklmnopqrstuvwxyz"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with Serbian Cyrillic" do
|
133
|
+
it "should modify the string permanently" do
|
134
|
+
cyr = "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ"
|
135
|
+
cyr.downcase!.should == "абвгдђежзијклљмнњопрстћуфхцчџш"
|
136
|
+
cyr.should == "абвгдђежзијклљмнњопрстћуфхцчџш"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
80
142
|
context "#capitalize" do
|
143
|
+
let(:cyrillic) { "чича".capitalize }
|
144
|
+
let(:latin) { "čiča".capitalize }
|
145
|
+
|
81
146
|
it "should capitalize Cyrillic" do
|
82
|
-
|
147
|
+
cyrillic.should == "Чича"
|
83
148
|
end
|
84
149
|
|
85
150
|
it "should capitalize Latin" do
|
86
|
-
|
151
|
+
latin.should == "Čiča"
|
87
152
|
end
|
88
153
|
end
|
89
154
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viljushka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-19 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &17202624100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17202624100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cucumber
|
27
|
-
requirement: &
|
27
|
+
requirement: &17202668920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17202668920
|
36
36
|
description: Character conversion from Latin alphabet to Serbian Cyrillic script and
|
37
37
|
vice versa
|
38
38
|
email: asimic@gmail.com
|
@@ -43,7 +43,6 @@ files:
|
|
43
43
|
- .gitignore
|
44
44
|
- .rspec
|
45
45
|
- .rvmrc
|
46
|
-
- CHANGELOG
|
47
46
|
- LICENSE
|
48
47
|
- README.md
|
49
48
|
- Rakefile
|
@@ -57,9 +56,7 @@ files:
|
|
57
56
|
- lib/viljushka.rb
|
58
57
|
- lib/viljushka/boc.rb
|
59
58
|
- lib/viljushka/version.rb
|
60
|
-
- spec/downcase_spec.rb
|
61
59
|
- spec/spec_helper.rb
|
62
|
-
- spec/uppercase_spec.rb
|
63
60
|
- spec/viljushka_spec.rb
|
64
61
|
- viljushka.gemspec
|
65
62
|
homepage: http://github.com/dotemacs/viljushka
|
data/CHANGELOG
DELETED
data/spec/downcase_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "Viljushka::Downcase" do
|
5
|
-
|
6
|
-
context "with alphabet" do
|
7
|
-
subject { "ABCDEFGHIJKLMNOPQRSTUVWXYZ".downcase }
|
8
|
-
it { should eql "abcdefghijklmnopqrstuvwxyz" }
|
9
|
-
end
|
10
|
-
|
11
|
-
context "with Serbian Cyrillic" do
|
12
|
-
subject { "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ".downcase }
|
13
|
-
it { should eql "абвгдђежзијклљмнњопрстћуфхцчџш" }
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/spec/uppercase_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "Viljushka::Upcase" do
|
5
|
-
|
6
|
-
context "with alphabet" do
|
7
|
-
subject { "abcdefghijklmnopqrstuvwxyz".upcase }
|
8
|
-
it { should eql "ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
|
9
|
-
end
|
10
|
-
|
11
|
-
context "with Serbian Cyrillic" do
|
12
|
-
subject { "абвгдђежзијклљмнњопрстћуфхцчџш".upcase }
|
13
|
-
it { should eql "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ" }
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|