From a60717985c912a57a055f1bcc61e478721c41178 Mon Sep 17 00:00:00 2001 From: "Kian-Meng, Ang" Date: Sun, 19 Sep 2021 17:09:20 +0800 Subject: [PATCH] Misc doc changes Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the source of truth for this Elixir library and leverage on latest features of ExDoc. --- .gitignore | 8 +++++--- CHANGELOG.md | 13 +++++++++---- LICENSE => LICENSE.md | 4 ++-- README.md | 17 +++++++++++++++-- lib/bow/exec.ex | 4 ++-- lib/bow/uploader.ex | 6 +++--- mix.exs | 43 ++++++++++++++++++++++++------------------ mix.lock | 10 ++++++---- test/bow/exec_test.exs | 2 +- test/bow_test.exs | 2 +- 10 files changed, 69 insertions(+), 40 deletions(-) rename LICENSE => LICENSE.md (94%) diff --git a/.gitignore b/.gitignore index 7a4a10c..5fb489b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ # The directory Mix downloads your dependencies sources to. /deps/ -# Where 3rd-party dependencies like ExDoc output generated docs. +# Where third-party dependencies like ExDoc output generated docs. /doc/ # Ignore .fetch files in case you like to edit your project deps locally. @@ -19,6 +19,8 @@ erl_crash.dump # Also ignore archive artifacts (built via "mix archive.build"). *.ez -/tmp +# Ignore package tarball (built via "mix hex.build"). +bow-*.tar -.elixir_ls +# Temporary files, for example, from tests. +/tmp/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 10fb379..77f0d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,23 @@ # Changelog -# v0.3.3 +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.3.3 (2021-08-31) * Fix file extension detection -## v0.3.2 +## 0.3.2 (2020-06-03) * Typespecs improvements -## v0.3.1 +## 0.3.1 (2020-05-12) * Typespecs improvements -## v0.3.0 +## 0.3.0 (2020-05-06) * Upgraded tesla dependency * Added missing callbacks required by Ecto 3.2 to generated `Ecto.Type` modules diff --git a/LICENSE b/LICENSE.md similarity index 94% rename from LICENSE rename to LICENSE.md index 56dd790..c883655 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +# MIT License -Copyright (c) 2016-2017 Tymon Tobolski, Recruitee +Copyright (c) 2016 Tymon Tobolski, Recruitee 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 ea60fc6..d4f3f6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Bow -File uploads for Elixir +[![Module Version](https://img.shields.io/hexpm/v/bow.svg)](https://hex.pm/packages/bow) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/bow/) +[![Total Download](https://img.shields.io/hexpm/dt/bow.svg)](https://hex.pm/packages/bow) +[![License](https://img.shields.io/hexpm/l/bow.svg)](https://github.com/recruitee/bow/blob/master/LICENSE.md) +[![Last Updated](https://img.shields.io/github/last-commit/recruitee/bow.svg)](https://github.com/recruitee/bow/commits/master) + +File uploads for Elixir. ## Features @@ -53,7 +59,7 @@ defmodule AttachmentUploader do end - # keep the origianal file name + # keep the original file name def filename(file, :original), do: file.name # prepend "thumb_" for thumbnail @@ -227,3 +233,10 @@ fakes3 -r tmp/s3 -p 4567 # run tests mix test --only s3 ``` + +## Copyright and License + +Copyright (c) 2016 Tymon Tobolski, Recruitee + +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/bow/exec.ex b/lib/bow/exec.ex index 938e799..d2ab358 100644 --- a/lib/bow/exec.ex +++ b/lib/bow/exec.ex @@ -78,12 +78,12 @@ defmodule Bow.Exec do result end - defp wait_for_exit(pid, ospid, timout) do + defp wait_for_exit(pid, ospid, timeout) do receive do {:EXIT, ^pid, :normal} -> {:ok, receive_output(ospid)} {:EXIT, ^pid, {:exit_status, code}} -> {:error, code, receive_output(ospid)} after - timout -> + timeout -> :exec.stop_and_wait(pid, 2000) {:error, :timeout, receive_output(ospid)} end diff --git a/lib/bow/uploader.ex b/lib/bow/uploader.ex index dbccf00..da5ca0f 100644 --- a/lib/bow/uploader.ex +++ b/lib/bow/uploader.ex @@ -28,7 +28,7 @@ defmodule Bow.Uploader do end - # keep the origianal file name + # keep the original file name def filename(file, :original), do: file.name # prepend "thumb_" for thumbnail @@ -153,7 +153,7 @@ defmodule Bow.Uploader do Example defmodule MyImageUploader do - # keep the origianal file name + # keep the original file name def filename(file, :original), do: file.name # for :pdf version prefix with _pdf and add .pdf extension @@ -179,7 +179,7 @@ defmodule Bow.Uploader do # generate image thumbnail def transform(source, target, :thumb) do # Bow.Exec allows executing any system command replacing ${input} and ${output} - # with correct paths. It can also take :timeout option to prevent resource consumtion. + # with correct paths. It can also take :timeout option to prevent resource consumption. # Refer to Bow.Exec documentation for more details Bow.Exec.exec source, target, "convert ${input} -strip -gravity Center -resize 250x175^ -extent 250x175 ${output}" diff --git a/mix.exs b/mix.exs index f5f68de..4ce6eb1 100644 --- a/mix.exs +++ b/mix.exs @@ -1,24 +1,23 @@ defmodule Bow.Mixfile do use Mix.Project + @source_url "https://github.com/recruitee/bow" @version "0.3.3" def project do [ app: :bow, + name: "Bow", version: @version, elixir: "~> 1.3", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), - test_coverage: [tool: Coverex.Task], + docs: docs(), package: package(), dialyzer: dialyzer(), - - # Docs - name: "Bow", - docs: docs() + test_coverage: [tool: Coverex.Task] ] end @@ -26,13 +25,15 @@ defmodule Bow.Mixfile do [ applications: [:logger, :plug, :tesla] ++ applications(Mix.env()) ] - - # TODO: Uncomment wneh dropping support for elixir 1.3 - # [ - # extra_applications: [:logger] ++ applications(Mix.env) - # ] end + # TODO: Uncomment when we dropping support for elixir 1.3 + # def application do + # [ + # extra_applications: [:logger] ++ applications(Mix.env) + # ] + # end + defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] @@ -65,7 +66,7 @@ defmodule Bow.Mixfile do # testing & docs {:postgrex, ">= 0.0.0", only: :test}, {:coverex, "~> 1.4.10", only: :test}, - {:ex_doc, "~> 0.21", only: :dev}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:mix_test_watch, "~> 0.5.0", only: :dev}, {:dialyxir, "~> 1.0", only: :dev} ] @@ -78,23 +79,29 @@ defmodule Bow.Mixfile do ] end - defp package() do + defp package do [ description: "File uploads for Elixir.", - maintainers: [], + maintainers: ["Kacper Pucek"], licenses: ["MIT"], links: %{ - "Github" => "https://github.com/recruitee/bow" + "Changelog" => "https://hexdocs.pm/bow/changelog.html", + "GitHub" => @source_url } ] end - defp docs() do + defp docs do [ main: "readme", - extras: ["README.md"], - source_url: "https://github.com/recruitee/bow", - source_ref: @version + extras: [ + "CHANGELOG.md": [], + "LICENSE.md": [title: "License"], + "README.md": [title: "Overview"] + ], + source_url: @source_url, + source_ref: @version, + formatters: ["html"] ] end diff --git a/mix.lock b/mix.lock index 02cdaf6..cbf9efe 100644 --- a/mix.lock +++ b/mix.lock @@ -6,23 +6,25 @@ "decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm", "52694ef56e60108e5012f8af9673874c66ed58ac1c4fae9b5b7ded31786663f5"}, "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"}, "earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, "ecto": {:hex, :ecto, "3.2.5", "76c864b77948a479e18e69cc1d0f0f4ee7cced1148ffe6a093ff91eba644f0b5", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "01251d9b28081b7e0af02a1875f9b809b057f064754ca3b274949d5216ea6f5f"}, "ecto_sql": {:hex, :ecto_sql, "3.2.2", "d10845bc147b9f61ef485cbf0973c0a337237199bd9bd30dd9542db00aadc26b", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.2.0 or ~> 0.3.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4a68f58cd12f3df73ea37c253f9b957c81313e532e60191890f71066840c714e"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "erlexec": {:hex, :erlexec, "1.9.5", "5ac0f70fb43c298a60b65a3e1bcad58714b0b1f6cd0a70b1e116ff42e65f954c", [:rebar3], [], "hexpm", "92424b47d7b12cb02585e551981c8023f1ebe0435ed33ee9cafd2d191f191f02"}, "ex_aws": {:hex, :ex_aws, "2.1.3", "26b6f036f0127548706aade4a509978fc7c26bd5334b004fba9bfe2687a525df", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "0bdbe2aed9f326922fc5a6a80417e32f0c895f4b3b2b0b9676ebf23dd16c5da4"}, "ex_aws_s3": {:hex, :ex_aws_s3, "2.0.2", "c0258bbdfea55de4f98f0b2f0ca61fe402cc696f573815134beb1866e778f47b", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "0569f5b211b1a3b12b705fe2a9d0e237eb1360b9d76298028df2346cad13097a"}, - "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, + "ex_doc": {:hex, :ex_doc, "0.25.2", "4f1cae793c4d132e06674b282f1d9ea3bf409bcca027ddb2fe177c4eed6a253f", [: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", "5b0c172e87ac27f14dfd152d52a145238ec71a95efbf29849550278c58a393d6"}, "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm", "9a00246e8af58cdf465ae7c48fd6fd7ba2e43300413dfcc25447ecd3bf76f0c1"}, "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, - "makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "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_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm", "33dd09e615daab5668c15cc3a33829892728fdbed910ab0c0a0edb06b45fc54d"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm", "90501b4ad90268127d1765c678a07872c921aebc672bd5fe218b00400bfb51b0"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm", "c1c408c57a1e4c88c365b9aff1198c350e22b765dbb97a460e9e6bd9364c6194"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, diff --git a/test/bow/exec_test.exs b/test/bow/exec_test.exs index ff7aaa5..c5b9de2 100644 --- a/test/bow/exec_test.exs +++ b/test/bow/exec_test.exs @@ -30,7 +30,7 @@ defmodule Bow.ExecTest do assert reason[:exit_code] != 0 end - test "timout", %{source: source, target: target} do + test "timeout", %{source: source, target: target} do assert {:error, reason} = exec(source, target, ["test/scripts/sleep.sh", :input, :output], timeout: 500) diff --git a/test/bow_test.exs b/test/bow_test.exs index 5399ff2..49be7c2 100644 --- a/test/bow_test.exs +++ b/test/bow_test.exs @@ -26,7 +26,7 @@ defmodule BowTest do test "raise when no name nor path" do assert_raise Bow.Error, fn -> # typos are intentional - Bow.new(nmae: "cat.jpg", phat: "path/to/cat.jpg") + Bow.new(name: "cat.jpg", phat: "path/to/cat.jpg") end end