money 6.6.1 → 6.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3285f9f76aec95f56d6f73d260330c3bc0f6984
4
- data.tar.gz: 956b5acb84b6b2100d31e49b4a4c79bfbc71e612
3
+ metadata.gz: 9cffd9f173701f8599fae9244a9de6b4aef0a95f
4
+ data.tar.gz: 30080c0c9743507a615598ab80c8235d7313f769
5
5
  SHA512:
6
- metadata.gz: 2892ac7ef0eb825da0e0d2d37c1c794703f781d3667bf265f72f032d2de0f132fe061965561dbbbf5d70f6de57a6658c4a11608e83462bee46a263a27c49b320
7
- data.tar.gz: ee6ac428822ff9c7783b684d50374fb6bb2e9b41722c4e20d57f57328c972dcb0055d62efb0684c4fc29dace6bc6340b5e36bbcfa2c58a75e19f63179b6ae49a
6
+ metadata.gz: 60307b13ad66a684ff833d58441093b58eb7730ccb108b6804a68f935a91dcc0921153e7c2ce0c8543af0851239b4c7289dcc23f71c60361e875d0e71f5f26fb
7
+ data.tar.gz: b435062afea1d2a798502354347b757dc5c4f84a835449d39d411c9ea6400e52fa99eeeded5322a92e00b0956d41d9d3003134b25f49c72b18b4fa1f195acf01
data/.gitignore CHANGED
@@ -17,6 +17,7 @@ doc/
17
17
  .rbx
18
18
  .rvmrc
19
19
  .ruby-version
20
+ .ruby-gemset
20
21
 
21
22
  # Spec artifacts
22
23
  /coverage
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.travis.yml CHANGED
@@ -3,8 +3,9 @@ sudo: false
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.6
7
- - 2.2.2
6
+ - 2.1.8
7
+ - 2.2.4
8
+ - 2.3.0
8
9
  - rbx-2
9
10
  script: bundle exec rspec spec
10
11
  notifications:
data/AUTHORS CHANGED
@@ -1,7 +1,7 @@
1
1
  Abhay Kumar
2
2
  Adrian Longley
3
- Alex Speller
4
3
  Alexander Ross
4
+ Alex Speller
5
5
  Andreas Loupasakis
6
6
  Andrei
7
7
  Andrew White
@@ -23,18 +23,19 @@ Choongmin Lee
23
23
  Chris Kampmeier
24
24
  Christian Billen
25
25
  Clarke Brunsdon
26
- Dave Kroondyk
27
26
  Daniel Sherson
27
+ Dave Kroondyk
28
28
  Doug Droper
29
+ Douglas Miller
29
30
  Ed Saunders
30
31
  Edwin Vlieg
31
32
  Eloy
32
33
  Evan Alter
33
34
  Exoth
34
35
  Filipe Goncalves
36
+ Francisco Trindade
35
37
  François Beausoleil
36
38
  François Klingler
37
- Francisco Trindade
38
39
  Gabriel Gilder
39
40
  Gee-Hsien Chuang
40
41
  George Millo
@@ -46,17 +47,18 @@ Jacob Atzen
46
47
  James Cotterill
47
48
  James Hunt
48
49
  Jean-Louis Giordano
50
+ Jean-Philippe Doyle
49
51
  Jell
50
- Jeremy McNevin
51
52
  Jérémy Lecour
53
+ Jeremy McNevin
52
54
  Jesse Cooke
53
55
  Jim Kingdon
54
56
  John Duff
55
57
  John Gakos
56
58
  Jonathon M. Abbott
57
59
  Josh Delsman
58
- Joshua Clayton
59
60
  Josh Hepworth
61
+ Joshua Clayton
60
62
  Julien Boyer
61
63
  Kaleem Ullah
62
64
  Kenichi Kamiya
@@ -68,11 +70,11 @@ Marco Otte-Witte
68
70
  Mateus Gomes
69
71
  Mateusz Wolsza
70
72
  Matias Korhonen
71
- Matt Jankowski
72
73
  Matthew McEachen
74
+ Matt Jankowski
73
75
  Max Melentiev
74
- Michael J. Cohen
75
76
  Michael Irwin
77
+ Michael J. Cohen
76
78
  Michael Reinsch
77
79
  Michael Rodrigues
78
80
  Mikael Wikman
@@ -85,11 +87,12 @@ Olek Janiszewski
85
87
  Orien Madgwick
86
88
  Paul McMahon
87
89
  Paulo Diniz
88
- Pavel Gabriel
89
90
  Pavan Sudarshan
91
+ Pavel Gabriel
90
92
  pconnor
91
93
  Pedro Nascimento
92
94
  Pelle Braendgaard
95
+ Peter Rhoades
93
96
  Phil Cohen
94
97
  pivotal-cloudplanner
95
98
  Prathan Thananart
@@ -97,15 +100,12 @@ Robert Starsi
97
100
  Romain Gérard
98
101
  Ryan Bigg
99
102
  sankaranarayanan
100
- Semyon Perepelitsa
101
103
  Scott Pierce
104
+ Semyon Perepelitsa
102
105
  Shane Emmons
103
106
  Simone Carletti
104
107
  Spencer Rinehart
105
108
  Steve Morris
106
- Yok
107
- Yuri Sidorov
108
- Yuusuke Takizawa
109
109
  Thomas E Enebo
110
110
  Thomas Weymuth
111
111
  Ticean Bennett
@@ -117,7 +117,10 @@ Tom Lianza
117
117
  tommeier
118
118
  Troels Knak-Nielsen
119
119
  Tsyren Ochirov
120
+ Victor Shcherbakov
120
121
  Wei Zhu
122
+ Yok
123
+ Yuri Sidorov
124
+ Yuusuke Takizawa
121
125
  Zubin Henner
122
126
  Бродяной Александр
123
- Douglas Miller
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## Next release
4
-
5
- TBD
3
+ ## 6.7.0
4
+ - Changed `Money#<=>` to return `nil` if the comparison is inappropriate. (#584)
5
+ - Remove implicit conversion of values being compared. Only accept `Money` and
6
+ subclasses of `Money` for comparisons and raise TypeError otherwise.
7
+ - When comparing fails due to `Money::Bank::UnknownRate` `Money#<=>` will now
8
+ return `nil` as `Comparable#==` will not rescue exceptions in the next release.
9
+ - Fix `Currency` specs for `#exponent` and `#decimal_places` not making assertions.
10
+ - Fix a couple of Ruby warnings found in specs.
11
+ - Fix `Money#-`,`Money#+` arithmetics for Ruby 2.3+ : check for zero value without using eql? with a Fixnum. (#577)
12
+ - Use `Money#decimal_mark` when formatting with `rounded_infinite_precision` rule
13
+ set to `true`.
14
+ - Replaced meta-defined `thousands_separator` and `decimal_mark` methods with regular methods. (#579)
6
15
 
7
16
  ## 6.6.0
8
17
  - Fixed VariableExchange#exchange_with for big numbers.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem "coveralls", :require => false
4
- gem "json", :platform => [:jruby, :mri_18]
4
+ gem "json", :platform => :jruby
5
5
  gem "pry", :require => false
6
6
 
7
7
  gemspec
data/README.md CHANGED
@@ -34,9 +34,9 @@ A Ruby Library for dealing with money and currency conversion.
34
34
 
35
35
  ### Resources
36
36
 
37
- - [Website](http://rubymoney.github.com/money)
38
- - [API Documentation](http://rubydoc.info/gems/money/frames)
39
- - [Git Repository](http://github.com/RubyMoney/money)
37
+ - [Website](http://rubymoney.github.io/money/)
38
+ - [API Documentation](http://www.rubydoc.info/gems/money/frames)
39
+ - [Git Repository](https://github.com/RubyMoney/money)
40
40
 
41
41
  ### Notes
42
42
 
@@ -101,8 +101,8 @@ The most part of `Money` APIs allows you to supply either a `String` or a
101
101
  `Money::Currency`.
102
102
 
103
103
  ``` ruby
104
- Money.new(1000, "USD") == Money.new(1000, Currency.new("USD"))
105
- Money.new(1000, "EUR").currency == Currency.new("EUR")
104
+ Money.new(1000, "USD") == Money.new(1000, Money::Currency.new("USD"))
105
+ Money.new(1000, "EUR").currency == Money::Currency.new("EUR")
106
106
  ```
107
107
 
108
108
  A `Money::Currency` instance holds all the information about the currency,
@@ -181,10 +181,10 @@ def all_currencies(hash)
181
181
  end
182
182
 
183
183
  major_currencies(Money::Currency.table)
184
- # => [ :usd, :eur, :bgp, :cad ]
184
+ # => [:usd, :eur, :gbp, :aud, :cad, :jpy]
185
185
 
186
186
  all_currencies(Money::Currency.table)
187
- # => [ :aed, :afn, all, ... ]
187
+ # => [:aed, :afn, :all, ...]
188
188
  ```
189
189
 
190
190
  ### Default Currency
@@ -202,7 +202,7 @@ If you use Rails, then `environment.rb` is a very good place to put this.
202
202
 
203
203
  The exponent of a money value is the number of digits after the decimal
204
204
  separator (which separates the major unit from the minor unit). See e.g.
205
- [Wikipedia on ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) for more
205
+ [ISO 4217](http://www.currency-iso.org/en/shared/amendments/iso-4217-amendment.html) for more
206
206
  information. You can find the exponent (as a `Float`) by
207
207
 
208
208
  ``` ruby
@@ -367,18 +367,19 @@ Money.disallow_currency_conversion!
367
367
  The following is a list of Money.gem compatible currency exchange rate
368
368
  implementations.
369
369
 
370
- - [eu_central_bank](http://github.com/RubyMoney/eu_central_bank)
371
- - [google_currency](http://github.com/RubyMoney/google_currency)
370
+ - [eu_central_bank](https://github.com/RubyMoney/eu_central_bank)
371
+ - [google_currency](https://github.com/RubyMoney/google_currency)
372
372
  - [money-json-rates](https://github.com/askuratovsky/money-json-rates)
373
- - [nordea](https://github.com/k33l0r/nordea)
373
+ - [nordea](https://github.com/matiaskorhonen/nordea)
374
374
  - [nbrb_currency](https://github.com/slbug/nbrb_currency)
375
+ - [money-currencylayer-bank](https://github.com/phlegx/money-currencylayer-bank)
375
376
  - [money-open-exchange-rates](https://github.com/spk/money-open-exchange-rates)
376
377
  - [money-historical-bank](https://github.com/atwam/money-historical-bank)
377
378
  - [russian_central_bank](https://github.com/rmustafin/russian_central_bank)
378
379
 
379
380
  ## Ruby on Rails
380
381
 
381
- To integrate money in a Rails application use [money-rails](http://github.com/RubyMoney/money-rails).
382
+ To integrate money in a Rails application use [money-rails](https://github.com/RubyMoney/money-rails).
382
383
 
383
384
  For deprecated methods of integrating with Rails, check [the wiki](https://github.com/RubyMoney/money/wiki).
384
385
 
@@ -412,9 +413,26 @@ If you wish to disable this feature:
412
413
  Money.use_i18n = false
413
414
  ```
414
415
 
416
+ ### Troubleshooting
417
+
418
+ If you get a runtime error such as:
419
+
420
+ I18n::InvalidLocale: :en is not a valid locale
421
+
422
+ Set the following:
423
+ ``` ruby
424
+ I18n.enforce_available_locales = false
425
+ ```
426
+
415
427
  ## Formatting
416
428
 
417
- There are several formatting rules for when `Money#format` is called. For more information, check out the [formatting module](https://github.com/RubyMoney/money/blob/master/lib/money/money/formatting.rb).*
429
+ There are several formatting rules for when `Money#format` is called. For more information, check out the [formatting module source](https://github.com/RubyMoney/money/blob/master/lib/money/money/formatting.rb), or read the latest release's [rdoc version](http://www.rubydoc.info/gems/money/Money/Formatting).
430
+
431
+ If you wish to format money according to the EU's [Rules for expressing monetary units](http://publications.europa.eu/code/en/en-370303.htm#position) in either English, Irish, Latvian or Maltese:
432
+ ```ruby
433
+ m = Money.new('123', :gbp) # => #<Money fractional:123 currency:GBP>
434
+ m.format( symbol: m.currency.to_s + ' ') # => "GBP 1.23"
435
+ ```
418
436
 
419
437
  ## Migration Notes
420
438
 
data/Rakefile CHANGED
@@ -14,3 +14,4 @@ RSpec::Core::RakeTask.new(:spec) do |t|
14
14
  t.fail_on_error = false
15
15
  end
16
16
 
17
+ task default: :spec
@@ -7,7 +7,7 @@
7
7
  "alternate_symbols": ["DH", "Dhs"],
8
8
  "subunit": "Fils",
9
9
  "subunit_to_unit": 100,
10
- "symbol_first": true,
10
+ "symbol_first": false,
11
11
  "html_entity": "",
12
12
  "decimal_mark": ".",
13
13
  "thousands_separator": ",",
@@ -202,7 +202,7 @@
202
202
  "priority": 100,
203
203
  "iso_code": "BGN",
204
204
  "name": "Bulgarian Lev",
205
- "symbol": "лв",
205
+ "symbol": "лв.",
206
206
  "alternate_symbols": ["lev", "leva", "лев", "лева"],
207
207
  "subunit": "Stotinka",
208
208
  "subunit_to_unit": 100,
@@ -351,8 +351,24 @@
351
351
  "iso_numeric": "072",
352
352
  "smallest_denomination": 5
353
353
  },
354
- "byr": {
354
+ "byn": {
355
355
  "priority": 100,
356
+ "iso_code": "BYN",
357
+ "name": "Belarusian Ruble",
358
+ "symbol": "Br",
359
+ "disambiguate_symbol": "BYN",
360
+ "alternate_symbols": ["бел. руб.", "б.р.", "руб.", "р."],
361
+ "subunit": "Kapeyka",
362
+ "subunit_to_unit": 100,
363
+ "symbol_first": false,
364
+ "html_entity": "",
365
+ "decimal_mark": ",",
366
+ "thousands_separator": " ",
367
+ "iso_numeric": "933",
368
+ "smallest_denomination": 1
369
+ },
370
+ "byr": {
371
+ "priority": 50,
356
372
  "iso_code": "BYR",
357
373
  "name": "Belarusian Ruble",
358
374
  "symbol": "Br",
@@ -365,7 +381,7 @@
365
381
  "decimal_mark": ",",
366
382
  "thousands_separator": " ",
367
383
  "iso_numeric": "974",
368
- "smallest_denomination": 50
384
+ "smallest_denomination": 100
369
385
  },
370
386
  "bzd": {
371
387
  "priority": 100,
@@ -887,7 +903,7 @@
887
903
  "alternate_symbols": [],
888
904
  "subunit": "Lipa",
889
905
  "subunit_to_unit": 100,
890
- "symbol_first": true,
906
+ "symbol_first": false,
891
907
  "html_entity": "",
892
908
  "decimal_mark": ",",
893
909
  "thousands_separator": ".",
@@ -990,8 +1006,8 @@
990
1006
  "name": "Iranian Rial",
991
1007
  "symbol": "﷼",
992
1008
  "alternate_symbols": [],
993
- "subunit": "Dinar",
994
- "subunit_to_unit": 100,
1009
+ "subunit": null,
1010
+ "subunit_to_unit": 1,
995
1011
  "symbol_first": true,
996
1012
  "html_entity": "&#xFDFC;",
997
1013
  "decimal_mark": ".",
@@ -11,7 +11,8 @@
11
11
  "html_entity": "",
12
12
  "decimal_mark": ".",
13
13
  "thousands_separator": ",",
14
- "iso_numeric": ""
14
+ "iso_numeric": "",
15
+ "smallest_denomination": 1
15
16
  },
16
17
  "jep": {
17
18
  "priority": 100,
@@ -28,5 +29,37 @@
28
29
  "thousands_separator": ",",
29
30
  "iso_numeric": "",
30
31
  "smallest_denomination": 1
32
+ },
33
+ "ggp": {
34
+ "priority": 100,
35
+ "iso_code": "GGP",
36
+ "name": "Guernsey Pound",
37
+ "symbol": "£",
38
+ "disambiguate_symbol": "GGP",
39
+ "alternate_symbols": [],
40
+ "subunit": "Penny",
41
+ "subunit_to_unit": 100,
42
+ "symbol_first": true,
43
+ "html_entity": "&#x00A3;",
44
+ "decimal_mark": ".",
45
+ "thousands_separator": ",",
46
+ "iso_numeric": "",
47
+ "smallest_denomination": 1
48
+ },
49
+ "imp": {
50
+ "priority": 100,
51
+ "iso_code": "IMP",
52
+ "name": "Isle of Man Pound",
53
+ "symbol": "£",
54
+ "disambiguate_symbol": "IMP",
55
+ "alternate_symbols": ["M£"],
56
+ "subunit": "Penny",
57
+ "subunit_to_unit": 100,
58
+ "symbol_first": true,
59
+ "html_entity": "&#x00A3;",
60
+ "decimal_mark": ".",
61
+ "thousands_separator": ",",
62
+ "iso_numeric": "",
63
+ "smallest_denomination": 1
31
64
  }
32
65
  }
data/lib/money.rb CHANGED
@@ -2,5 +2,18 @@ require "bigdecimal"
2
2
  require "bigdecimal/util"
3
3
  require "set"
4
4
  require "i18n"
5
+ require "sixarm_ruby_unaccent"
5
6
  require "money/currency"
6
7
  require "money/money"
8
+
9
+ # Overwrites unaccent method of sixarm_ruby_unaccent.
10
+ class String
11
+ def unaccent
12
+ accentmap = ACCENTMAP
13
+ accentmap.delete("\u{0142}") # Delete ł symbol from ACCENTMAP used in PLN currency
14
+ accentmap.delete("\u{010D}") # Delete č symbol from ACCENTMAP used in CZK currency
15
+ accentmap.delete("\u{FDFC}") # Delete ﷼ symbol from ACCENTMAP used in IRR, SAR and YER currencies
16
+ accentmap.delete("\u{20A8}") # Delete ₨ symbol from ACCENTMAP used in INR, LKR, MUR, NPR, PKR and SCR currencies
17
+ split(//u).map {|c| accentmap[c] || c }.join("")
18
+ end
19
+ end
@@ -118,7 +118,7 @@ class Money
118
118
  # @example
119
119
  # same_currency?("usd", "USD") #=> true
120
120
  # same_currency?("usd", "EUR") #=> false
121
- # same_currency?("usd", Currency.new("USD") #=> true
121
+ # same_currency?("usd", Currency.new("USD")) #=> true
122
122
  # same_currency?("usd", "USD") #=> true
123
123
  def same_currency?(currency1, currency2)
124
124
  Currency.wrap(currency1) == Currency.wrap(currency2)
@@ -188,7 +188,7 @@ class Money
188
188
  key = curr.downcase.to_sym
189
189
  end
190
190
  existed = @table.delete(key)
191
- @stringified_keys = stringify_keys
191
+ @stringified_keys = stringify_keys if existed
192
192
  existed ? true : false
193
193
  end
194
194
 
@@ -232,9 +232,9 @@ class Money
232
232
  # @!attribute [r] decimal_mark
233
233
  # @return [String] The decimal mark, or character used to separate the
234
234
  # whole unit from the subunit.
235
- # @!attribute [r] The
236
- # @return [String] character used to separate thousands grouping of the
237
- # whole unit.
235
+ # @!attribute [r] thousands_separator
236
+ # @return [String] The character used to separate thousands grouping of
237
+ # the whole unit.
238
238
  # @!attribute [r] symbol_first
239
239
  # @return [Boolean] Should the currency symbol precede the amount, or
240
240
  # should it come after?