c12-commons 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,29 +1,31 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- # Returns the first argument unless it's <code>nil</code>,
4
- # in which case the second argument is returned.
5
- def nvl(value, value_if_nil = 0)
6
- value.nil? ? value_if_nil : value
7
- end
3
+ module C12
8
4
 
9
- # Determines emptiness of the argument.
10
- #
11
- # <code>nil</code> is empty, <code>''</code> is empty,
12
- # empty <code>Array</code> or <code>Array</code> of <code>nil</code>s is empty.
13
- # Other objects are empty if they respond to <code>empty?</code> command and it returns <code>true</code>.
14
- # In other cases the object is not empty.
15
- def empty?(value)
16
- return true if value.nil?
17
- return value.strip.empty? if value.instance_of? String
18
- return value.compact.empty? if value.instance_of? Array
19
- return value.empty? if value.respond_to? :empty?
20
- false
21
- end
5
+ # Returns the first argument unless it's <code>nil</code>,
6
+ # in which case the second argument is returned.
7
+ def self.nvl(value, value_if_nil = 0)
8
+ value.nil? ? value_if_nil : value
9
+ end
22
10
 
23
- include ActionView::Helpers::NumberHelper
11
+ # Determines emptiness of the argument.
12
+ #
13
+ # <code>nil</code> is empty, <code>''</code> is empty,
14
+ # empty <code>Array</code> or <code>Array</code> of <code>nil</code>s is empty.
15
+ # Other objects are empty if they respond to <code>empty?</code> command and it returns <code>true</code>.
16
+ # In other cases the object is not empty.
17
+ def self.empty?(value)
18
+ return true if value.nil?
19
+ return value.strip.empty? if value.instance_of? String
20
+ return value.compact.empty? if value.instance_of? Array
21
+ return value.empty? if value.respond_to? :empty?
22
+ false
23
+ end
24
24
 
25
- # Format number using given precission. Number is formatted
26
- # using Georgian conventions for decimal and thousands separators.
27
- def number_format(number, precision = 2)
28
- C12::KA.number(number, :precision => precision)
29
- end
25
+ # Format number using given precission. Number is formatted
26
+ # using Georgian conventions for decimal and thousands separators.
27
+ def self.number_format(number, precision = 2)
28
+ C12::KA.number(number, :precision => precision)
29
+ end
30
+
31
+ end
@@ -1,9 +1,14 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ require 'c12-commons'
4
+
3
5
  module C12
4
6
 
5
7
  # This module is used for managing Georgian locale data.
6
8
  module KA
9
+
10
+ include ActionView::Helpers::NumberHelper
11
+
7
12
  private
8
13
 
9
14
  MONTHS_EN_SHORT = {'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8, 'sep' => 9, 'oct' => 10, 'nov' => 11, 'dec' => 12}
@@ -54,7 +59,7 @@ module C12
54
59
  #
55
60
  # The maximum value for the argument is the value <code>999,999,999,999</code>.
56
61
  def self.tokenize(num, opts = {})
57
- num_ge_0 = nvl(num, 0).abs
62
+ num_ge_0 = C12.nvl(num, 0).abs
58
63
  if num.instance_of? Fixnum
59
64
  token = tokenize_int_ge_0(num_ge_0)
60
65
  elsif num.instance_of? Float
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module C12
3
3
  module Commons
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
@@ -5,7 +5,7 @@ require 'c12-commons'
5
5
  # გადაეცით ორი არგუმენტი და შეადარეთ გამოსავალი.
6
6
  def test_nvl(a1, a2, expect)
7
7
  describe "nvl(#{a1.inspect}, #{a2.inspect})" do
8
- subject { nvl(a1, a2) }
8
+ subject { C12.nvl(a1, a2) }
9
9
  it("should be #{expect.inspect}") { should == expect }
10
10
  end
11
11
  end
@@ -16,7 +16,7 @@ test_nvl(nil, 2, 2)
16
16
 
17
17
  def test_emptiness(val, is_empty)
18
18
  describe "#{val.inspect}" do
19
- subject { empty?(val) }
19
+ subject { C12.empty?(val) }
20
20
  it("is #{is_empty ? '' : ' not '} empty") { should == is_empty }
21
21
  end
22
22
  end
@@ -33,7 +33,7 @@ test_emptiness({:a => 1, :b=>2}, false)
33
33
 
34
34
  def test_number_formatting(number, precision, format)
35
35
  describe "#{number} should be formated" do
36
- subject{ number_format(number, precision) }
36
+ subject{ C12.number_format(number, precision) }
37
37
  it("as #{format}") { should == format }
38
38
  end
39
39
  end
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-04 00:00:00.000000000 Z
12
+ date: 2012-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70316684746560 !ruby/object:Gem::Requirement
16
+ requirement: &84622480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70316684746560
24
+ version_requirements: *84622480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &70316684675880 !ruby/object:Gem::Requirement
27
+ requirement: &84622280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70316684675880
35
+ version_requirements: *84622280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: actionpack
38
- requirement: &70316680599740 !ruby/object:Gem::Requirement
38
+ requirement: &84622010 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70316680599740
46
+ version_requirements: *84622010
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: prawn
49
- requirement: &70316680351380 !ruby/object:Gem::Requirement
49
+ requirement: &84621760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.12'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70316680351380
57
+ version_requirements: *84621760
58
58
  description: Simple functionality used in my projects
59
59
  email:
60
60
  - dimitri@c12.ge
@@ -78,10 +78,10 @@ files:
78
78
  - lib/c12-commons/pdf-assets/DejaVuSerif.ttf
79
79
  - lib/c12-commons/pdf.rb
80
80
  - lib/c12-commons/version.rb
81
+ - spec/c12-commons/core_spec.rb
81
82
  - spec/c12-commons/date_spec.rb
82
83
  - spec/c12-commons/number_spec.rb
83
84
  - spec/c12-commons/pdf_spec.rb
84
- - spec/c12-commons/ruby_spec.rb
85
85
  - spec/spec_helper.rb
86
86
  homepage: http://c12.ge
87
87
  licenses: []
@@ -103,14 +103,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project: c12-commons
106
- rubygems_version: 1.8.15
106
+ rubygems_version: 1.8.13
107
107
  signing_key:
108
108
  specification_version: 3
109
109
  summary: Simple functions
110
- test_files:
111
- - spec/c12-commons/date_spec.rb
112
- - spec/c12-commons/number_spec.rb
113
- - spec/c12-commons/pdf_spec.rb
114
- - spec/c12-commons/ruby_spec.rb
115
- - spec/spec_helper.rb
110
+ test_files: []
116
111
  has_rdoc: