i18n-complements 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +4 -4
- data/lib/i18n-complements/localize_extension.rb +3 -18
- data/lib/i18n-complements/numisma/currencies.yml +1 -0
- data/lib/i18n-complements/version.rb +1 -1
- data/test/test_currency_rates.rb +1 -1
- metadata +13 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3b22b0de1c457756d284aa0a6eb849d5bc0a954
|
4
|
+
data.tar.gz: e6a52e8aace1e3e30264b41e2bc5a84419b2492c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4bc7979b0ec81716b0ab6c6566401dadb9682ad87fcc668129fcc158c0ec845ae84581bee40ead4315f631233281810ff3ba5a0fb2491d664b0664b61535f21
|
7
|
+
data.tar.gz: 1a58f4a68fd03024545266768f7a305d843064cc24f2b91242ab2cf0013db29c7c336014e870e8c8be01ebb1fc60e71aba6c5d604a17679fa9ee5674bc0a72ad
|
data/README.rdoc
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
= I18nComplements
|
2
2
|
{<img src="https://badge.fury.io/rb/i18n-complements.png" alt="Gem Version" />}[http://badge.fury.io/rb/i18n-complements]
|
3
|
-
{<img src="https://api.travis-ci.org/
|
4
|
-
{<img src="https://gemnasium.com/
|
5
|
-
{<img src="https://codeclimate.com/github/
|
6
|
-
{<img src="https://coveralls.io/repos/
|
3
|
+
{<img src="https://api.travis-ci.org/ekylibre/i18n-complements.png?branch=master"/>}[https://travis-ci.org/ekylibre/i18n-complements]
|
4
|
+
{<img src="https://gemnasium.com/ekylibre/i18n-complements.png"/>}[https://gemnasium.com/ekylibre/i18n-complements]
|
5
|
+
{<img src="https://codeclimate.com/github/ekylibre/i18n-complements.png" />}[https://codeclimate.com/github/ekylibre/i18n-complements]
|
6
|
+
{<img src="https://coveralls.io/repos/ekylibre/i18n-complements/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/ekylibre/i18n-complements]
|
7
7
|
|
8
8
|
|
9
9
|
I18n complements provides:
|
@@ -10,13 +10,13 @@ module I18n
|
|
10
10
|
elsif object.respond_to?(:abs)
|
11
11
|
if currency = options[:currency]
|
12
12
|
raise I18n::InvalidCurrency.new("Currency #{currency.to_s} does not exist.") unless I18nComplements::Numisma[currency.to_s]
|
13
|
-
return I18nComplements::Numisma[currency.to_s].localize(object, :locale=>locale)
|
13
|
+
return I18nComplements::Numisma[currency.to_s].localize(object, :locale => locale)
|
14
14
|
else
|
15
15
|
formatter = I18n.translate('number.format'.to_sym, :locale => locale, :default => {})
|
16
16
|
if formatter.is_a?(Proc)
|
17
17
|
return formatter[object]
|
18
18
|
elsif formatter.is_a?(Hash)
|
19
|
-
formatter = {:format => "%n", :separator=>'.', :delimiter=>'', :precision=>3}.merge(formatter).merge(options)
|
19
|
+
formatter = {:format => "%n", :separator => '.', :delimiter => '', :precision => 3}.merge(formatter).merge(options)
|
20
20
|
format = formatter[:format]
|
21
21
|
negative_format = formatter[:negative_format] || "-" + format
|
22
22
|
|
@@ -30,24 +30,9 @@ module I18n
|
|
30
30
|
value = integrals.gsub(/^0+[1-9]+/, '').gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{formatter[:delimiter]}")
|
31
31
|
decimals = "0" if decimals.to_s.match(/^\s*$/) and object.is_a?(Float)
|
32
32
|
unless decimals.to_s.match(/^\s*$/)
|
33
|
-
# decimals = decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').reverse.split(/(?=\d{3})/).reverse.collect{|x| x.reverse}.join(formatter[:delimiter])
|
34
33
|
value << formatter[:separator]
|
35
|
-
|
36
|
-
i = 0
|
37
|
-
decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').each_char do |c|
|
38
|
-
if i == 3
|
39
|
-
value << formatter[:delimiter]
|
40
|
-
i = 0
|
41
|
-
end
|
42
|
-
value << c
|
43
|
-
i += 1
|
44
|
-
end
|
45
|
-
# .reverse.split(/(?=\d{3})/).reverse.collect{|x| x.reverse}.join(formatter[:delimiter])
|
46
|
-
# value << decimals
|
34
|
+
value << decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').scan(/.{1,3}/).join(formatter[:delimiter])
|
47
35
|
end
|
48
|
-
|
49
|
-
# decimals = decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').reverse.split(/(?=\d{3})/).reverse.collect{|x| x.reverse}.join(formatter[:delimiter])
|
50
|
-
# value += formatter[:separator] + decimals unless decimals.to_s.match(/^\s*$/)
|
51
36
|
return format.gsub(/%n/, value).gsub(/%s/, "\u{00A0}")
|
52
37
|
end
|
53
38
|
end
|
data/test/test_currency_rates.rb
CHANGED
@@ -19,7 +19,7 @@ class TestCurrencies < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
r1 = I18nComplements::Numisma.currency_rate("EUR", "JPY")
|
21
21
|
r2 = I18nComplements::Numisma.currency_rate("JPY", "EUR")
|
22
|
-
|
22
|
+
assert 0.01 >= 1 - (r1 * r2).round(2)
|
23
23
|
|
24
24
|
assert_nothing_raised do
|
25
25
|
I18nComplements::Numisma.currency_rate("EUR", "JPY")
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-complements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.11
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brice Texier
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: i18n
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.6'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: coveralls
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.6.3
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.6.3
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '10'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '10'
|
62
55
|
description:
|
@@ -89,27 +82,26 @@ files:
|
|
89
82
|
homepage: http://github.com/burisu/i18n-complements
|
90
83
|
licenses:
|
91
84
|
- MIT
|
85
|
+
metadata: {}
|
92
86
|
post_install_message:
|
93
87
|
rdoc_options: []
|
94
88
|
require_paths:
|
95
89
|
- lib
|
96
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
91
|
requirements:
|
99
|
-
- -
|
92
|
+
- - ">="
|
100
93
|
- !ruby/object:Gem::Version
|
101
94
|
version: '0'
|
102
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
96
|
requirements:
|
105
|
-
- -
|
97
|
+
- - ">="
|
106
98
|
- !ruby/object:Gem::Version
|
107
99
|
version: '0'
|
108
100
|
requirements: []
|
109
101
|
rubyforge_project:
|
110
|
-
rubygems_version:
|
102
|
+
rubygems_version: 2.2.2
|
111
103
|
signing_key:
|
112
|
-
specification_version:
|
104
|
+
specification_version: 4
|
113
105
|
summary: I18n missing functionnalities
|
114
106
|
test_files:
|
115
107
|
- test/helper.rb
|