viljushka 0.1.5 → 0.4.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.
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  Character conversion from Latin alphabet to Serbian Cyrillic script
4
4
  and vice versa
5
5
 
6
+ It adds **downcase** & **downcase** methods that understand Serbian
7
+ Cyrillic case
8
+
6
9
 
7
10
  ### Install
8
11
 
@@ -14,13 +17,33 @@ $ gem install viljushka
14
17
 
15
18
  ```
16
19
  require 'viljushka'
17
- puts 'ćirilica'.to_cyr
18
- puts 'ćirilica'.po_vuku
19
- puts 'латиница'.to_lat
20
- puts 'латиница'.po_gaju
20
+ ```
21
+
22
+ For Cyrillic
23
+
24
+
25
+ ```
26
+ puts "ćirilica".to_cyr
27
+ puts "ćirilica".po_vuku
28
+ ``
29
+
30
+ and for Latin
31
+
32
+ ``
33
+ puts "латиница".to_lat
34
+ puts "латиница".po_gaju
35
+ ```
36
+
37
+ also **downcase** & **upcase**
38
+
39
+ ```
40
+ puts "ПАЗИ САД".downcase
41
+ => "пази сад"
42
+ puts "пази сад".upcase
43
+ => "ПАЗИ САД"
21
44
  ```
22
45
 
23
46
  ### Note
24
47
 
25
48
  The idea for this gem comes from Dalibor Nasevic, who originally
26
- created it for Macedonian Cyrillic
49
+ created it for Macedonian Cyrillic.
data/Rakefile CHANGED
@@ -8,6 +8,6 @@ task :default => :spec
8
8
  desc "Run specs"
9
9
  RSpec::Core::RakeTask.new
10
10
 
11
- Cucumber::Rake::Task.new(:features) do |t|
11
+ Cucumber::Rake::Task.new(:cukes) do |t|
12
12
  t.cucumber_opts = "features --format pretty"
13
13
  end
@@ -72,20 +72,11 @@ Feature: Convert Latin To Cyrilic
72
72
  | C | Ц |
73
73
  | č | ч |
74
74
  | Č | Ч |
75
- | ch | ч |
76
- | CH | Ч |
77
- | Ch | Ч |
78
- | dz | џ |
79
- | DZ | Џ |
80
- | Dz | Џ |
81
75
  | dž | џ |
82
76
  | DŽ | Џ |
83
77
  | Dž | Џ |
84
78
  | š | ш |
85
79
  | Š | Ш |
86
- | sh | ш |
87
- | SH | Ш |
88
- | Sh | Ш |
89
80
 
90
81
  Scenario Outline: User writes sentences in Latin characters
91
82
  When user writes <Latin> text
@@ -94,6 +85,5 @@ Feature: Convert Latin To Cyrilic
94
85
  Examples:
95
86
  | Latin | Cyrillic |
96
87
  | abeceda | абецеда |
97
- | Cela rechenica | Цела реченица |
98
88
  | Cela rečenica | Цела реченица |
99
89
  | Džečćž | Џечћж |
@@ -0,0 +1,39 @@
1
+ Feature: Convert from uppercase To lowercase
2
+ In order to convert text from uppercase to lowercase
3
+
4
+ Scenario Outline: User enters Latin characters
5
+ When I provide a <Uppercase> character
6
+ Then I should get it in <Lowercase>
7
+
8
+ Examples:
9
+ | Uppercase | Lowercase |
10
+ | А | а |
11
+ | Б | б |
12
+ | В | в |
13
+ | Г | г |
14
+ | Д | д |
15
+ | Ђ | ђ |
16
+ | Е | е |
17
+ | Ж | ж |
18
+ | З | з |
19
+ | И | и |
20
+ | Ј | ј |
21
+ | К | к |
22
+ | Л | л |
23
+ | Љ | љ |
24
+ | М | м |
25
+ | Н | н |
26
+ | Њ | њ |
27
+ | О | о |
28
+ | П | п |
29
+ | Р | р |
30
+ | С | с |
31
+ | Т | т |
32
+ | Ћ | ћ |
33
+ | У | у |
34
+ | Ф | ф |
35
+ | Х | х |
36
+ | Ц | ц |
37
+ | Ч | ч |
38
+ | Џ | џ |
39
+ | Ш | ш |
@@ -0,0 +1,7 @@
1
+ When /^I provide a (.*) character$/ do |char|
2
+ @char = char
3
+ end
4
+
5
+ Then /^I should get it in (.*)$/ do |lowercase|
6
+ @char.downcase.should == lowercase
7
+ end
@@ -0,0 +1,4 @@
1
+
2
+ Then /^I should get it converted in (.*)$/ do |uppercase|
3
+ @char.upcase.should == uppercase
4
+ end
@@ -1,4 +1,5 @@
1
- require File.dirname(__FILE__) + "/../../lib/viljushka"
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
2
 
3
3
  require 'cucumber'
4
4
  require 'rspec'
5
+ require 'viljushka'
@@ -0,0 +1,39 @@
1
+ Feature: Convert from uppercase To lowercase
2
+ In order to convert text from uppercase to lowercase
3
+
4
+ Scenario Outline: User enters Latin characters
5
+ When I provide a <Lowercase> character
6
+ Then I should get it converted in <Uppercase>
7
+
8
+ Examples:
9
+ | Lowercase | Uppercase |
10
+ | а | А |
11
+ | б | Б |
12
+ | в | В |
13
+ | г | Г |
14
+ | д | Д |
15
+ | ђ | Ђ |
16
+ | е | Е |
17
+ | ж | Ж |
18
+ | з | З |
19
+ | и | И |
20
+ | ј | Ј |
21
+ | к | К |
22
+ | л | Л |
23
+ | љ | Љ |
24
+ | м | М |
25
+ | н | Н |
26
+ | њ | Њ |
27
+ | о | О |
28
+ | п | П |
29
+ | р | Р |
30
+ | с | С |
31
+ | т | Т |
32
+ | ћ | Ћ |
33
+ | у | У |
34
+ | ф | Ф |
35
+ | х | Х |
36
+ | ц | Ц |
37
+ | ч | Ч |
38
+ | џ | Џ |
39
+ | ш | Ш |
data/lib/viljushka/boc.rb CHANGED
@@ -2,40 +2,29 @@
2
2
  module Viljushka
3
3
  module Boc
4
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(Ђ Ђ ђ Џ Џ џ Џ Џ џ Ж Ж ж Љ Љ љ Њ Њ њ Ч Ч ч Ш Ш ш А а Б б В в Г г Д д Ђ ђ Ђ ђ Е е Ж ж З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т Ћ ћ У у Ф ф Х х Ц ц Ч ч Ш ш)
5
+ Latin = %w(DJ Dj dj LJ Lj lj NJ Nj nj 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(Ђ Ђ ђ Џ Џ џ Љ Љ љ Њ Њ њ А а Б б В в Г г Д д Ђ ђ Ђ ђ Е е Ж ж З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т Ћ ћ У у Ф ф Х х Ц ц Ч ч Ш ш)
10
7
 
11
8
  def to_cyr
12
- convert(self.dup, Latin, Cyrillic)
9
+ Viljushka.convert(self.dup, Latin, Cyrillic)
13
10
  end
14
11
  alias_method :po_vuku, :to_cyr
15
12
 
16
13
  def to_cyr!
17
- convert(self, Latin, Cyrillic)
14
+ Viljushka.convert(self, Latin, Cyrillic)
18
15
  end
19
16
  alias_method :po_vuku!, :to_cyr!
20
17
 
21
18
  def to_lat
22
- convert(self.dup, Cyrillic, Latin)
19
+ Viljushka.convert(self.dup, Cyrillic, Latin)
23
20
  end
24
21
  alias_method :po_gaju, :to_lat
25
22
 
26
23
  def to_lat!
27
- convert(self, Cyrillic, Latin)
24
+ Viljushka.convert(self, Cyrillic, Latin)
28
25
  end
29
26
  alias_method :po_gaju!, :to_lat!
30
27
 
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
28
  end
40
29
  end
41
30
 
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ module Viljushka
3
+ module CaseConversion
4
+
5
+ Up = %w(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 А Б В Г Д Ђ Е Ж З И Ј К Л Љ М Н Њ О П Р С Т Ћ У Ф Х Ц Ч Џ Ш)
6
+ Low = %w(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 а б в г д ђ е ж з и ј к л љ м н њ о п р с т ћ у ф х ц ч џ ш)
7
+
8
+ def downcase_with_serbian_cyrillic
9
+ Viljushka.convert(self.dup, Up, Low)
10
+ end
11
+
12
+ alias_method :downcase, :downcase_with_serbian_cyrillic
13
+
14
+ def upcase_with_serbian_cyrillic
15
+ Viljushka.convert(self.dup, Low, Up)
16
+ end
17
+
18
+ alias_method :upcase, :upcase_with_serbian_cyrillic
19
+
20
+ end
21
+ end
22
+
23
+ class String
24
+ remove_method(:downcase)
25
+ remove_method(:upcase)
26
+ include Viljushka::CaseConversion
27
+ end
@@ -0,0 +1,3 @@
1
+ module Viljushka
2
+ VERSION = '0.4.0'
3
+ end
data/lib/viljushka.rb CHANGED
@@ -1,8 +1,14 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
-
4
1
  require 'viljushka/boc'
2
+ require 'viljushka/case_conversion'
5
3
 
6
4
  module Viljushka
7
- VERSION = '0.1.5'
5
+
6
+ private
7
+
8
+ def self.convert(text, from, to)
9
+ from.each_with_index do |char, i|
10
+ text.gsub!(char, to[i])
11
+ end
12
+ text
13
+ end
8
14
  end
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,16 @@
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
@@ -66,7 +66,7 @@ describe "Viljushka::Boc" do
66
66
  end
67
67
 
68
68
  it "should convert Serbian characters" do
69
- "chicha".to_cyr.should == 'чича'
69
+ "čiča".to_cyr.should == 'чича'
70
70
  end
71
71
 
72
72
  end
data/viljushka.gemspec CHANGED
@@ -1,8 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+
5
+ require 'viljushka/version'
6
+
3
7
  Gem::Specification.new do |s|
4
8
  s.name = "viljushka"
5
- s.version = "0.1.5"
9
+ s.version = Viljushka::VERSION
6
10
  s.homepage = "http://github.com/dotemacs/viljushka"
7
11
  s.authors = ["Aleksandar Simić"]
8
12
  s.date = "2012-01-22"
@@ -13,8 +17,7 @@ Gem::Specification.new do |s|
13
17
  s.files = `git ls-files`.split("\n")
14
18
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
15
19
 
16
- s.required_ruby_version = '>= 1.9.2'
17
- s.required_rubygems_version = '>= 1.8.10'
20
+ s.required_rubygems_version = '>= 1.3.6'
18
21
 
19
22
  {
20
23
  'rspec' => '>= 2.0.0',
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.1.5
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &17202708740 !ruby/object:Gem::Requirement
16
+ requirement: &17201438920 !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: *17202708740
24
+ version_requirements: *17201438920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cucumber
27
- requirement: &17202710940 !ruby/object:Gem::Requirement
27
+ requirement: &17201438480 !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: *17202710940
35
+ version_requirements: *17201438480
36
36
  description: Character conversion from Latin alphabet to Serbian Cyrillic script and
37
37
  vice versa
38
38
  email: asimic@gmail.com
@@ -48,11 +48,19 @@ files:
48
48
  - README.md
49
49
  - Rakefile
50
50
  - features/convert_latin_to_cyrillic.feature
51
+ - features/downcase.feature
51
52
  - features/step_definitions/convert_latin_to_cyrillic_steps.rb
53
+ - features/step_definitions/downcase_steps.rb
54
+ - features/step_definitions/upcase_steps.rb
52
55
  - features/support/env.rb
56
+ - features/upcase.feature
53
57
  - lib/viljushka.rb
54
58
  - lib/viljushka/boc.rb
59
+ - lib/viljushka/case_conversion.rb
60
+ - lib/viljushka/version.rb
61
+ - spec/downcase_spec.rb
55
62
  - spec/spec_helper.rb
63
+ - spec/uppercase_spec.rb
56
64
  - spec/viljushka_spec.rb
57
65
  - viljushka.gemspec
58
66
  homepage: http://github.com/dotemacs/viljushka
@@ -66,13 +74,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
74
  requirements:
67
75
  - - ! '>='
68
76
  - !ruby/object:Gem::Version
69
- version: 1.9.2
77
+ version: '0'
70
78
  required_rubygems_version: !ruby/object:Gem::Requirement
71
79
  none: false
72
80
  requirements:
73
81
  - - ! '>='
74
82
  - !ruby/object:Gem::Version
75
- version: 1.8.10
83
+ version: 1.3.6
76
84
  requirements: []
77
85
  rubyforge_project:
78
86
  rubygems_version: 1.8.10