forked from dalibor/cyrillizer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added downcase method that understands Serbian Cyrillic
-version bump -renamed the call to Cucumber NOTE: the downcase method might be slower now as it uses Ruby's Array to look up the characters for the conversion.
- Loading branch information
Showing
10 changed files
with
119 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Feature: Convert from uppercase To lowercase | ||
In order to convert text from uppercase to lowercase | ||
|
||
Scenario Outline: User enters Latin characters | ||
When I enter a <Uppercase> character | ||
Then I should get it in <Lowercase> | ||
|
||
Examples: | ||
| Uppercase | Lowercase | | ||
| А | а | | ||
| Б | б | | ||
| В | в | | ||
| Г | г | | ||
| Д | д | | ||
| Ђ | ђ | | ||
| Е | е | | ||
| Ж | ж | | ||
| З | з | | ||
| И | и | | ||
| Ј | ј | | ||
| К | к | | ||
| Л | л | | ||
| Љ | љ | | ||
| М | м | | ||
| Н | н | | ||
| Њ | њ | | ||
| О | о | | ||
| П | п | | ||
| Р | р | | ||
| С | с | | ||
| Т | т | | ||
| Ћ | ћ | | ||
| У | у | | ||
| Ф | ф | | ||
| Х | х | | ||
| Ц | ц | | ||
| Ч | ч | | ||
| Џ | џ | | ||
| Ш | ш | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
When /^I enter a (.*) character$/ do |char| | ||
@char = char | ||
end | ||
|
||
Then /^I should get it in (.*)$/ do |lowercase| | ||
@char.downcase.should == lowercase | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require File.dirname(__FILE__) + "/../../lib/viljushka" | ||
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) | ||
|
||
require 'cucumber' | ||
require 'rspec' | ||
require 'viljushka' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
require 'viljushka/boc' | ||
require 'viljushka/downcase' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# coding: utf-8 | ||
module Viljushka | ||
module Downcase | ||
|
||
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 А Б В Г Д Ђ Е Ж З И Ј К Л Љ М Н Њ О П Р С Т Ћ У Ф Х Ц Ч Џ Ш) | ||
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 а б в г д ђ е ж з и ј к л љ м н њ о п р с т ћ у ф х ц ч џ ш) | ||
|
||
def downcase_with_serbian_cyrillic | ||
convert(self.dup, Up, Low) | ||
end | ||
|
||
alias_method :downcase, :downcase_with_serbian_cyrillic | ||
|
||
private | ||
|
||
def convert(text, from, to) | ||
from.each_with_index do |char, i| | ||
text.gsub!(char, to[i]) | ||
end | ||
text | ||
end | ||
|
||
end | ||
end | ||
|
||
class String | ||
remove_method(:downcase) | ||
include Viljushka::Downcase | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Viljushka | ||
VERSION = '0.1.5' | ||
VERSION = '0.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
require 'spec_helper' | ||
|
||
describe "Viljushka::Downcase" do | ||
|
||
context "with alphabet" do | ||
subject { "ABCDEFGHIJKLMNOPQRSTUVWXYZ".downcase } | ||
it { should eql "abcdefghijklmnopqrstuvwxyz" } | ||
end | ||
|
||
context "with Serbian Cyrillic" do | ||
subject { "АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ".downcase } | ||
it { should eql "абвгдђежзијклљмнњопрстћуфхцчџш" } | ||
end | ||
|
||
end |