1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-30 01:15:52 +00:00

Fix building with latest elixir.

This commit is contained in:
Vanilla I. Shu 2021-02-27 10:55:41 +00:00
parent 2d57b26db8
commit 2ff9f64c60
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=566688
4 changed files with 207 additions and 4 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= elixir-bson
PORTVERSION= 0.4.4
PORTREVISION= 1
CATEGORIES= devel
MAINTAINER= vanilla@FreeBSD.org
@ -9,8 +10,6 @@ COMMENT= BSON implementation in Elixir
LICENSE= MIT
IGNORE= does not build with Elixir 1.6
USES= elixir
USE_GITHUB= yes
GH_ACCOUNT= checkiz

View File

@ -0,0 +1,29 @@
--- lib/bson_decoder.ex.orig 2021-02-27 04:49:09 UTC
+++ lib/bson_decoder.ex
@@ -51,7 +51,7 @@ defmodule Bson.Decoder do
```
"""
- def elist_to_hashdict(elist), do: elist |> Enum.reduce %HashDict{}, fn({k, v}, h) -> HashDict.put(h, k, v) end
+ def elist_to_hashdict(elist), do: elist |> Enum.reduce(%HashDict{}, fn({k, v}, h) -> HashDict.put(h, k, v) end)
@doc """
Transform an elist to a Keyword
@@ -62,7 +62,7 @@ defmodule Bson.Decoder do
```
"""
- def elist_to_keyword(elist), do: elist |> Enum.map fn({k, v}) -> {String.to_atom(k), v} end
+ def elist_to_keyword(elist), do: elist |> Enum.map(fn({k, v}) -> {String.to_atom(k), v} end)
@doc """
Identity function
@@ -91,7 +91,7 @@ defmodule Bson.Decoder do
...> %{a: "r"},
...> %{a: ""},
...> %{a: 1, b: 5}
- ...> ] |> Enum.all? fn(term) -> assert term == term |> Bson.encode |> Bson.decode end
+ ...> ] |> Enum.all?(fn(term) -> assert term == term |> Bson.encode |> Bson.decode end)
true
iex> term = %{

View File

@ -0,0 +1,170 @@
--- lib/bson_encoder.ex.orig 2021-02-27 04:48:02 UTC
+++ lib/bson_encoder.ex
@@ -1,32 +1,33 @@
-defmodule Bson.Encoder do
- defprotocol Protocol do
- @moduledoc """
- `Bson.Encoder.Protocol` protocol defines Bson encoding according to Elxir terms and some Bson predefined structs (see `Bson`).
+defprotocol Bson.Encoder.Protocol do
+ @moduledoc """
+ `Bson.Encoder.Protocol` protocol defines Bson encoding according to Elxir terms and some Bson predefined structs (see `Bson`).
- List of the protocol implementations:
+ List of the protocol implementations:
- * `Map` - Encodes a map into a document
- * `HasDict` - Encodes a HashDict into a document
- * `Keyword` - Encodes a Keyword into a document
- * `List` - Encodes a list of key-alue pairs into a document otherwize encode list into array
- * `Integer` - Encodes integer in 32 or 64 bits
- * `Float` - Encodes float in 64 bits
- * `Atom` - Encodes special atom (`false`, `true`, `nil`,
- `:nan`, `:+inf`, `:-inf`, `MIN_KEY` and `MAX_KEY`) in appropriate format
- others in special type Symbol
- * `BitString` - as binary string
- * `Bson.Regex' - see specs
- * `Bson.ObjectId' - see specs
- * `Bson.JS' - see specs
- * `Bson.Bin' - see specs
- * `Bson.Timestamp ' - see specs
- """
+ * `Map` - Encodes a map into a document
+ * `HasDict` - Encodes a HashDict into a document
+ * `Keyword` - Encodes a Keyword into a document
+ * `List` - Encodes a list of key-alue pairs into a document otherwize encode list into array
+ * `Integer` - Encodes integer in 32 or 64 bits
+ * `Float` - Encodes float in 64 bits
+ * `Atom` - Encodes special atom (`false`, `true`, `nil`,
+ `:nan`, `:+inf`, `:-inf`, `MIN_KEY` and `MAX_KEY`) in appropriate format
+ others in special type Symbol
+ * `BitString` - as binary string
+ * `Bson.Regex' - see specs
+ * `Bson.ObjectId' - see specs
+ * `Bson.JS' - see specs
+ * `Bson.Bin' - see specs
+ * `Bson.Timestamp ' - see specs
+ """
- @doc """
- Returns a binary representing a term in Bson format
- """
- def encode(term)
- end
+ @doc """
+ Returns a binary representing a term in Bson format
+ """
+ def encode(term)
+end
+
+defmodule Bson.Encoder do
defmodule Error do
@moduledoc """
Container for error messages
@@ -56,7 +57,7 @@ defmodule Bson.Encoder do
end
end
- defimpl Protocol, for: Integer do
+ defimpl Bson.Encoder.Protocol, for: Integer do
@doc """
iex> Bson.Encoder.Protocol.encode(2)
{<<16>>, <<2, 0, 0, 0>>}
@@ -73,7 +74,7 @@ defmodule Bson.Encoder do
def encode(i), do: %Error{what: [Integer], term: i}
end
- defimpl Protocol, for: Float do
+ defimpl Bson.Encoder.Protocol, for: Float do
@doc """
iex> Bson.Encoder.Protocol.encode(1.1)
{<<1>>, <<154, 153, 153, 153, 153, 153, 241, 63>>}
@@ -81,7 +82,7 @@ defmodule Bson.Encoder do
def encode(f), do: {<<0x01>>, <<(f)::size(64)-float-little>>}
end
- defimpl Protocol, for: Atom do
+ defimpl Bson.Encoder.Protocol, for: Atom do
@doc """
iex> Bson.Encoder.Protocol.encode(true)
{<<8>>, <<1>>}
@@ -114,7 +115,7 @@ defmodule Bson.Encoder do
def encode(atom), do: {<<0x0e>>, (atom |> Atom.to_string |> Bson.Encoder.wrap_string)}
end
- defimpl Protocol, for: Bson.UTC do
+ defimpl Bson.Encoder.Protocol, for: Bson.UTC do
@doc """
iex> Bson.Encoder.Protocol.encode(Bson.UTC.from_now({1390, 324703, 518471}))
{<<9>>, <<30, 97, 207, 181, 67, 1, 0, 0>>}
@@ -123,7 +124,7 @@ defmodule Bson.Encoder do
def encode(utc), do: %Error{what: [Bson.UTC], term: utc}
end
- defimpl Protocol, for: Bson.Regex do
+ defimpl Bson.Encoder.Protocol, for: Bson.Regex do
@doc """
iex> Bson.Encoder.Protocol.encode(%Bson.Regex{pattern: "p", opts: "i"})
{<<11>>, ["p", <<0>>, "i", <<0>>]}
@@ -132,7 +133,7 @@ defmodule Bson.Encoder do
def encode(regex), do: %Error{what: [Bson.Regex], term: regex}
end
- defimpl Protocol, for: Bson.ObjectId do
+ defimpl Bson.Encoder.Protocol, for: Bson.ObjectId do
@doc """
iex> Bson.Encoder.Protocol.encode(%Bson.ObjectId{oid: <<0xFF>>})
{<<0x07>>, <<255>>}
@@ -144,7 +145,7 @@ defmodule Bson.Encoder do
def encode(oid), do: %Error{what: [Bson.ObjectId], term: oid}
end
- defimpl Protocol, for: Bson.JS do
+ defimpl Bson.Encoder.Protocol, for: Bson.JS do
@doc """
iex> Bson.Encoder.Protocol.encode(%Bson.JS{code: "1+1;"})
{<<13>>, [<<5, 0, 0, 0>>, "1+1;", <<0>>]}
@@ -166,7 +167,7 @@ defmodule Bson.Encoder do
defp js_ctx(jsctx), do: <<(byte_size(jsctx)+4)::32-little-signed, jsctx::binary>>
end
- defimpl Protocol, for: Bson.Bin do
+ defimpl Bson.Encoder.Protocol, for: Bson.Bin do
@doc """
iex> Bson.Encoder.Protocol.encode(%Bson.Bin{bin: "e", subtype: Bson.Bin.subtyx(:user)})
{<<5>>,[<<1, 0, 0, 0>>, 128, "e"]}
@@ -178,7 +179,7 @@ defmodule Bson.Encoder do
def encode(bin, subtype), do: %Error{what: [Bson.Bin], term: {bin, subtype}}
end
- defimpl Protocol, for: Bson.Timestamp do
+ defimpl Bson.Encoder.Protocol, for: Bson.Timestamp do
@doc """
iex> Bson.Encoder.Protocol.encode(%Bson.Timestamp{inc: 1, ts: 2})
{<<17>>,<<1, 0, 0, 0, 2, 0, 0, 0>>}
@@ -190,7 +191,7 @@ defmodule Bson.Encoder do
def encode(ts), do: %Error{what: [Bson.Timestamp], term: ts}
end
- defimpl Protocol, for: BitString do
+ defimpl Bson.Encoder.Protocol, for: BitString do
@doc """
iex> Bson.Encoder.Protocol.encode("a")
{<<2>>, [<<2, 0, 0, 0>>, "a", <<0>>]}
@@ -199,7 +200,7 @@ defmodule Bson.Encoder do
def encode(bits), do: %Error{what: [BitString], term: bits}
end
- defimpl Protocol, for: List do
+ defimpl Bson.Encoder.Protocol, for: List do
@doc """
iex> Bson.Encoder.Protocol.encode([])
{<<4>>,<<5, 0, 0, 0, 0>>}
@@ -241,7 +242,7 @@ defmodule Bson.Encoder do
end
end
- defimpl Protocol, for: [Map, HashDict, Keyword] do
+ defimpl Bson.Encoder.Protocol, for: [Map, HashDict, Keyword] do
@doc """
# Map
iex> Bson.Encoder.Protocol.encode(%{})

View File

@ -1,6 +1,6 @@
--- mix.exs.orig 2015-09-26 08:10:10 UTC
--- mix.exs.orig 2015-09-18 11:00:09 UTC
+++ mix.exs
@@ -5,7 +5,6 @@ defmodule Bson.Mixfile do
@@ -5,11 +5,10 @@ defmodule Bson.Mixfile do
[ app: :bson,
name: "bson",
version: "0.4.3",
@ -8,3 +8,8 @@
description: "BSON implementation for Elixir",
source_url: "https://github.com/checkiz/elixir-bson",
deps: deps(Mix.env),
- package: package,
+ package: package(),
docs: &docs/0 ]
end