From c9547def84f198d96417568e32b9ffb461d39d66 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Feb 2020 01:35:38 +0100 Subject: [PATCH 01/15] Add #copy_with helper method --- src/money/money.cr | 9 ++++++++- src/money/money/allocate.cr | 6 +++--- src/money/money/arithmetic.cr | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/money/money.cr b/src/money/money.cr index 4849326..0c0aebb 100644 --- a/src/money/money.cr +++ b/src/money/money.cr @@ -97,6 +97,13 @@ struct Money @bank = bank end + # Returns a new `Money` instance with same `currency` and `bank` + # properties set as in `self`. + protected def copy_with(**options) : Money + options = {currency: currency, bank: bank}.merge(options) + Money.new(**options) + end + # Returns hash value based on the `amount` and `currency` attributes. def_hash amount, currency @@ -163,6 +170,6 @@ struct Money # See `#nearest_cash_value`. def rounded_to_nearest_cash_value : Money - Money.new(nearest_cash_value, currency, bank) + copy_with(fractional: nearest_cash_value) end end diff --git a/src/money/money/allocate.cr b/src/money/money/allocate.cr index c460478..2a0cb61 100644 --- a/src/money/money/allocate.cr +++ b/src/money/money/allocate.cr @@ -8,8 +8,8 @@ struct Money def split(num : Int) : Array(Money) raise ArgumentError.new("Need at least one party") if num < 1 - low = Money.new(fractional // num, currency, bank) - high = Money.new(low.fractional + 1, currency, bank) + low = copy_with(fractional: fractional // num) + high = copy_with(fractional: low.fractional + 1) remainder = fractional % num @@ -47,7 +47,7 @@ struct Money amounts[i % size] += delta end amounts.map do |fractional| - Money.new(fractional.to_big_i, currency, bank) + copy_with(fractional: fractional.to_big_i) end end diff --git a/src/money/money/arithmetic.cr b/src/money/money/arithmetic.cr index 291e7ba..7031fe3 100644 --- a/src/money/money/arithmetic.cr +++ b/src/money/money/arithmetic.cr @@ -41,7 +41,7 @@ struct Money # Money.new(-100).abs # => Money(@amount=1) # ``` def abs : Money - Money.new(amount.abs, currency, bank) + copy_with(amount: amount.abs) end # Alias of `#abs`. @@ -59,7 +59,7 @@ struct Money # -Money.new(100) # => Money(@amount=-1) # ``` def - : Money - Money.new(-amount, currency, bank) + copy_with(amount: -amount) end # Returns a new `Money` object containing the sum of the two @@ -71,7 +71,7 @@ struct Money def +(other : Money) : Money return self if other.zero? with_same_currency(other) do |converted_other| - Money.new(amount + converted_other.amount, currency, bank) + copy_with(amount: amount + converted_other.amount) end end @@ -84,7 +84,7 @@ struct Money def -(other : Money) : Money return self if other.zero? with_same_currency(other) do |converted_other| - Money.new(amount - converted_other.amount, currency, bank) + copy_with(amount: amount - converted_other.amount) end end @@ -95,7 +95,7 @@ struct Money # Money.new(100) * 2 # => Money(@amount=2) # ``` def *(other : Number) : Money - Money.new(amount * other, currency, bank) + copy_with(amount: amount * other) end # Divides the monetary value with the given *other* `Number` and returns @@ -105,7 +105,7 @@ struct Money # Money.new(100) / 10 # => Money(@amount=0.1) # ``` def /(other : Number) : Money - Money.new(amount / other, currency, bank) + copy_with(amount: amount / other) end # Divides the monetary value with the given *other* `Money` object and @@ -130,14 +130,14 @@ struct Money def divmod(other : Money) : {BigInt, Money} with_same_currency(other) do |converted_other| quotient, remainder = fractional.divmod(converted_other.fractional) - {quotient, Money.new(remainder, currency, bank)} + {quotient, copy_with(fractional: remainder)} end end # ditto def divmod(other : Number) : {Money, Money} quotient, remainder = fractional.divmod(other.to_big_i) - {Money.new(quotient, currency, bank), Money.new(remainder, currency, bank)} + {copy_with(fractional: quotient), copy_with(fractional: remainder)} end # Equivalent to `#divmod(other)[1]`. @@ -164,7 +164,7 @@ struct Money if (amount < 0 && other < 0) || (amount > 0 && other > 0) modulo(other) else - modulo(other) - Money.new(other, currency, bank) + modulo(other) - copy_with(amount: other) end end @@ -174,7 +174,7 @@ struct Money # Money.new(10.1, "USD").round # => Money(@amount=10, @currency="USD") # ``` def round(precision : Int? = 0) : Money - Money.new(@amount.round(precision), currency, bank) + copy_with(amount: @amount.round(precision)) end end end From f142e24b90410a898da67f3b7f7b129430a5fe77 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Feb 2020 01:35:58 +0100 Subject: [PATCH 02/15] Fix buggy arg type restriction --- src/money/money/arithmetic.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/money/money/arithmetic.cr b/src/money/money/arithmetic.cr index 7031fe3..8bbb194 100644 --- a/src/money/money/arithmetic.cr +++ b/src/money/money/arithmetic.cr @@ -173,7 +173,7 @@ struct Money # ``` # Money.new(10.1, "USD").round # => Money(@amount=10, @currency="USD") # ``` - def round(precision : Int? = 0) : Money + def round(precision : Int = 0) : Money copy_with(amount: @amount.round(precision)) end end From 6687326d468762688fe5b3422cdf05ead87b7c93 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Feb 2020 01:37:01 +0100 Subject: [PATCH 03/15] Misc refactors --- src/money/bank/variable_exchange.cr | 2 +- src/money/currency.cr | 44 ++++++++++++++--------------- src/money/money.cr | 19 ++++--------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/money/bank/variable_exchange.cr b/src/money/bank/variable_exchange.cr index f6b2a75..c78845b 100644 --- a/src/money/bank/variable_exchange.cr +++ b/src/money/bank/variable_exchange.cr @@ -3,7 +3,7 @@ struct Money def exchange(from : Money, to : Currency) : Money rate = store[from.currency, to] fractional = calculate_fractional(from, to) - fractional = fractional * rate + fractional *= rate Money.new(fractional.to_big_i, to, self) end diff --git a/src/money/currency.cr b/src/money/currency.cr index 23a2e63..8a3c707 100644 --- a/src/money/currency.cr +++ b/src/money/currency.cr @@ -14,6 +14,25 @@ struct Money # List of known currencies. class_getter table : Hash(String, Currency) { load_currencies } + getter priority : Int32? + getter iso_numeric : UInt32? + getter code : String + getter name : String? + getter symbol : String? + getter alternate_symbols : Array(String)? + getter subunit : String? + getter subunit_to_unit : UInt64 + getter? symbol_first : Bool? + getter html_entity : String? + getter decimal_mark : String? + getter thousands_separator : String? + getter smallest_denomination : UInt32? + + # Currency ID, for time being lower-cased `#code`. + getter id : String { code.downcase } + + def_equals_and_hash id + def self.register(currency : Currency) table[currency.id] = currency end @@ -50,25 +69,6 @@ struct Money wrap?(value) || raise UnknownCurrencyError.new("Can't find currency: #{value}") end - getter priority : Int32? - getter iso_numeric : UInt32? - getter code : String - getter name : String? - getter symbol : String? - getter alternate_symbols : Array(String)? - getter subunit : String? - getter subunit_to_unit : UInt64 - getter? symbol_first : Bool? - getter html_entity : String? - getter decimal_mark : String? - getter thousands_separator : String? - getter smallest_denomination : UInt32? - - # Currency ID, for time being lower-cased `#code`. - getter id : String { code.downcase } - - def_equals_and_hash id - # Returns the relation between subunit and unit as a base 10 exponent. # # NOTE: MGA and MRU are exceptions and are rounded to 1. @@ -98,10 +98,8 @@ struct Money comparison = priority <=> other_priority return id <=> other.id if comparison == 0 comparison - when {nil, Int32} - 1 - when {Int32, nil} - -1 + when {Int32, nil} then -1 + when {nil, Int32} then 1 else id <=> other.id end diff --git a/src/money/money.cr b/src/money/money.cr index 0c0aebb..6297479 100644 --- a/src/money/money.cr +++ b/src/money/money.cr @@ -56,26 +56,26 @@ struct Money end # Creates a new `Money` object of value given as an *amount* - # of the given *currency*. + # of the given *currency* (as fractional if `Int`, or whole amount otherwise) # # ``` # Money.new # => Money(@amount=0 @currency="USD") - # Money.new(1.5) # => Money(@amount=1.5 @currency="USD") + # Money.new(1_50) # => Money(@amount=1.5 @currency="USD") + # Money.new(1.5, :usd) # => Money(@amount=1.5 @currency="USD") # Money.new(1.5.to_big_d, "USD") # => Money(@amount=1.5 @currency="USD") - # Money.new(3.to_big_r, "EUR") # => Money(@amount=3 @currency="EUR") # ``` def initialize(amount : Number = 0, currency = Money.default_currency) initialize(amount, currency, nil) end - # :ditto: + # :nodoc: def initialize(amount : BigDecimal | BigRational, currency, bank) @currency = Currency.wrap(currency) @amount = amount.to_big_d @bank = bank end - # :ditto: + # :nodoc: def initialize(amount : Float, currency, bank) unless amount.finite? raise ArgumentError.new "Must be initialized with a finite value" @@ -83,14 +83,7 @@ struct Money initialize(amount.to_big_d, currency) end - # Creates a new `Money` object of value given in the - # *fractional* unit of the given *currency*. - # - # ``` - # Money.new(100) # => Money(@amount=1 @currency="USD") - # Money.new(100, "USD") # => Money(@amount=1 @currency="USD") - # Money.new(100, "EUR") # => Money(@amount=1 @currency="EUR") - # ``` + # :nodoc: def initialize(fractional : Int, currency, bank) @currency = Currency.wrap(currency) @amount = fractional.to_big_d / @currency.subunit_to_unit From 083181aecf5a444b5c37b99562fc00f19347ecd6 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Feb 2020 01:48:25 +0100 Subject: [PATCH 04/15] Fix Money initializer to accept bank argument as well --- src/money/money.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/money/money.cr b/src/money/money.cr index 6297479..cff15a1 100644 --- a/src/money/money.cr +++ b/src/money/money.cr @@ -64,8 +64,8 @@ struct Money # Money.new(1.5, :usd) # => Money(@amount=1.5 @currency="USD") # Money.new(1.5.to_big_d, "USD") # => Money(@amount=1.5 @currency="USD") # ``` - def initialize(amount : Number = 0, currency = Money.default_currency) - initialize(amount, currency, nil) + def initialize(amount : Number = 0, currency = Money.default_currency, bank = nil) + initialize(amount, currency, bank) end # :nodoc: From 284c336f2c6be97233b55195b755b039e43921c8 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Feb 2020 02:06:22 +0100 Subject: [PATCH 05/15] Run CI checks against whole codebase --- .ameba.yml | 16 ++++++++++++++++ .travis.yml | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .ameba.yml diff --git a/.ameba.yml b/.ameba.yml new file mode 100644 index 0000000..b8cadd4 --- /dev/null +++ b/.ameba.yml @@ -0,0 +1,16 @@ +# This configuration file was generated by `ameba --gen-config` +# on 2020-02-16 01:09:31 UTC using Ameba version 0.11.0. +# The point is for the user to remove these configuration records +# one by one as the reported problems are removed from the code base. + +# Problems found: 8 +# Run `ameba --only Lint/ShadowingOuterLocalVar` for details +Lint/ShadowingOuterLocalVar: + Description: Disallows the usage of the same name as outer local variables for block + or proc arguments. + Enabled: true + Severity: Warning + Excluded: + - spec/bank/variable_exchange_spec.cr + - spec/money/exchange_spec.cr + - spec/money/arithmetic_spec.cr diff --git a/.travis.yml b/.travis.yml index 4b24a53..471288a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,5 @@ install: script: - crystal spec - - crystal tool format --check src spec - - bin/ameba src + - crystal tool format --check + - bin/ameba From e7fb7da1110c09ebee4062dacd3c68a8161bbda9 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Mon, 17 Feb 2020 22:17:55 +0100 Subject: [PATCH 06/15] Add mistakenly removed entity --- data/currencies/uzs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/currencies/uzs.json b/data/currencies/uzs.json index 8d8b651..ca4c0e5 100644 --- a/data/currencies/uzs.json +++ b/data/currencies/uzs.json @@ -4,6 +4,7 @@ "name": "Uzbekistan Som", "symbol": "so'm", "alternate_symbols": [ + "so‘m", "сўм", "сум", "s", From 6555caf83b3ac164c82191fbd659baa9a0047260 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Tue, 18 Feb 2020 15:53:12 +0100 Subject: [PATCH 07/15] Add type restrictions to `to_s` methods --- src/money/currency.cr | 2 +- src/money/currency/rate.cr | 2 +- src/money/money/formatting.cr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/money/currency.cr b/src/money/currency.cr index 8a3c707..77c6b62 100644 --- a/src/money/currency.cr +++ b/src/money/currency.cr @@ -117,7 +117,7 @@ struct Money # Money::Currency.find(:usd).to_s # => "USD" # Money::Currency.find(:eur).to_s # => "EUR" # ``` - def to_s(io) + def to_s(io : IO) : Nil io << code end end diff --git a/src/money/currency/rate.cr b/src/money/currency/rate.cr index 74fdb61..83020c5 100644 --- a/src/money/currency/rate.cr +++ b/src/money/currency/rate.cr @@ -22,7 +22,7 @@ class Money::Currency Money.new(@value, @to, bank) end - def to_s(io) + def to_s(io : IO) : Nil io << @from << " -> " << @to << ": " << to_big_d end end diff --git a/src/money/money/formatting.cr b/src/money/money/formatting.cr index 027cfe9..d816c7a 100644 --- a/src/money/money/formatting.cr +++ b/src/money/money/formatting.cr @@ -254,7 +254,7 @@ struct Money end # See `#format`. - def to_s(io) + def to_s(io : IO) : Nil io << format end end From 71a2647fe0ccc1bac5987dadd7f7499bc48607ae Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 19 Feb 2020 01:17:49 +0100 Subject: [PATCH 08/15] ditto -> :ditto: --- src/money/currency.cr | 2 +- src/money/currency/enumeration.cr | 4 ++-- src/money/currency/rate_store.cr | 2 +- src/money/money.cr | 2 +- src/money/money/allocate.cr | 2 +- src/money/money/arithmetic.cr | 2 +- src/money/money/formatting.cr | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/money/currency.cr b/src/money/currency.cr index 77c6b62..53ea428 100644 --- a/src/money/currency.cr +++ b/src/money/currency.cr @@ -64,7 +64,7 @@ struct Money end end - # ditto + # :ditto: def self.wrap(value : String | Symbol | Currency | Nil) : Currency wrap?(value) || raise UnknownCurrencyError.new("Can't find currency: #{value}") end diff --git a/src/money/currency/enumeration.cr b/src/money/currency/enumeration.cr index 1cee581..8e8eb57 100644 --- a/src/money/currency/enumeration.cr +++ b/src/money/currency/enumeration.cr @@ -14,7 +14,7 @@ struct Money table[key.to_s.downcase]? end - # ditto + # :ditto: def []?(key : String | Symbol) : Currency? find?(key) end @@ -30,7 +30,7 @@ struct Money table[key.to_s.downcase]? || raise UnknownCurrencyError.new("Can't find currency: #{key}") end - # ditto + # :ditto: def [](key : String | Symbol) : Currency find(key) end diff --git a/src/money/currency/rate_store.cr b/src/money/currency/rate_store.cr index 45797fa..2aa5acd 100644 --- a/src/money/currency/rate_store.cr +++ b/src/money/currency/rate_store.cr @@ -38,7 +38,7 @@ class Money::Currency transaction { get_rate?(from, to).try(&.to_big_d) } end - # ditto + # :ditto: def [](from, to) : BigDecimal from, to = Currency.wrap(from), Currency.wrap(to) self[from, to]? || raise UnknownRateError.new("No conversion rate known for #{from} -> #{to}") diff --git a/src/money/money.cr b/src/money/money.cr index cff15a1..93f2d78 100644 --- a/src/money/money.cr +++ b/src/money/money.cr @@ -25,7 +25,7 @@ struct Money # Sets the default currency for creating new `Money` object. class_property default_currency : Currency { Currency.find("USD") } - # ditto + # :ditto: def self.default_currency=(currency_code : String | Symbol) self.default_currency = Currency.find(currency_code) end diff --git a/src/money/money/allocate.cr b/src/money/money/allocate.cr index 2a0cb61..57389b4 100644 --- a/src/money/money/allocate.cr +++ b/src/money/money/allocate.cr @@ -51,7 +51,7 @@ struct Money end end - # ditto + # :ditto: def allocate(*splits : Number) : Array(Money) allocate(splits) end diff --git a/src/money/money/arithmetic.cr b/src/money/money/arithmetic.cr index 8bbb194..5837432 100644 --- a/src/money/money/arithmetic.cr +++ b/src/money/money/arithmetic.cr @@ -134,7 +134,7 @@ struct Money end end - # ditto + # :ditto: def divmod(other : Number) : {Money, Money} quotient, remainder = fractional.divmod(other.to_big_i) {copy_with(fractional: quotient), copy_with(fractional: remainder)} diff --git a/src/money/money/formatting.cr b/src/money/money/formatting.cr index d816c7a..bf199c8 100644 --- a/src/money/money/formatting.cr +++ b/src/money/money/formatting.cr @@ -248,7 +248,7 @@ struct Money formatted end - # ditto + # :ditto: def format(**options) : String format(options) end From 7062e0614dab2bee9b3fbaea3e65d7b41a944a79 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 10 Apr 2020 21:35:46 +0200 Subject: [PATCH 09/15] Define VERSION constant with help of `shards version` --- src/money/version.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/money/version.cr b/src/money/version.cr index 18f905c..899f587 100644 --- a/src/money/version.cr +++ b/src/money/version.cr @@ -1,3 +1,3 @@ struct Money - VERSION = "1.0.1" + VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }} end From dfb1bbbc583128d8909689995e8b83c39030be01 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 26 Feb 2020 01:24:34 +0100 Subject: [PATCH 10/15] Monkey-patch BigDecimal#to_json_object_key --- src/money/money/json.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/money/money/json.cr b/src/money/money/json.cr index 73a4580..52ab2e1 100644 --- a/src/money/money/json.cr +++ b/src/money/money/json.cr @@ -5,6 +5,10 @@ struct BigDecimal def to_json(json : JSON::Builder) json.string(to_s) end + + def to_json_object_key + to_s + end end struct Money From a810501f2affcbe08831b16f0b73b84c634e7b3a Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 26 Feb 2020 01:27:12 +0100 Subject: [PATCH 11/15] This and that --- src/money/money/arithmetic.cr | 2 -- src/money/money/json.cr | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/money/money/arithmetic.cr b/src/money/money/arithmetic.cr index 5837432..0a703b6 100644 --- a/src/money/money/arithmetic.cr +++ b/src/money/money/arithmetic.cr @@ -1,5 +1,3 @@ -require "big" - struct Money module Arithmetic # Returns `true` if the money amount is greater than 0, `false` otherwise. diff --git a/src/money/money/json.cr b/src/money/money/json.cr index 52ab2e1..c3a4813 100644 --- a/src/money/money/json.cr +++ b/src/money/money/json.cr @@ -1,9 +1,10 @@ require "big/json" require "json" +# https://github.com/crystal-lang/crystal/issues/7856 struct BigDecimal def to_json(json : JSON::Builder) - json.string(to_s) + json.string(self) end def to_json_object_key From c8d1365441aebadcfe3e2b965643d1428c5feeca Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 10 Apr 2020 21:35:05 +0200 Subject: [PATCH 12/15] Update ameba dependency --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 8d95d5b..90fc5ad 100644 --- a/shard.yml +++ b/shard.yml @@ -7,7 +7,7 @@ authors: development_dependencies: ameba: github: crystal-ameba/ameba - version: ~> 0.11.0 + version: ~> 0.12.0 crystal: 0.30.1 From e3fb3f2223b8505f29ce257a750e170748b00bcb Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 10 Apr 2020 21:36:41 +0200 Subject: [PATCH 13/15] Remove monkey-patch needed for Crystal < 0.34.0 --- shard.yml | 2 +- src/money.cr | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/shard.yml b/shard.yml index 90fc5ad..04324d0 100644 --- a/shard.yml +++ b/shard.yml @@ -9,6 +9,6 @@ development_dependencies: github: crystal-ameba/ameba version: ~> 0.12.0 -crystal: 0.30.1 +crystal: 0.34.0 license: MIT diff --git a/src/money.cr b/src/money.cr index 577a873..9825c23 100644 --- a/src/money.cr +++ b/src/money.cr @@ -1,18 +1,5 @@ require "big" -# See https://github.com/crystal-lang/crystal/issues/8789 -{% if compare_versions(Crystal::VERSION, "0.34.0") < 0 %} - struct BigDecimal - def in_scale(new_scale : UInt64) : BigDecimal - previous_def - end - - def ceil : BigDecimal - previous_def.in_scale(0) - end - end -{% end %} - struct Money end From c982569bedbdd8047656f03a56464c5a849a112c Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 10 Apr 2020 21:42:11 +0200 Subject: [PATCH 14/15] Move BigDecimal monkey-patch to its own file --- src/ext/big_decimal.cr | 10 ++++++++++ src/money/money/json.cr | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/ext/big_decimal.cr diff --git a/src/ext/big_decimal.cr b/src/ext/big_decimal.cr new file mode 100644 index 0000000..eab9224 --- /dev/null +++ b/src/ext/big_decimal.cr @@ -0,0 +1,10 @@ +# https://github.com/crystal-lang/crystal/issues/7856 +struct BigDecimal + def to_json(json : JSON::Builder) + json.string(self) + end + + def to_json_object_key + to_s + end +end diff --git a/src/money/money/json.cr b/src/money/money/json.cr index c3a4813..0f2f54d 100644 --- a/src/money/money/json.cr +++ b/src/money/money/json.cr @@ -1,16 +1,6 @@ require "big/json" require "json" - -# https://github.com/crystal-lang/crystal/issues/7856 -struct BigDecimal - def to_json(json : JSON::Builder) - json.string(self) - end - - def to_json_object_key - to_s - end -end +require "../../ext/big_decimal" struct Money JSON.mapping({ From b37392c468e7b90889962b997c5de28da5b3134a Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 10 Apr 2020 21:42:17 +0200 Subject: [PATCH 15/15] Bump version to 1.1.0 --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 04324d0..4212115 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: money -version: 1.0.1 +version: 1.1.0 authors: - Sijawusz Pur Rahnama