Cyrillizer 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.
@@ -0,0 +1,45 @@
1
+ = cyrillizer
2
+
3
+ * http://github.com/vasil/cyrillizer
4
+
5
+ == DESCRIPTION:
6
+
7
+ Character conversion from latin alphabet to Macedonian cyrillic alphabet
8
+
9
+ == SYNOPSIS:
10
+
11
+ require 'rubygems'
12
+ require 'cyrillizer'
13
+ puts 'Konvertiraj go ova na kirilica'.to_cyr
14
+
15
+ == INSTALL:
16
+
17
+ $ git clone git://github.com/vasil/cyrillizer.git
18
+ $ cd cyrillizer
19
+ $ rage gem
20
+ $ sudo gem install pkg/Cyrillizer-0.1.1.gem
21
+
22
+ == LICENSE:
23
+
24
+ (The MIT License)
25
+
26
+ Copyright (c) 2009 Dalibor Nasevic
27
+
28
+ Permission is hereby granted, free of charge, to any person obtaining
29
+ a copy of this software and associated documentation files (the
30
+ 'Software'), to deal in the Software without restriction, including
31
+ without limitation the rights to use, copy, modify, merge, publish,
32
+ distribute, sublicense, and/or sell copies of the Software, and to
33
+ permit persons to whom the Software is furnished to do so, subject to
34
+ the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be
37
+ included in all copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
40
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
42
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
43
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
44
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
45
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/testtask'
7
+ require 'spec/rake/spectask'
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'Cyrillizer'
11
+ s.version = '0.1.1'
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = ['README.rdoc']
14
+ s.summary = 'Converts (macedonian) text from latin transcript to cyrillic'
15
+ s.homepage = 'http://github.com/vasil/cyrillizer'
16
+ s.description = 'Character conversion from latin alphabet to Macedonian cyrillic alphabet'
17
+ s.author = 'Vasil Taneski'
18
+ s.email = 'vasil.taneski@gmail.com'
19
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
20
+ s.require_path = "lib"
21
+ s.bindir = "bin"
22
+ end
23
+
24
+ Rake::GemPackageTask.new(spec) do |p|
25
+ p.gem_spec = spec
26
+ p.need_tar = true
27
+ p.need_zip = true
28
+ end
29
+
30
+ Rake::RDocTask.new do |rdoc|
31
+ files =['README.rdoc', 'lib/**/*.rb']
32
+ rdoc.rdoc_files.add(files)
33
+ rdoc.main = "README.rdoc"
34
+ rdoc.title = "Cyrillizer Docs"
35
+ rdoc.rdoc_dir = 'doc/rdoc'
36
+ rdoc.options << '--line-numbers'
37
+ end
38
+
39
+ Spec::Rake::SpecTask.new do |t|
40
+ t.spec_files = FileList['spec/**/*.rb']
41
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'cyrillizer/converter'
5
+
6
+ module Cyrillizer
7
+ VERSION = '0.1.1'
8
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ module Cyrillizer
3
+ module Converter
4
+
5
+ Latin = "AaBbVvGgDdEeZzIiJjKkLlMmNnOoPpRrSsTtUuFfHhCc"
6
+ Cyrillic = "АаБбВвГгДдЕеЗзИиЈјКкЛлМмНнОоПпРрСсТтУуФфХхЦц"
7
+
8
+ Latin_a = %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)
9
+ Cyrillic_a = %w(Џ Џ џ Ѓ Ѓ ѓ Ж Ж ж Ѕ Ѕ ѕ Љ Љ љ Њ Њ њ Ќ Ќ ќ Ч Ч ч Ш Ш ш )
10
+
11
+ def to_cyr
12
+ self.tr_group(Latin_a, Cyrillic_a).tr(Latin, Cyrillic)
13
+ end
14
+
15
+ protected
16
+ def tr_group(from, to)
17
+ text = clone
18
+ from.each_with_index { |latin, i|
19
+ text.gsub!(latin, to[i])
20
+ }
21
+ return text
22
+ end
23
+ end
24
+ end
25
+
26
+ # Add to_cyr method to all Strings
27
+ class String
28
+ include Cyrillizer::Converter
29
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ require File.join(File.dirname(__FILE__), *%w(.. lib cyrillizer converter))
3
+
4
+ describe Cyrillizer::Converter do
5
+
6
+ latin = Cyrillizer::Converter::Latin
7
+ latin_a = Cyrillizer::Converter::Latin_a
8
+
9
+ cyrillic = Cyrillizer::Converter::Cyrillic
10
+ cyrillic_a = Cyrillizer::Converter::Cyrillic_a
11
+
12
+ it "should return empty string for given empty string" do
13
+ "".to_cyr.should == ""
14
+ end
15
+
16
+ it "should return the same string for given cyrillic patterns" do
17
+ cyrillic.to_cyr.should == cyrillic
18
+ cyrillic_a.join.to_cyr.should == cyrillic_a.join
19
+ end
20
+
21
+ it "should return the cyrillic patterns for given latin ones" do
22
+ latin.to_cyr.should == cyrillic
23
+ latin_a.join.to_cyr.should == cyrillic_a.join
24
+ end
25
+
26
+ it "should be ok for UPCASE SENTENCES" do
27
+ "DZHABE RABOTI, DZHABE NE SEDI".to_cyr.should == "ЏАБЕ РАБОТИ, ЏАБЕ НЕ СЕДИ"
28
+ end
29
+
30
+ it "should be ok for Capitalized sentences" do
31
+ "Dzhabe raboti, dzhabe ne sedi".to_cyr.should == "Џабе работи, џабе не седи"
32
+ end
33
+
34
+ end
35
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Cyrillizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Vasil Taneski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-25 01:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Character conversion from latin alphabet to Macedonian cyrillic alphabet
17
+ email: vasil.taneski@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ - Rakefile
27
+ - lib/cyrillizer.rb
28
+ - lib/cyrillizer/converter.rb
29
+ - spec/converter_spec.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/vasil/cyrillizer
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Converts (macedonian) text from latin transcript to cyrillic
58
+ test_files: []
59
+