c12-commons 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/c12-commons.gemspec +2 -6
- data/lib/c12-commons/core.rb +1 -1
- data/lib/c12-commons/email.rb +1 -1
- data/lib/c12-commons/mobile.rb +1 -1
- data/lib/c12-commons/string.rb +48 -0
- data/lib/c12-commons/version.rb +2 -2
- data/lib/c12-commons.rb +2 -2
- data/spec/c12-commons/date_spec.rb +1 -1
- data/spec/c12-commons/email_spec.rb +1 -1
- data/spec/c12-commons/mobile_spec.rb +1 -1
- data/spec/c12-commons/number_spec.rb +1 -1
- data/spec/c12-commons/string_spec.rb +17 -0
- data/spec/spec_helper.rb +0 -10
- metadata +15 -65
- data/lib/c12-commons/pdf-assets/DejaVuSans-Bold.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSans-BoldOblique.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSans-Oblique.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSans.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSerif-Bold.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSerif-BoldItalic.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSerif-Italic.ttf +0 -0
- data/lib/c12-commons/pdf-assets/DejaVuSerif.ttf +0 -0
- data/lib/c12-commons/pdf.rb +0 -48
- data/spec/c12-commons/pdf_spec.rb +0 -14
data/c12-commons.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Dimitri Kurashvili"]
|
9
9
|
s.email = ["dimitri@c12.ge"]
|
10
10
|
s.homepage = "http://c12.ge"
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
11
|
+
s.summary = %q{KA Localization}
|
12
|
+
s.description = %q{Functionality used in georgian projects}
|
13
13
|
|
14
14
|
s.rubyforge_project = "c12-commons"
|
15
15
|
|
@@ -19,8 +19,4 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_development_dependency 'rspec', '~> 2'
|
22
|
-
s.add_development_dependency 'simplecov'
|
23
|
-
|
24
|
-
s.add_runtime_dependency 'actionpack', '~> 3'
|
25
|
-
s.add_runtime_dependency 'prawn', '~> 0.12'
|
26
22
|
end
|
data/lib/c12-commons/core.rb
CHANGED
data/lib/c12-commons/email.rb
CHANGED
data/lib/c12-commons/mobile.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class String
|
3
|
+
|
4
|
+
# Generates next numeric value from this string.
|
5
|
+
def next_number
|
6
|
+
index = self.index(/[0-9]*$/)
|
7
|
+
if index
|
8
|
+
pref = self[0, index]
|
9
|
+
suff = self[index, self.length].to_i + 1
|
10
|
+
lnth = self.length - pref.length
|
11
|
+
%Q{#{pref}#{("%0#{lnth}d" % suff)}}
|
12
|
+
else
|
13
|
+
"#{self}1"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Translation between legacy character sets.
|
18
|
+
|
19
|
+
GEO = 'ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖ×ØÙÚÛÜÝÞßàáãä'
|
20
|
+
KA = 'აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ'
|
21
|
+
LAT = 'abgdevzTiklmnopJrstufqRySCcZwWxjh'
|
22
|
+
|
23
|
+
def translate(from, to)
|
24
|
+
txt = ""
|
25
|
+
self.split('').each do |c|
|
26
|
+
indx = from.index(c)
|
27
|
+
txt += indx ? to[indx] : c
|
28
|
+
end
|
29
|
+
txt
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_ka(deep = false)
|
33
|
+
if deep
|
34
|
+
self.translate("#{GEO}#{LAT}", "#{KA}#{KA}")
|
35
|
+
else
|
36
|
+
self.translate(GEO, KA)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_geo
|
41
|
+
self.translate(KA, GEO)
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_lat
|
45
|
+
self.translate("#{GEO}#{KA}", "#{LAT}#{LAT}")
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/c12-commons/version.rb
CHANGED
data/lib/c12-commons.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'action_controller'
|
4
4
|
include ActionView::Helpers::NumberHelper
|
5
5
|
|
6
|
+
require 'c12-commons/string'
|
6
7
|
require 'c12-commons/version'
|
7
8
|
require 'c12-commons/core'
|
8
9
|
require 'c12-commons/ka'
|
9
|
-
require 'c12-commons/pdf'
|
10
10
|
require 'c12-commons/email'
|
11
|
-
require 'c12-commons/mobile'
|
11
|
+
require 'c12-commons/mobile'
|
@@ -93,4 +93,4 @@ def test_date_format(date, expected, options = {})
|
|
93
93
|
end
|
94
94
|
|
95
95
|
test_date_format(Time.new(2012, 1, 1), '01 იანვარი 2012')
|
96
|
-
test_date_format(Time.new(2012, 1, 1), '01 იან 2012', :format => :short)
|
96
|
+
test_date_format(Time.new(2012, 1, 1), '01 იან 2012', :format => :short)
|
@@ -17,4 +17,4 @@ test_number_tokenizer(-9999, 'მინუს ცხრა ათას ცხ
|
|
17
17
|
|
18
18
|
# currency
|
19
19
|
test_number_tokenizer(10.20, 'ათი ლარი 20 თეთრი', :currency => 'ლარი', :currency_minor => 'თეთრი')
|
20
|
-
test_number_tokenizer(390.20, 'სამას ოთხმოცდა ათი ლარი 20 თეთრი', :currency => 'ლარი', :currency_minor => 'თეთრი')
|
20
|
+
test_number_tokenizer(390.20, 'სამას ოთხმოცდა ათი ლარი 20 თეთრი', :currency => 'ლარი', :currency_minor => 'თეთრი')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'String#next_number' do
|
5
|
+
specify { '001'.next_number.should == '002' }
|
6
|
+
specify { '001-01'.next_number.should == '001-02' }
|
7
|
+
specify { '009'.next_number.should == '010' }
|
8
|
+
specify { '099'.next_number.should == '100' }
|
9
|
+
specify { '999'.next_number.should == '1000' }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'String#to_ka' do
|
13
|
+
specify { 'dimitri yuraSvili'.to_ka.should == 'dimitri yuraSvili' }
|
14
|
+
specify { 'dimitri yuraSvili'.to_ka(true).should == 'დიმიტრი ყურაშვილი' }
|
15
|
+
specify { 'ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖ×ØÙÚÛÜÝÞßàáãä'.to_ka.should == 'აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ' }
|
16
|
+
specify { 'აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ'.to_geo.should == 'ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖ×ØÙÚÛÜÝÞßàáãä' }
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c12-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -27,55 +27,7 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2'
|
30
|
-
|
31
|
-
name: simplecov
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: actionpack
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: prawn
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0.12'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0.12'
|
78
|
-
description: Simple functionality used in my projects
|
30
|
+
description: Functionality used in georgian projects
|
79
31
|
email:
|
80
32
|
- dimitri@c12.ge
|
81
33
|
executables: []
|
@@ -93,22 +45,14 @@ files:
|
|
93
45
|
- lib/c12-commons/email.rb
|
94
46
|
- lib/c12-commons/ka.rb
|
95
47
|
- lib/c12-commons/mobile.rb
|
96
|
-
- lib/c12-commons/
|
97
|
-
- lib/c12-commons/pdf-assets/DejaVuSans-BoldOblique.ttf
|
98
|
-
- lib/c12-commons/pdf-assets/DejaVuSans-Oblique.ttf
|
99
|
-
- lib/c12-commons/pdf-assets/DejaVuSans.ttf
|
100
|
-
- lib/c12-commons/pdf-assets/DejaVuSerif-Bold.ttf
|
101
|
-
- lib/c12-commons/pdf-assets/DejaVuSerif-BoldItalic.ttf
|
102
|
-
- lib/c12-commons/pdf-assets/DejaVuSerif-Italic.ttf
|
103
|
-
- lib/c12-commons/pdf-assets/DejaVuSerif.ttf
|
104
|
-
- lib/c12-commons/pdf.rb
|
48
|
+
- lib/c12-commons/string.rb
|
105
49
|
- lib/c12-commons/version.rb
|
106
50
|
- spec/c12-commons/core_spec.rb
|
107
51
|
- spec/c12-commons/date_spec.rb
|
108
52
|
- spec/c12-commons/email_spec.rb
|
109
53
|
- spec/c12-commons/mobile_spec.rb
|
110
54
|
- spec/c12-commons/number_spec.rb
|
111
|
-
- spec/c12-commons/
|
55
|
+
- spec/c12-commons/string_spec.rb
|
112
56
|
- spec/spec_helper.rb
|
113
57
|
homepage: http://c12.ge
|
114
58
|
licenses: []
|
@@ -130,9 +74,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
74
|
version: '0'
|
131
75
|
requirements: []
|
132
76
|
rubyforge_project: c12-commons
|
133
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.24
|
134
78
|
signing_key:
|
135
79
|
specification_version: 3
|
136
|
-
summary:
|
137
|
-
test_files:
|
138
|
-
|
80
|
+
summary: KA Localization
|
81
|
+
test_files:
|
82
|
+
- spec/c12-commons/core_spec.rb
|
83
|
+
- spec/c12-commons/date_spec.rb
|
84
|
+
- spec/c12-commons/email_spec.rb
|
85
|
+
- spec/c12-commons/mobile_spec.rb
|
86
|
+
- spec/c12-commons/number_spec.rb
|
87
|
+
- spec/c12-commons/string_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/c12-commons/pdf.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require 'prawn'
|
4
|
-
|
5
|
-
module C12
|
6
|
-
# This module is used for working with PDF.
|
7
|
-
module PDF
|
8
|
-
|
9
|
-
class Document < Prawn::Document
|
10
|
-
|
11
|
-
# Sets the current font of the document.
|
12
|
-
# Font names are predefined.
|
13
|
-
# All of them are Georgian-character friendly fonts.
|
14
|
-
#
|
15
|
-
# @param font name of the font. This may be one of
|
16
|
-
# <code>default</code>, <code>serif</code>, <code>sefit-italic</code>,
|
17
|
-
# <code>serif-bold</code>, <code>serif-bold-italic</code>.
|
18
|
-
# Value <code>nil</code> or any other value is considered as <code>default</code>.
|
19
|
-
# @param size size for the font. This parameter defaults to 10pt.
|
20
|
-
def change_font(font = :default, size = 10)
|
21
|
-
case font.to_s
|
22
|
-
when 'default'
|
23
|
-
ff = 'DejaVuSans'
|
24
|
-
when 'bold'
|
25
|
-
ff = 'DejaVuSans-Bold'
|
26
|
-
when 'italic'
|
27
|
-
ff = 'DejaVuSans-Oblique'
|
28
|
-
when 'bold-italic'
|
29
|
-
ff = 'DejaVuSans-BoldOblique'
|
30
|
-
when 'serif'
|
31
|
-
ff = 'DejaVuSerif'
|
32
|
-
when 'serif-italic'
|
33
|
-
ff = 'DejaVuSerif-Italic'
|
34
|
-
when 'serif-bold'
|
35
|
-
ff = 'DejaVuSerif-Bold'
|
36
|
-
when 'serif-bold-italic'
|
37
|
-
ff = 'DejaVuSerif-BoldItalic'
|
38
|
-
else
|
39
|
-
ff = 'DejaVuSans'
|
40
|
-
end
|
41
|
-
#pdf.font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
42
|
-
self.font File.expand_path("../pdf-assets/#{ff}.ttf", __FILE__), :size => size
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'Simple PDF generation' do
|
6
|
-
before(:all) do
|
7
|
-
C12::PDF::Document.generate 'tmp/example.pdf' do |pdf|
|
8
|
-
pdf.change_font
|
9
|
-
pdf.text 'დიმიტრი ყურაშვილი'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
specify { File.exists?('tmp/example.pdf').should == true }
|
13
|
-
specify { File.zero?('tmp/example.pdf').should == false }
|
14
|
-
end
|