diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index dab1dd8..008305f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,30 @@ -/_build -/cover -/deps -/doc +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). *.ez + +# Ignore package tarball (built via "mix hex.build"). +operator-*.tar + +# Temporary files, for example, from tests. +/tmp/ + +# Misc. *.beam -.DS_Store +.-DS_Store diff --git a/LICENSE b/LICENSE.md similarity index 98% rename from LICENSE rename to LICENSE.md index f116208..5bd1ee0 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,4 +1,4 @@ -MIT License +# MIT License Copyright (c) 2016 Brooklyn Zelenka diff --git a/README.md b/README.md index 1a6db88..73336bd 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,22 @@ ![](https://raw.githubusercontent.com/expede/operator/master/brand/logo.png) -## Helpers for defining Elixir operators -[![Build Status](https://travis-ci.org/expede/operator.svg?branch=master)](https://travis-ci.org/expede/operator) [![Inline docs](http://inch-ci.org/github/expede/operator.svg?branch=master)](http://inch-ci.org/github/expede/operator) [![Deps Status](https://beta.hexfaktor.org/badge/all/github/expede/operator.svg)](https://beta.hexfaktor.org/github/expede/operator) [![hex.pm version](https://img.shields.io/hexpm/v/operator.svg?style=flat)](https://hex.pm/packages/operator) [![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](http://hexdocs.pm/operator/) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/expede/operator/blob/master/LICENSE) +[![Build Status](https://travis-ci.org/expede/operator.svg?branch=master)](https://travis-ci.org/expede/operator) +[![Module Version](https://img.shields.io/hexpm/v/operator.svg)](https://hex.pm/packages/operator) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/operator/) +[![Total Download](https://img.shields.io/hexpm/dt/operator.svg)](https://hex.pm/packages/operator) +[![License](https://img.shields.io/hexpm/l/operator.svg)](https://github.com/expede/operator/blob/master/LICENSE.md) +[![Last Updated](https://img.shields.io/github/last-commit/expede/operator.svg)](https://github.com/expede/operator/commits/master) -# Quick Start +Helpers for defining operator aliases for functions. + +## Quick Start ```elixir def deps do - [{:operator, "~> 0.2.0"}] + [ + {:operator, "~> 0.2.0"} + ] end defmodule MyModule do @@ -19,7 +27,7 @@ defmodule MyModule do end ``` -# Summary +## Summary Helpers for defining operator aliases for functions @@ -58,7 +66,7 @@ multiply(10, 2) ``` -# Operator Reference +## Operator Reference Elixir has a limited number of available operators. Many of them are already used by `Kernel` (the standard lib). You _can_ overwrite the standard definition @@ -117,3 +125,11 @@ Please refer to the table below. | `and` | | :heavy_check_mark: | | | `or` | | :heavy_check_mark: | | | `not` | | :heavy_check_mark: | | + + +## Copyright and License + +Copyright (c) 2016 Brooklyn Zelenka + +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. diff --git a/lib/operator.ex b/lib/operator.ex index cf06733..ea008b2 100644 --- a/lib/operator.ex +++ b/lib/operator.ex @@ -1,6 +1,6 @@ defmodule Operator do @moduledoc ~S""" - Helpers for defining operator aliases for functions + Helpers for defining operator aliases for functions. Operators can be hard to follow, especially with the limited number available in Elixir. Always having a named function backing an operator makes it easy to @@ -109,15 +109,16 @@ defmodule Operator do end @doc ~S""" - Workaround for `defdelegate` with variables in AST + Workaround for `defdelegate` with variables in AST. This is an ABSURD workaround. Just brute forcing the problem for now. Need to revisit, obviously. + Having difficulty interpolating `a ~> b` into `defdelegate` because unquoting tries to fully evaluate what looks like a function call The hope is that this function will be able to be removed completely, - hence isolating it here + hence isolating it here. """ # credo:disable-for-lines:71 Credo.Check.Refactor.CyclomaticComplexity defmacro dispatch_alias(fun_head, operator_symbol) do diff --git a/lib/operator/example.ex b/lib/operator/example.ex index f1a83db..28e4141 100644 --- a/lib/operator/example.ex +++ b/lib/operator/example.ex @@ -1,5 +1,5 @@ defmodule Operator.Example do - @moduledoc "Example for testing & teaching" + @moduledoc "Example for testing & teaching." use Operator diff --git a/mix.exs b/mix.exs index b6e7afb..ae1b93e 100644 --- a/mix.exs +++ b/mix.exs @@ -1,45 +1,43 @@ defmodule Operator.Mixfile do use Mix.Project + @source_url "https://github.com/expede/operator" + @version "0.2.1" + def project do [ - app: :operator, + app: :operator, name: "Operator", - description: "Helpers for defining operators", - version: "0.2.1", - elixir: "~> 1.11", - + version: @version, + elixir: "~> 1.11", package: [ maintainers: ["Brooklyn Zelenka"], - licenses: ["MIT"], - links: %{"GitHub" => "https://github.com/expede/operator"} + licenses: ["MIT"], + links: %{"GitHub" => @source_url} ], - - source_url: "https://github.com/expede/operator", - homepage_url: "https://github.com/expede/operator", - aliases: [ quality: [ "test", "credo --strict" ] ], - deps: [ - {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, - - {:dialyxir, "~> 1.1", only: :dev, runtime: false}, - {:earmark, "~> 1.4", only: :dev, runtime: false}, - {:ex_doc, "~> 0.23", only: :dev, runtime: false}, - - {:inch_ex, "~> 2.0", only: [:dev, :docs, :test], runtime: false} + {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, + {:dialyxir, "~> 1.1", only: :dev, runtime: false}, + {:earmark, "~> 1.4", only: :dev, runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, + {:inch_ex, "~> 2.0", only: [:dev, :docs, :test], runtime: false} ], - docs: [ - extras: ["README.md"], - logo: "./brand/logo.png", - main: "readme" + extras: [ + "LICENSE.md": [title: "License"], + "README.md": [title: "Overview"] + ], + main: "readme", + source_url: @source_url, + homepage_url: @source_url, + logo: "./brand/logo.png" ] ] end diff --git a/mix.lock b/mix.lock index b940bfd..229a831 100644 --- a/mix.lock +++ b/mix.lock @@ -3,13 +3,14 @@ "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [: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", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, "earmark": {:hex, :earmark, "1.4.14", "d04572cef64dd92726a97d92d714e38d6e130b024ea1b3f8a56e7de66ec04e50", [:mix], [{:earmark_parser, ">= 1.4.12", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "df338b8b1852ee425180b276c56c6941cb12220e04fe8718fe4acbdd35fd699f"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.17", "6f3c7e94170377ba45241d394389e800fb15adc5de51d0a3cd52ae766aafd63f", [:mix], [], "hexpm", "f93ac89c9feca61c165b264b5837bf82344d13bebc634cd575cb711e2e342023"}, "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.25.5", "ac3c5425a80b4b7c4dfecdf51fa9c23a44877124dd8ca34ee45ff608b1c6deb9", [: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", "688cfa538cdc146bc4291607764a7f1fcfa4cce8009ecd62de03b27197528350"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "inch_ex": {:hex, :inch_ex, "2.0.0", "24268a9284a1751f2ceda569cd978e1fa394c977c45c331bb52a405de544f4de", [:mix], [{:bunt, "~> 0.2", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "96d0ec5ecac8cf63142d02f16b7ab7152cf0f0f1a185a80161b758383c9399a8"}, "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "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.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "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.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, }