currency_data 1.0.1 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5b0fce59025b4a8016c1f91755cbd7cdcb598a3
4
- data.tar.gz: 01ee6da7fb62dcc33fcbe865a94000856347ab10
3
+ metadata.gz: 8301c7990ed0539dbc99622500cac5ed63ed8d24
4
+ data.tar.gz: f6c987067a3e841cdc4b13fd1afbd0e7cbe37fbd
5
5
  SHA512:
6
- metadata.gz: 534731944184013f4d66c86945eb61e61a7e02b10c70d58686b38839d152cf4ef3e7c2ed6649965fec6faae7e972f044c8b5f64d857b972692f887d364cebafe
7
- data.tar.gz: 36583b2cc568a4ef9029c99c4d17a96684be17d51c1b7b1b7a9565ea0aed3e6688092c75af7f9497a663d55f50ca34b650ce48812d95724e32913b0305e0d6d6
6
+ metadata.gz: c2c77711a6c05c308056e9c304a5fa941809289c38a84269ee357733bd2f5c9184553d594bda6d1d87464358f036867598339ee043940cb3a0bf0128cfe99e70
7
+ data.tar.gz: 6b681d7b912218b5567794eb57034aa7cef74bb92597f49db3c1bf91c02ec8fc87d72061a9cfda22ae9b6cb07689d7da54469a4ce15473d37fc89ac7e3c055ab
@@ -2,7 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0
5
+ - 2.1
6
6
  notifications:
7
7
  email:
8
8
  on_success: always
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Bucky Box Limited
1
+ Copyright (c) 2013-2014 Bucky Box Limited
2
2
 
3
3
  MIT License
4
4
 
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rspec", "~> 3"
24
24
  end
@@ -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": "SHP",
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": "TMM",
1921
+ "iso_code": "TMT",
1922
1922
  "name": "Turkmenistani Manat",
1923
- "symbol": "m",
1923
+ "symbol": "T",
1924
1924
  "alternate_symbols": [],
1925
- "subunit": "Tennesi",
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": "&#x20B4",
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
  },
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CurrencyData
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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 be_true }
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 be_true }
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.1
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-02-23 00:00:00.000000000 Z
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: '0'
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: '0'
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.0
93
+ rubygems_version: 2.2.2
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Currency Data