greek_string_utils 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.
- data/.gitignore +7 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +24 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +27 -0
- data/greek_string_utils.gemspec +20 -0
- data/lib/greek_string_utils.rb +59 -0
- data/lib/greek_string_utils/version.rb +3 -0
- data/lib/tasks/greek_upperfix_tasks.rake +4 -0
- data/spec/greek_string_utils_spec.rb +19 -0
- metadata +63 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
greek_string_utils (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.6.0)
|
11
|
+
rspec-core (~> 2.6.0)
|
12
|
+
rspec-expectations (~> 2.6.0)
|
13
|
+
rspec-mocks (~> 2.6.0)
|
14
|
+
rspec-core (2.6.4)
|
15
|
+
rspec-expectations (2.6.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.6.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
greek_string_utils!
|
24
|
+
rspec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= GreekStringUtils
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
In general greek strings dont preserve accents when upcase. This module simply provides a method
|
6
|
+
to correct this issue. For other cases (capitalize, downcase etc) +unicode+, +mb_chars+ etc are doing
|
7
|
+
their job very well. Gem's name is more ambitious than what it really provides :)
|
8
|
+
|
9
|
+
== Install
|
10
|
+
|
11
|
+
gem install 'greek_string_utils'
|
12
|
+
|
13
|
+
== Example
|
14
|
+
|
15
|
+
require 'greek_string_utils'
|
16
|
+
include GreekStringUtils
|
17
|
+
|
18
|
+
a = 'το 2012 η ελλάδα θα είναι δεύτερη σε ύφεση στον κόσμο'
|
19
|
+
upperfix(a) # => 'ΤΟ 2012 Η ΕΛΛΑΔΑ ΘΑ ΕΙΝΑΙ ΔΕΥΤΕΡΗ ΣΕ ΥΦΕΣΗ ΣΤΟΝ ΚΟΣΜΟ'
|
20
|
+
|
21
|
+
if you want to use it in a rails app:
|
22
|
+
|
23
|
+
gem 'greek_string_utils'
|
24
|
+
|
25
|
+
And normally in application_helper.rb:
|
26
|
+
|
27
|
+
include GreekStringUtils
|
28
|
+
|
29
|
+
== Credits
|
30
|
+
|
31
|
+
Eric Coen https://github.com/eirc
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'GreekStringUtils'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "greek_string_utils/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "greek_string_utils"
|
9
|
+
s.version = GreekStringUtils::VERSION
|
10
|
+
s.authors = ["Giorgos Tsiftsis"]
|
11
|
+
s.email = ["giorgos.tsiftsis@gmail.com"]
|
12
|
+
s.homepage = "https://github.com/chief/greek_string_utils"
|
13
|
+
s.summary = "Simple library to correct upcase in greek"
|
14
|
+
s.description = "Simple library to correct upcase in greek"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GreekStringUtils
|
4
|
+
def upperfix(string)
|
5
|
+
string.chars.map do |char|
|
6
|
+
case char
|
7
|
+
# Downcase characters
|
8
|
+
when 'α' then 'Α'
|
9
|
+
when 'β' then 'Β'
|
10
|
+
when 'γ' then 'Γ'
|
11
|
+
when 'δ' then 'Δ'
|
12
|
+
when 'ε' then 'Ε'
|
13
|
+
when 'ζ' then 'Ζ'
|
14
|
+
when 'η' then 'Η'
|
15
|
+
when 'θ' then 'Θ'
|
16
|
+
when 'ι' then 'Ι'
|
17
|
+
when 'κ' then 'Κ'
|
18
|
+
when 'λ' then 'Λ'
|
19
|
+
when 'μ' then 'Μ'
|
20
|
+
when 'ν' then 'Ν'
|
21
|
+
when 'ξ' then 'Ξ'
|
22
|
+
when 'ο' then 'Ο'
|
23
|
+
when 'π' then 'Π'
|
24
|
+
when 'ρ' then 'Ρ'
|
25
|
+
when 'σ' then 'Σ'
|
26
|
+
when 'ς' then 'Σ'
|
27
|
+
when 'τ' then 'Τ'
|
28
|
+
when 'υ' then 'Υ'
|
29
|
+
when 'φ' then 'Φ'
|
30
|
+
when 'χ' then 'Χ'
|
31
|
+
when 'ψ' then 'Ψ'
|
32
|
+
when 'ω' then 'Ω'
|
33
|
+
# Downcase characters with acute accents
|
34
|
+
when 'ά' then 'Α'
|
35
|
+
when 'έ' then 'Ε'
|
36
|
+
when 'ή' then 'Η'
|
37
|
+
when 'ί' then 'Ι'
|
38
|
+
when 'ό' then 'Ο'
|
39
|
+
when 'ύ' then 'Υ'
|
40
|
+
when 'ώ' then 'Ω'
|
41
|
+
# Upcase characters with acute accents
|
42
|
+
when 'Ά' then 'Α'
|
43
|
+
when 'Έ' then 'Ε'
|
44
|
+
when 'Ή' then 'Η'
|
45
|
+
when 'Ί' then 'Ι'
|
46
|
+
when 'Ό' then 'Ο'
|
47
|
+
when 'Ύ' then 'Υ'
|
48
|
+
when 'Ώ' then 'Ω'
|
49
|
+
# Downcase characters with acute and diaeresis accents (diaeresis preserved in upcase)
|
50
|
+
when 'ϊ' then 'Ϊ'
|
51
|
+
when 'ϋ' then 'Ϋ'
|
52
|
+
# Downcase characters with acute and diaeresis accents (diaeresis preserved in upcase)
|
53
|
+
when 'ΐ' then 'Ϊ'
|
54
|
+
when 'ΰ' then 'Ϋ'
|
55
|
+
else char.upcase
|
56
|
+
end
|
57
|
+
end.join
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'greek_string_utils'
|
4
|
+
|
5
|
+
describe 'GreekStringUtils' do
|
6
|
+
|
7
|
+
include GreekStringUtils
|
8
|
+
|
9
|
+
it 'should upcase greek letters' do
|
10
|
+
a = 'αυτό είναι ένα τεστ'
|
11
|
+
upperfix(a).should eql('ΑΥΤΟ ΕΙΝΑΙ ΕΝΑ ΤΕΣΤ')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should upcase greek letters mixin with english' do
|
15
|
+
a = 'αυτό einai ένα test'
|
16
|
+
upperfix(a).should eql('ΑΥΤΟ EINAI ΕΝΑ TEST')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: greek_string_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Giorgos Tsiftsis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-05 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Simple library to correct upcase in greek
|
15
|
+
email:
|
16
|
+
- giorgos.tsiftsis@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rspec
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- MIT-LICENSE
|
26
|
+
- README.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- greek_string_utils.gemspec
|
29
|
+
- lib/greek_string_utils.rb
|
30
|
+
- lib/greek_string_utils/version.rb
|
31
|
+
- lib/tasks/greek_upperfix_tasks.rake
|
32
|
+
- spec/greek_string_utils_spec.rb
|
33
|
+
homepage: https://github.com/chief/greek_string_utils
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
hash: 480759795
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
hash: 480759795
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.14
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Simple library to correct upcase in greek
|
63
|
+
test_files: []
|