cyrillizer 0.0.2

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/History.txt ADDED
@@ -0,0 +1,10 @@
1
+ === 0.0.2 2009-11-08
2
+
3
+ * 1 major enhancement:
4
+ * Fixed convertions for upper case latters
5
+
6
+ === 0.0.1 2009-10-12
7
+
8
+ * 1 major enhancement:
9
+ * Initial release
10
+
data/Manifest.txt ADDED
@@ -0,0 +1,17 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ features/convert_latin_to_cyrillic.feature
7
+ features/development.feature
8
+ features/step_definitions/common_steps.rb
9
+ features/step_definitions/convert_latin_to_cyrillic_steps.rb
10
+ features/support/common.rb
11
+ features/support/env.rb
12
+ features/support/matchers.rb
13
+ lib/cyrillizer.rb
14
+ lib/cyrillizer/converter.rb
15
+ spec/cyrillizer_spec.rb
16
+ spec/spec.opts
17
+ spec/spec_helper.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,8 @@
1
+
2
+ Usage:
3
+
4
+ require 'rubygems'
5
+ require 'cyrillizer'
6
+ puts 'Konvertiraj go ova na kirilica'.to_cyr
7
+
8
+ For more information on cyrillizer, see http://github.com/dalibor/cyrillizer
data/README.rdoc ADDED
@@ -0,0 +1,52 @@
1
+ = cyrillizer
2
+
3
+ * http://github.com/dalibor/cyrillizer
4
+
5
+ == DESCRIPTION:
6
+
7
+ Character conversion from latin alphabet to Macedonian cyrillic alphabet
8
+
9
+ == SYNOPSIS:
10
+
11
+ - Ruby 1.8.6, 1.8.7
12
+
13
+ $KCODE = 'UTF8'
14
+ require 'rubygems'
15
+ require 'cyrillizer'
16
+ puts 'Konvertiraj go ova na kirilica'.to_cyr
17
+
18
+ - Ruby 1.9.1, ...
19
+
20
+ require 'cyrillizer'
21
+ puts 'Konvertiraj go ova na kirilica'.to_cyr
22
+
23
+ == INSTALL:
24
+
25
+ gem install gemcutter
26
+ gem tumble
27
+ gem install cyrillizer
28
+
29
+ == LICENSE:
30
+
31
+ (The MIT License)
32
+
33
+ Copyright (c) 2009 Dalibor Nasevic
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, and/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/cyrillizer'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'cyrillizer' do
14
+ self.developer 'Dalibor Nasevic', 'dalibor.nasevic@gmail.com'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
@@ -0,0 +1,92 @@
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 latic characters to cyrilic
5
+
6
+ Scenario Outline: User enters latic characters
7
+ When user writes <latin> character
8
+ Then that character will be converted into <cyrilic>
9
+
10
+ Examples:
11
+ | latin | cyrilic |
12
+ | a | а |
13
+ | A | А |
14
+ | b | б |
15
+ | B | Б |
16
+ | v | в |
17
+ | V | В |
18
+ | g | г |
19
+ | G | Г |
20
+ | d | д |
21
+ | D | Д |
22
+ | gj | ѓ |
23
+ | GJ | Ѓ |
24
+ | Gj | Ѓ |
25
+ | e | е |
26
+ | E | Е |
27
+ | zh | ж |
28
+ | ZH | Ж |
29
+ | Zh | Ж |
30
+ | z | з |
31
+ | Z | З |
32
+ | dz | ѕ |
33
+ | DZ | Ѕ |
34
+ | Dz | Ѕ |
35
+ | i | и |
36
+ | I | И |
37
+ | j | ј |
38
+ | J | Ј |
39
+ | k | к |
40
+ | K | К |
41
+ | l | л |
42
+ | L | Л |
43
+ | lj | љ |
44
+ | LJ | Љ |
45
+ | Lj | Љ |
46
+ | m | м |
47
+ | M | М |
48
+ | n | н |
49
+ | N | Н |
50
+ | nj | њ |
51
+ | NJ | Њ |
52
+ | Nj | Њ |
53
+ | o | о |
54
+ | O | О |
55
+ | p | п |
56
+ | P | П |
57
+ | r | р |
58
+ | R | Р |
59
+ | s | с |
60
+ | S | С |
61
+ | t | т |
62
+ | T | Т |
63
+ | kj | ќ |
64
+ | KJ | Ќ |
65
+ | Kj | Ќ |
66
+ | u | у |
67
+ | U | У |
68
+ | f | ф |
69
+ | F | Ф |
70
+ | h | х |
71
+ | H | Х |
72
+ | c | ц |
73
+ | C | Ц |
74
+ | ch | ч |
75
+ | CH | Ч |
76
+ | Ch | Ч |
77
+ | dzh | џ |
78
+ | DZH | Џ |
79
+ | Dzh | Џ |
80
+ | sh | ш |
81
+ | SH | Ш |
82
+ | Sh | Ш |
83
+
84
+ Scenario Outline: User writes sentences in latic characters
85
+ When user writes <latin> text
86
+ Then that text will be converted into <cyrilic>
87
+
88
+ Examples:
89
+ | latin | cyrilic |
90
+ | abeceda | абецеда |
91
+ | Cela rechenica | Цела реченица |
92
+
@@ -0,0 +1,13 @@
1
+ Feature: Development processes of newgem itself (rake tasks)
2
+
3
+ As a Newgem maintainer or contributor
4
+ I want rake tasks to maintain and release the gem
5
+ So that I can spend time on the tests and code, and not excessive time on maintenance processes
6
+
7
+ Scenario: Generate RubyGem
8
+ Given this project is active project folder
9
+ And "pkg" folder is deleted
10
+ When I invoke task "rake gem"
11
+ Then folder "pkg" is created
12
+ And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this
13
+ And gem spec key "rdoc_options" contains /--mainREADME.rdoc/
@@ -0,0 +1,163 @@
1
+ Given /^this project is active project folder/ do
2
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
3
+ end
4
+
5
+ Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
6
+ ENV[env_var] = value
7
+ end
8
+
9
+ Given /"(.*)" folder is deleted/ do |folder|
10
+ in_project_folder { FileUtils.rm_rf folder }
11
+ end
12
+
13
+ When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
14
+ @stdout = StringIO.new
15
+ in_project_folder do
16
+ if Object.const_defined?("APP_ROOT")
17
+ APP_ROOT.replace(FileUtils.pwd)
18
+ else
19
+ APP_ROOT = FileUtils.pwd
20
+ end
21
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
22
+ end
23
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
24
+ @stdout.rewind
25
+ f << @stdout.read
26
+ end
27
+ end
28
+
29
+ When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
30
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
31
+ in_project_folder do
32
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
33
+ end
34
+ end
35
+
36
+ When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
37
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
38
+ in_project_folder do
39
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
40
+ end
41
+ end
42
+
43
+ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
44
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
45
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
46
+ in_project_folder do
47
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
48
+ end
49
+ end
50
+
51
+ When /^I invoke task "rake (.*)"/ do |task|
52
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
53
+ in_project_folder do
54
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
55
+ end
56
+ end
57
+
58
+ Then /^folder "(.*)" (is|is not) created/ do |folder, is|
59
+ in_project_folder do
60
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
61
+ end
62
+ end
63
+
64
+ Then /^file "(.*)" (is|is not) created/ do |file, is|
65
+ in_project_folder do
66
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
67
+ end
68
+ end
69
+
70
+ Then /^file with name matching "(.*)" is created/ do |pattern|
71
+ in_project_folder do
72
+ Dir[pattern].should_not be_empty
73
+ end
74
+ end
75
+
76
+ Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
77
+ in_project_folder do
78
+ actual_output = File.read(file)
79
+ (does == 'does') ?
80
+ actual_output.should(match(/#{regex}/)) :
81
+ actual_output.should_not(match(/#{regex}/))
82
+ end
83
+ end
84
+
85
+ Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
86
+ File.exists?(gem_file).should be_true
87
+ File.exists?(project_file).should be_true
88
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
89
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
90
+ project_file_contents.should == gem_file_contents
91
+ end
92
+
93
+ Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
94
+ actual_output = File.read(@stdout)
95
+ does_invoke == "does" ?
96
+ actual_output.should(match(/dependency\s+#{generator}/)) :
97
+ actual_output.should_not(match(/dependency\s+#{generator}/))
98
+ end
99
+
100
+ Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
101
+ actual_output = File.read(@stdout)
102
+ actual_output.should match(/#{opt1}/)
103
+ actual_output.should match(/#{opt2}/)
104
+ end
105
+
106
+ Then /^I should see$/ do |text|
107
+ actual_output = File.read(@stdout)
108
+ actual_output.should contain(text)
109
+ end
110
+
111
+ Then /^I should not see$/ do |text|
112
+ actual_output = File.read(@stdout)
113
+ actual_output.should_not contain(text)
114
+ end
115
+
116
+ Then /^I should see exactly$/ do |text|
117
+ actual_output = File.read(@stdout)
118
+ actual_output.should == text
119
+ end
120
+
121
+ Then /^I should see all (\d+) tests pass/ do |expected_test_count|
122
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
123
+ actual_output = File.read(@stdout)
124
+ actual_output.should match(expected)
125
+ end
126
+
127
+ Then /^I should see all (\d+) examples pass/ do |expected_test_count|
128
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
129
+ actual_output = File.read(@stdout)
130
+ actual_output.should match(expected)
131
+ end
132
+
133
+ Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
134
+ in_project_folder do
135
+ yaml = eval yaml
136
+ YAML.load(File.read(file)).should == yaml
137
+ end
138
+ end
139
+
140
+ Then /^Rakefile can display tasks successfully/ do
141
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
142
+ in_project_folder do
143
+ system "rake -T > #{@stdout} 2> #{@stdout}"
144
+ end
145
+ actual_output = File.read(@stdout)
146
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
147
+ end
148
+
149
+ Then /^task "rake (.*)" is executed successfully/ do |task|
150
+ @stdout.should_not be_nil
151
+ actual_output = File.read(@stdout)
152
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
153
+ actual_output.should_not match(/Error/i)
154
+ end
155
+
156
+ Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
157
+ in_project_folder do
158
+ gem_file = Dir["pkg/*.gem"].first
159
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
160
+ spec_value = gem_spec.send(key.to_sym)
161
+ spec_value.to_s.should match(/#{regex}/)
162
+ end
163
+ end
@@ -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 |cyrilic|
6
+ @text.to_cyr.should == cyrilic
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 |cyrilic|
14
+ @text.to_cyr.should == cyrilic
15
+ end
@@ -0,0 +1,29 @@
1
+ module CommonHelpers
2
+ def in_tmp_folder(&block)
3
+ FileUtils.chdir(@tmp_root, &block)
4
+ end
5
+
6
+ def in_project_folder(&block)
7
+ project_folder = @active_project_folder || @tmp_root
8
+ FileUtils.chdir(project_folder, &block)
9
+ end
10
+
11
+ def in_home_folder(&block)
12
+ FileUtils.chdir(@home_path, &block)
13
+ end
14
+
15
+ def force_local_lib_override(project_name = @project_name)
16
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
17
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
18
+ f << "$:.unshift('#{@lib_path}')\n"
19
+ f << rakefile
20
+ end
21
+ end
22
+
23
+ def setup_active_project_folder project_name
24
+ @active_project_folder = File.join(@tmp_root, project_name)
25
+ @project_name = project_name
26
+ end
27
+ end
28
+
29
+ World(CommonHelpers)
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + "/../../lib/cyrillizer"
2
+
3
+ gem 'cucumber'
4
+ require 'cucumber'
5
+ gem 'rspec'
6
+ require 'spec'
7
+
8
+ Before do
9
+ @tmp_root = File.dirname(__FILE__) + "/../../tmp"
10
+ @home_path = File.expand_path(File.join(@tmp_root, "home"))
11
+ FileUtils.rm_rf @tmp_root
12
+ FileUtils.mkdir_p @home_path
13
+ ENV['HOME'] = @home_path
14
+ end
@@ -0,0 +1,11 @@
1
+ module Matchers
2
+ def contain(expected)
3
+ simple_matcher("contain #{expected.inspect}") do |given, matcher|
4
+ matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
5
+ matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
6
+ given.index expected
7
+ end
8
+ end
9
+ end
10
+
11
+ World(Matchers)
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ module Cyrillizer
3
+ module Converter
4
+
5
+ Latin = %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 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(Џ Џ џ Ѓ Ѓ ѓ Ж Ж ж Ѕ Ѕ ѕ Љ Љ љ Њ Њ њ Ќ Ќ ќ Ч Ч ч Ш Ш ш А а Б б В в Г г Д д Е е З з И и Ј ј К к Л л М м Н н О о П п Р р С с Т т У у Ф ф Х х Ц ц)
7
+
8
+ def to_cyr
9
+ code(self.dup, Latin, Cyrillic)
10
+ end
11
+
12
+ def to_cyr!
13
+ code(self, Latin, Cyrillic)
14
+ end
15
+
16
+ private
17
+ def code(text, from, to)
18
+ from.each_with_index do |latin, i|
19
+ text.gsub!(latin, to[i])
20
+ end
21
+ return text
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ # Add to_cyr method to all Strings
28
+ class String
29
+ include Cyrillizer::Converter
30
+ end
data/lib/cyrillizer.rb ADDED
@@ -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.0.2'
8
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Convertor" do
4
+
5
+ it "changes original string" do
6
+ string = 'orginalen'
7
+ string.to_cyr!.should == 'оргинален'
8
+ string.should == 'оргинален'
9
+ end
10
+
11
+ it "does not changes original string" do
12
+ string = 'orginalen'
13
+ string.to_cyr.should == 'оргинален'
14
+ string.should == 'orginalen'
15
+ end
16
+
17
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'cyrillizer'
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cyrillizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Dalibor Nasevic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-08 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ description: Character conversion from latin alphabet to Macedonian cyrillic alphabet
26
+ email:
27
+ - dalibor.nasevic@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - PostInstall.txt
36
+ files:
37
+ - History.txt
38
+ - Manifest.txt
39
+ - PostInstall.txt
40
+ - README.rdoc
41
+ - Rakefile
42
+ - features/convert_latin_to_cyrillic.feature
43
+ - features/development.feature
44
+ - features/step_definitions/common_steps.rb
45
+ - features/step_definitions/convert_latin_to_cyrillic_steps.rb
46
+ - features/support/common.rb
47
+ - features/support/env.rb
48
+ - features/support/matchers.rb
49
+ - lib/cyrillizer.rb
50
+ - lib/cyrillizer/converter.rb
51
+ - spec/cyrillizer_spec.rb
52
+ - spec/spec.opts
53
+ - spec/spec_helper.rb
54
+ has_rdoc: true
55
+ homepage: http://github.com/dalibor/cyrillizer
56
+ licenses: []
57
+
58
+ post_install_message: PostInstall.txt
59
+ rdoc_options:
60
+ - --main
61
+ - README.rdoc
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ requirements: []
77
+
78
+ rubyforge_project: cyrillizer
79
+ rubygems_version: 1.3.5
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Character conversion from latin alphabet to Macedonian cyrillic alphabet
83
+ test_files: []
84
+