currency_data 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/LICENSE.txt +1 -1
- data/currency_data.gemspec +1 -1
- data/data/currencies.json +9 -7
- data/lib/currency_data.rb +9 -2
- data/lib/currency_data/version.rb +1 -1
- data/spec/currency_data_spec.rb +14 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8301c7990ed0539dbc99622500cac5ed63ed8d24
|
4
|
+
data.tar.gz: f6c987067a3e841cdc4b13fd1afbd0e7cbe37fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c77711a6c05c308056e9c304a5fa941809289c38a84269ee357733bd2f5c9184553d594bda6d1d87464358f036867598339ee043940cb3a0bf0128cfe99e70
|
7
|
+
data.tar.gz: 6b681d7b912218b5567794eb57034aa7cef74bb92597f49db3c1bf91c02ec8fc87d72061a9cfda22ae9b6cb07689d7da54469a4ce15473d37fc89ac7e3c055ab
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/currency_data.gemspec
CHANGED
data/data/currencies.json
CHANGED
@@ -269,7 +269,7 @@
|
|
269
269
|
"priority": 100,
|
270
270
|
"iso_code": "BRL",
|
271
271
|
"name": "Brazilian Real",
|
272
|
-
"symbol": "R$
|
272
|
+
"symbol": "R$",
|
273
273
|
"subunit": "Centavo",
|
274
274
|
"subunit_to_unit": 100,
|
275
275
|
"symbol_first": true,
|
@@ -413,7 +413,7 @@
|
|
413
413
|
"subunit": "Peso",
|
414
414
|
"subunit_to_unit": 1,
|
415
415
|
"symbol_first": true,
|
416
|
-
"html_entity": "&#
|
416
|
+
"html_entity": "$",
|
417
417
|
"decimal_mark": ",",
|
418
418
|
"thousands_separator": ".",
|
419
419
|
"iso_numeric": "152"
|
@@ -1820,7 +1820,7 @@
|
|
1820
1820
|
},
|
1821
1821
|
"ssp": {
|
1822
1822
|
"priority": 100,
|
1823
|
-
"iso_code": "
|
1823
|
+
"iso_code": "SSP",
|
1824
1824
|
"name": "South Sudanese Pound",
|
1825
1825
|
"symbol": "£",
|
1826
1826
|
"alternate_symbols": [],
|
@@ -1918,11 +1918,11 @@
|
|
1918
1918
|
},
|
1919
1919
|
"tmt": {
|
1920
1920
|
"priority": 100,
|
1921
|
-
"iso_code": "
|
1921
|
+
"iso_code": "TMT",
|
1922
1922
|
"name": "Turkmenistani Manat",
|
1923
|
-
"symbol": "
|
1923
|
+
"symbol": "T",
|
1924
1924
|
"alternate_symbols": [],
|
1925
|
-
"subunit": "
|
1925
|
+
"subunit": "Tenge",
|
1926
1926
|
"subunit_to_unit": 100,
|
1927
1927
|
"symbol_first": false,
|
1928
1928
|
"html_entity": "",
|
@@ -2023,7 +2023,7 @@
|
|
2023
2023
|
"subunit": "Kopiyka",
|
2024
2024
|
"subunit_to_unit": 100,
|
2025
2025
|
"symbol_first": false,
|
2026
|
-
"html_entity": "₴",
|
2026
|
+
"html_entity": "₴",
|
2027
2027
|
"decimal_mark": ".",
|
2028
2028
|
"thousands_separator": ",",
|
2029
2029
|
"iso_numeric": "980"
|
@@ -2230,11 +2230,13 @@
|
|
2230
2230
|
"name": "Cfp Franc",
|
2231
2231
|
"symbol": "Fr",
|
2232
2232
|
"alternate_symbols": ["F"],
|
2233
|
+
"prefered_symbol": "CFP",
|
2233
2234
|
"subunit": "Centime",
|
2234
2235
|
"subunit_to_unit": 100,
|
2235
2236
|
"symbol_first": false,
|
2236
2237
|
"html_entity": "",
|
2237
2238
|
"decimal_mark": ".",
|
2239
|
+
"decimal_places": 0,
|
2238
2240
|
"thousands_separator": ",",
|
2239
2241
|
"iso_numeric": "953"
|
2240
2242
|
},
|
data/lib/currency_data.rb
CHANGED
@@ -9,13 +9,20 @@ module_function
|
|
9
9
|
|
10
10
|
def find iso_code
|
11
11
|
data = table[iso_code.to_s.downcase.to_sym]
|
12
|
-
data && OpenStruct.new(data)
|
12
|
+
data && OpenStruct.new(data).freeze
|
13
13
|
end
|
14
14
|
|
15
15
|
def table
|
16
16
|
@table ||= begin
|
17
17
|
json = File.read(CURRENCIES)
|
18
|
-
JSON.parse(json, symbolize_names: true)
|
18
|
+
hash = JSON.parse(json, symbolize_names: true)
|
19
|
+
|
20
|
+
hash.each do |code, attributes|
|
21
|
+
attributes[:prefered_symbol] ||= attributes[:symbol]
|
22
|
+
attributes[:decimal_places] ||= 2
|
23
|
+
end
|
24
|
+
|
25
|
+
hash.freeze
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
data/spec/currency_data_spec.rb
CHANGED
@@ -16,7 +16,9 @@ describe CurrencyData do
|
|
16
16
|
specify { expect(@nzd.symbol).to eq("$") }
|
17
17
|
specify { expect(@nzd.decimal_mark).to eq(".") }
|
18
18
|
specify { expect(@nzd.thousands_separator).to eq(",") }
|
19
|
-
specify { expect(@nzd.symbol_first).to
|
19
|
+
specify { expect(@nzd.symbol_first).to be true }
|
20
|
+
specify { expect(@nzd.prefered_symbol).to eq("$") }
|
21
|
+
specify { expect(@nzd.decimal_places).to eq(2) }
|
20
22
|
end
|
21
23
|
|
22
24
|
context "with EUR" do
|
@@ -27,7 +29,17 @@ describe CurrencyData do
|
|
27
29
|
specify { expect(@eur.symbol).to eq("€") }
|
28
30
|
specify { expect(@eur.decimal_mark).to eq(",") }
|
29
31
|
specify { expect(@eur.thousands_separator).to eq(".") }
|
30
|
-
specify { expect(@eur.symbol_first).to
|
32
|
+
specify { expect(@eur.symbol_first).to be true }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with XPF" do
|
36
|
+
before do
|
37
|
+
@xpf = CurrencyData.find("XPF")
|
38
|
+
end
|
39
|
+
|
40
|
+
specify { expect(@xpf.symbol).to eq("Fr") }
|
41
|
+
specify { expect(@xpf.prefered_symbol).to eq("CFP") }
|
42
|
+
specify { expect(@xpf.decimal_places).to eq(0) }
|
31
43
|
end
|
32
44
|
end
|
33
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cédric Félizard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3'
|
55
55
|
description: Information about currencies.
|
56
56
|
email:
|
57
57
|
- cedric@felizard.fr
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.2.
|
93
|
+
rubygems_version: 2.2.2
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Currency Data
|