money 6.8.0 → 6.8.1

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: f9d58da811f0d0d652d931abc3e027c4ac29f194
4
- data.tar.gz: eb6e25dcd90e03488b99913bcbedfed44b9370f3
3
+ metadata.gz: 15096aaaa1d4cd7f33b54b6763c3ee1fa35dbe30
4
+ data.tar.gz: e8907ecf8a282428ae9f9da1f183acc2d615e508
5
5
  SHA512:
6
- metadata.gz: 672f61e940c74f7818db5dcfb0b98cf23976a91e4cd7b40aeb20cfdb365f0ce4b591b94829c913fed9235e653bb3e9b454e9412a183e35df9ad5ff7ffa798197
7
- data.tar.gz: d3987957ca8e363e66dd909bc2489f94d47be3ba92e8aa2411470d5541390068ccc40d4df3d3cfda89359d5848ff83dbaaa31260a469e679260852a2584d6119
6
+ metadata.gz: 1ffc7e4ebb66b8fe190add39f17fa26536d7e5de5e2130fa7d56c01a624ec7886671fe6ad389dd1d661721e168fa738ade3a44671e8616b9dfb83131fb121a99
7
+ data.tar.gz: 76fbc5414418ccd7bce8e41c7baf481daf29574a641957274c20c830e338030795011a61f33d7c50daa9c3587f36eca1fdf1c51283535e719dd25ee3958a89a1
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.8.1
4
+ - Fixed issue with calling `format` on a frozen `Money` object
5
+
3
6
  ## 6.8.0
4
7
  - Ruby 2.4.0 support
5
8
  - Fixed UZS syntax
@@ -10,7 +10,8 @@ class Money
10
10
  # @example
11
11
  # Money.empty #=> #<Money @fractional=0>
12
12
  def empty(currency = default_currency)
13
- new(0, currency)
13
+ @empty ||= {}
14
+ @empty[currency] ||= new(0, currency).freeze
14
15
  end
15
16
  alias_method :zero, :empty
16
17
 
@@ -205,6 +205,10 @@ class Money
205
205
  rules = default_formatting_rules.merge(rules)
206
206
  rules = localize_formatting_rules(rules)
207
207
  rules = translate_formatting_rules(rules) if rules[:translate]
208
+
209
+ thousands_separator = self.thousands_separator
210
+ decimal_mark = self.decimal_mark
211
+
208
212
  escaped_decimal_mark = Regexp.escape(decimal_mark)
209
213
 
210
214
  if fractional == 0
@@ -288,11 +292,11 @@ class Money
288
292
  end
289
293
 
290
294
  def thousands_separator
291
- @thousands_separator ||= i18n_format_for(:thousands_separator, :delimiter, ",")
295
+ i18n_format_for(:thousands_separator, :delimiter, ",")
292
296
  end
293
297
 
294
298
  def decimal_mark
295
- @decimal_mark ||= i18n_format_for(:decimal_mark, :separator, ".")
299
+ i18n_format_for(:decimal_mark, :separator, ".")
296
300
  end
297
301
 
298
302
  alias_method :delimiter, :thousands_separator
@@ -1,3 +1,3 @@
1
1
  class Money
2
- VERSION = "6.8.0"
2
+ VERSION = "6.8.1"
3
3
  end
@@ -7,6 +7,18 @@ describe Money::Constructors do
7
7
  expect(Money.empty).to eq Money.new(0)
8
8
  end
9
9
 
10
+ it "memoizes the result" do
11
+ expect(Money.empty.object_id).to eq Money.empty.object_id
12
+ end
13
+
14
+ it "memoizes a result for each currency" do
15
+ expect(Money.empty(:cad).object_id).to eq Money.empty(:cad).object_id
16
+ end
17
+
18
+ it "doesn't allow money to be modified for a currency" do
19
+ expect(Money.empty).to be_frozen
20
+ end
21
+
10
22
  it "instantiates a subclass when inheritance is used" do
11
23
  special_money_class = Class.new(Money)
12
24
  expect(special_money_class.empty).to be_a special_money_class
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.8.0
4
+ version: 6.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n