Migrate to decimal v2

This commit is contained in:
FloatingGhost 2022-08-03 22:21:32 +01:00
parent 71f710e44e
commit c16453fb37
4 changed files with 11 additions and 8 deletions

View file

@ -22,22 +22,22 @@ defmodule RDF.XSD.Decimal do
@doc false
def min_inclusive_conform?(min_inclusive, value, _lexical) do
not (D.cmp(value, D.new(min_inclusive)) == :lt)
not (D.compare(value, D.new(min_inclusive)) == :lt)
end
@doc false
def max_inclusive_conform?(max_inclusive, value, _lexical) do
not (D.cmp(value, D.new(max_inclusive)) == :gt)
not (D.compare(value, D.new(max_inclusive)) == :gt)
end
@doc false
def min_exclusive_conform?(min_exclusive, value, _lexical) do
D.cmp(value, D.new(min_exclusive)) == :gt
D.compare(value, D.new(min_exclusive)) == :gt
end
@doc false
def max_exclusive_conform?(max_exclusive, value, _lexical) do
D.cmp(value, D.new(max_exclusive)) == :lt
D.compare(value, D.new(max_exclusive)) == :lt
end
@doc false
@ -61,7 +61,8 @@ defmodule RDF.XSD.Decimal do
@invalid_value
else
case D.parse(lexical) do
{:ok, decimal} -> elixir_mapping(decimal, opts)
{decimal, ""} -> elixir_mapping(decimal, opts)
{_, _} -> @invalid_value
:error -> @invalid_value
end
end
@ -74,6 +75,8 @@ defmodule RDF.XSD.Decimal do
def elixir_mapping(%D{coef: coef}, _) when coef in ~w[qNaN sNaN inf]a,
do: @invalid_value
def elixir_mapping(%D{coef: :NaN}, _), do: @invalid_value
def elixir_mapping(%D{} = decimal, _),
do: canonical_decimal(decimal)

View file

@ -83,7 +83,7 @@ defmodule RDF.XSD.Numeric do
def do_compare(_, _), do: nil
defp compare_decimal_value(%D{} = left, %D{} = right), do: D.cmp(left, right)
defp compare_decimal_value(%D{} = left, %D{} = right), do: D.compare(left, right)
defp compare_decimal_value(%D{} = left, right),
do: compare_decimal_value(left, new_decimal(right))

View file

@ -70,7 +70,7 @@ defmodule RDF.Mixfile do
defp deps do
[
{:decimal, "~> 1.5"},
{:decimal, "~> 2.0"},
{:protocol_ex, "~> 0.4.4"},
{:elixir_uuid, "~> 1.2", optional: true},
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},

View file

@ -3,7 +3,7 @@
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"certifi": {:hex, :certifi, "2.8.0", "d4fb0a6bb20b7c9c3643e22507e42f356ac090a1dcea9ab99e27e0376d695eba", [:rebar3], [], "hexpm", "6ac7efc1c6f8600b08d625292d4bbf584e14847ce1b6b5c44d983d273e1097ea"},
"credo": {:hex, :credo, "1.6.4", "ddd474afb6e8c240313f3a7b0d025cc3213f0d171879429bf8535d7021d9ad78", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "c28f910b61e1ff829bffa056ef7293a8db50e87f2c57a9b5c3f57eee124536b7"},
"decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.25", "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f", [:mix], [], "hexpm", "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e"},