Skip to content

Commit

Permalink
Merge pull request #6 from kianmeng/misc-doc-changes
Browse files Browse the repository at this point in the history
Misc doc changes
  • Loading branch information
zloyrusskiy authored Dec 14, 2021
2 parents 5a230f9 + 81d5626 commit 80a327e
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# The directory Mix will write compiled artifacts to.
/_build
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover
/cover/

# The directory Mix downloads your dependencies sources to.
/deps
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc
# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
Expand All @@ -19,4 +19,8 @@ erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez

.DS_Store
# Ignore package tarball (built via "mix hex.build").
php_serializer-*.tar

# Temporary files, for example, from tests.
/tmp/
4 changes: 3 additions & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# The MIt License

Copyright (c) 2017 Alexander Fyodorov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -16,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@

# PhpSerializer

[![Module Version](https://img.shields.io/hexpm/v/php_serializer.svg)](https://hex.pm/packages/php_serializer)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/php_serializer/)
[![Total Download](https://img.shields.io/hexpm/dt/php_serializer.svg)](https://hex.pm/packages/php_serializer)
[![License](https://img.shields.io/hexpm/l/php_serializer.svg)](https://github.com/zloyrusskiy/php_serializer/blob/master/LICENSE.md)
[![Last Updated](https://img.shields.io/github/last-commit/zloyrusskiy/php_serializer.svg)](https://github.com/zloyrusskiy/php_serializer/commits/master)

PHP serialize/unserialize support for Elixir

## Installation

The package can be installed by adding `php_serializer` to your list of dependencies in `mix.exs`:
The package can be installed by adding `:php_serializer` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[{:php_serializer, "~> 2.0"}]
[
{:php_serializer, "~> 2.0"}
]
end
```

Expand Down Expand Up @@ -63,3 +70,10 @@ PhpSerializer.unserialize("i:0;i:34;", strict: true)
PhpSerializer.unserialize("i:0;i:34;", strict: true, with_excess: true)
# {:error, "excess characters found", "i:34;"}
```

## Copyright and License

Copyright (c) 2017 Alexander Fyodorov <[email protected]>

This work is free. You can redistribute it and/or modify it under the
terms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details.
10 changes: 6 additions & 4 deletions lib/php_serializer.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule PhpSerializer do
@doc ~S"""
Serialize Elixir data
Serialize Elixir data.
iex> PhpSerializer.serialize(123)
"i:123;"
Expand All @@ -10,6 +10,7 @@ defmodule PhpSerializer do
iex> PhpSerializer.serialize(%PhpSerializable.Class{class: "NameOfTheClass", data: "somedata"})
"C:14:\"NameOfTheClass\":8:{somedata}"
"""
@spec serialize(any) :: String.t()
def serialize(nil), do: "N;"
Expand Down Expand Up @@ -78,7 +79,7 @@ defmodule PhpSerializer do
end

@doc ~S"""
Unserialize PHP data
Unserialize PHP data.
iex> PhpSerializer.unserialize("a:3:{i:0;i:1;i:1;s:9:\"some_atom\";i:2;a:2:{i:1;s:1:\"a\";s:1:\"b\";i:2;}}")
{:ok, [{0, 1}, {1, "some_atom"}, {2, [{1, "a"}, {"b", 2}]}]}
Expand All @@ -87,12 +88,12 @@ defmodule PhpSerializer do
iex> List.keyfind(data, 1, 0)
{1, "some_atom"}
converted to maps:
Converted to maps:
iex> PhpSerializer.unserialize("a:3:{i:0;i:1;i:1;s:9:\"some_atom\";i:2;a:2:{i:1;s:1:\"a\";s:1:\"b\";i:2;}}", array_to_map: true)
{:ok, %{0 => 1, 1 => "some_atom", 2 => %{1 => "a", "b" => 2}}}
with excess data:
With excess data:
iex> PhpSerializer.unserialize("i:0;i:34;")
{:ok, 0}
Expand All @@ -105,6 +106,7 @@ defmodule PhpSerializer do
iex> PhpSerializer.unserialize("i:0;i:34;", strict: true, with_excess: true)
{:error, "excess characters found", "i:34;"}
"""
@type error_msg() :: String.t()
@type excess_data() :: String.t()
Expand Down
36 changes: 26 additions & 10 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
defmodule PhpSerializer.Mixfile do
use Mix.Project

@source_url "https://github.com/zloyrusskiy/php_serializer"
@version "2.0.0"

def project do
[
app: :php_serializer,
version: "2.0.0",
version: @version,
elixir: "~> 1.4",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
source_url: "https://github.com/zloyrusskiy/php_serializer",
description: description(),
package: package(),
deps: deps()
deps: deps(),
docs: docs(),
preferred_cli_env: [docs: :docs]
]
end

Expand All @@ -22,19 +25,32 @@ defmodule PhpSerializer.Mixfile do
defp deps do
[
{:dialyxir, "~> 1.0", only: :dev, runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
{:ex_doc, ">= 0.0.0", only: :docs, runtime: false}
]
end

defp description do
"PHP serialize/unserialize support for Elixir"
end

defp package do
[
description: "PHP serialize/unserialize support for Elixir",
maintainers: ["Alexander Fyodorov"],
licenses: ["MIT"],
links: %{"Github" => "https://github.com/zloyrusskiy/php_serializer"}
links: %{"Github" => @source_url}
]
end

defp docs do
[
extras: [
"LICENSE.md": [title: "License"],
"README.md": [title: "Overview"]
],
main: "readme",
source_url: @source_url,
# the git tagged version and library version is mismatch, "2.0" and
# "2.0.0", default to master branch.
source_ref: "master",
formatters: ["html"],
api_reference: false
]
end
end
9 changes: 5 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
%{
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
}

0 comments on commit 80a327e

Please sign in to comment.