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 1093cc7..e35f487 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -19,6 +19,11 @@ erl_crash.dump # Also ignore archive artifacts (built via "mix archive.build"). *.ez -.elixir_ls/ +# Ignore package tarball (built via "mix hex.build"). +nested_filter-*.tar +# Temporary files, for example, from tests. +/tmp/ + +# Misc. .tool-versions diff --git a/LICENSE b/LICENSE.md similarity index 95% rename from LICENSE rename to LICENSE.md index 3eb0bed..785a89c 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +# MIT License -Copyright (c) [2017] [Bruce Park] +Copyright (c) 2017 Bruce Park Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 71e9dec..0bcb299 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # NestedFilter + ![Build](https://github.com/treble37/nested_filter/actions/workflows/nested_filter_ci.yml/badge.svg?branch=master) -[![Maintainability](https://api.codeclimate.com/v1/badges/ba239c585908a0aad2ac/maintainability)](https://codeclimate.com/github/treble37/nested_filter/maintainability) -[![Test Coverage](https://api.codeclimate.com/v1/badges/ba239c585908a0aad2ac/test_coverage)](https://codeclimate.com/github/treble37/nested_filter/test_coverage) -[![Coverage Status](https://coveralls.io/repos/github/treble37/nested_filter/badge.svg?branch=master)](https://coveralls.io/github/treble37/nested_filter?branch=master) -[![Hex.pm](https://img.shields.io/hexpm/v/nested_filter.svg)](https://hex.pm/packages/nested_filter) -[![Hex.pm Downloads](https://img.shields.io/hexpm/dt/nested_filter.svg)](https://hex.pm/packages/nested_filter) [![GitHub stars](https://img.shields.io/github/stars/treble37/nested_filter.svg)](https://github.com/treble37/nested_filter/stargazers) -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/treble37/nested_filter/master/LICENSE) +[![Module Version](https://img.shields.io/hexpm/v/nested_filter.svg)](https://hex.pm/packages/nested_filter) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/nested_filter/) +[![Total Download](https://img.shields.io/hexpm/dt/nested_filter.svg)](https://hex.pm/packages/nested_filter) +[![License](https://img.shields.io/hexpm/l/nested_filter.svg)](https://github.com/treble37/nested_filter/blob/master/LICENSE.md) +[![Last Updated](https://img.shields.io/github/last-commit/treble37/nested_filter.svg)](https://github.com/treble37/nested_filter/commits/master) ## The Problems @@ -34,12 +34,14 @@ NestedFilter drills down into a nested map and can do any of the following: ## Installation -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `nested_filter` to your list of dependencies in `mix.exs`: +The package can be installed by adding `:nested_filter` to your list of +dependencies in `mix.exs`: ```elixir def deps do - [{:nested_filter, "~> 1.2.2"}] + [ + {:nested_filter, "~> 1.2.2"} + ] end ``` @@ -89,3 +91,11 @@ assert NestedFilter.take_by_key(nested_map, [:b, :f]) == %{b: 1, f: 4 } ``` You can browse the tests for more usage examples. + + +## Copyright and License + +Copyright (c) 2017 Bruce Park + +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/nested_filter.ex b/lib/nested_filter.ex index e852a53..a2143c6 100644 --- a/lib/nested_filter.ex +++ b/lib/nested_filter.ex @@ -35,7 +35,7 @@ defmodule NestedFilter do @doc """ Take a (nested) map and filter out any keys with specified values in the - values_to_reject list. + `values_to_reject` list. """ @spec drop_by_value(%{any => any}, [any]) :: %{any => any} def drop_by_value(map, values_to_reject) when is_map(map) do @@ -44,7 +44,7 @@ defmodule NestedFilter do @doc """ Take a (nested) map and filter out any values with specified keys in the - keys_to_reject list. + `keys_to_reject` list. """ @spec drop_by_key(%{any => any}, [any]) :: %{any => any} def drop_by_key(map, keys_to_reject) when is_map(map) do @@ -68,7 +68,7 @@ defmodule NestedFilter do @doc """ Take a (nested) map and keep any values with specified keys in the - keys_to_select list. + `keys_to_select` list. """ @spec take_by_key(%{any => any}, [any]) :: %{any => any} def take_by_key(map, keys_to_select) when is_map(map) do diff --git a/mix.exs b/mix.exs index 3eeeb12..edbc425 100644 --- a/mix.exs +++ b/mix.exs @@ -1,59 +1,60 @@ defmodule NestedFilter.Mixfile do use Mix.Project + @source_url "https://github.com/treble37/nested_filter" + @version "1.2.2" + def project do [ app: :nested_filter, - version: "1.2.2", + version: @version, elixir: ">= 1.7.0", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], - description: description(), package: package(), - deps: deps() + deps: deps(), + docs: docs() ] end defp package do [ + description: "Drill down into a nested map and filter out keys " + <> "according to user specified values", files: ["lib", "mix.exs", "README*", "LICENSE*"], maintainers: ["Bruce Park"], licenses: ["MIT"], - links: %{"GitHub" => "https://github.com/treble37/nested_filter"} + links: %{ + "Changelog" => "https://hexdocs.pm/nested_filter/changelog.html", + "GitHub" => @source_url + } ] end - defp description do - """ - Drill down into a nested map and filter out keys according to user - specified values - """ - end - - # Configuration for the OTP application - # - # Type "mix help compile.app" for more information def application do - # Specify extra applications you'll use from Erlang/Elixir [extra_applications: [:logger]] end - # Dependencies can be Hex packages: - # - # {:my_dep, "~> 0.3.0"} - # - # Or git/path repositories: - # - # {:my_dep, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} - # - # Type "mix help deps" for more examples and options defp deps do [ - {:ex_doc, ">= 0.25.3", only: :dev}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:excoveralls, "~> 0.14.3", only: :test}, {:inch_ex, "~> 2.0.0", only: :docs}, {:credo, "~> 1.5.6", only: [:dev, :test]} ] end + + defp docs do + [ + extras: [ + "CHANGELOG.md": [], + "LICENSE.md": [title: "License"], + "README.md": [title: "Overview"] + ], + main: "readme", + source_url: @source_url, + formatters: ["html"] + ] + end end