ogma 0.0.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,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ogma.gemspec
4
+ gemspec
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = ["test/*.rb"]
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,60 @@
1
+ # encoding: UTF-8
2
+ require "ogma/version"
3
+
4
+ module Ogma
5
+ LOWER_SINGLE = {
6
+ "і"=>"i","ґ"=>"g","ё"=>"yo","№"=>"#","є"=>"e",
7
+ "ї"=>"yi","а"=>"a","б"=>"b",
8
+ "в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"zh",
9
+ "з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
10
+ "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
11
+ "с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
12
+ "ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"'",
13
+ "ы"=>"y","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"
14
+ }
15
+
16
+ LOWER_MULTI = {
17
+ "ье"=>"ie",
18
+ "ьё"=>"ie"
19
+ }
20
+
21
+ UPPER_SINGLE = {
22
+ "Ґ"=>"G","Ё"=>"YO","Є"=>"E","Ї"=>"YI","І"=>"I",
23
+ "А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
24
+ "Д"=>"D","Е"=>"E","Ж"=>"ZH","З"=>"Z","И"=>"I",
25
+ "Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
26
+ "О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
27
+ "У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
28
+ "Ш"=>"SH","Щ"=>"SCH","Ъ"=>"'","Ы"=>"Y","Ь"=>"",
29
+ "Э"=>"E","Ю"=>"YU","Я"=>"YA"
30
+ }
31
+
32
+ UPPER_MULTI = {
33
+ "ЬЕ"=>"IE",
34
+ "ЬЁ"=>"IE"
35
+ }
36
+
37
+ LOWER = (LOWER_SINGLE.merge(LOWER_MULTI)).freeze
38
+ UPPER = (UPPER_SINGLE.merge(UPPER_MULTI)).freeze
39
+ MULTI_KEYS = (LOWER_MULTI.merge(UPPER_MULTI)).keys.sort_by {|s| s.length}.reverse.freeze
40
+
41
+ def self.transliterate str
42
+ chars = str.scan(%r{#{MULTI_KEYS.join '|'}|\w|.})
43
+
44
+ result = ""
45
+
46
+ chars.each_with_index do |char, index|
47
+ if UPPER.has_key?(char) && LOWER.has_key?(chars[index+1])
48
+ result << UPPER[char].downcase.capitalize
49
+ elsif UPPER.has_key?(char)
50
+ result << UPPER[char]
51
+ elsif LOWER.has_key?(char)
52
+ result << LOWER[char]
53
+ else
54
+ result << char
55
+ end
56
+ end
57
+
58
+ result
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Ogma
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ogma/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ogma"
7
+ s.version = Ogma::VERSION
8
+ s.authors = ["Sergey Aldosev"]
9
+ s.email = ["stichie@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = "russian to english transliteration gem"
12
+ s.description = "simple russian to english transliteration gem with specific ukrainian letters support"
13
+
14
+ s.add_development_dependency "test-unit"
15
+
16
+ s.rubyforge_project = "ogma"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ # s.add_development_dependency "rspec"
25
+ # s.add_runtime_dependency "rest-client"
26
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ogma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sergey Aldosev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-unit
16
+ requirement: &2156019200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2156019200
25
+ description: simple russian to english transliteration gem with specific ukrainian
26
+ letters support
27
+ email:
28
+ - stichie@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - Rakefile
36
+ - lib/ogma.rb
37
+ - lib/ogma/version.rb
38
+ - ogma.gemspec
39
+ homepage: ''
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project: ogma
59
+ rubygems_version: 1.8.15
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: russian to english transliteration gem
63
+ test_files: []