From 4031779105c299e0f92f18d3e37e51f3abe55902 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Tue, 7 Mar 2017 09:25:40 -0600 Subject: [PATCH 01/13] Clean up elixir 1.4 compile warnings (#65) * Clean up elixir 1.4 compile warnings * Fix a couple more deprecation warnings --- lib/hedwig/adapter.ex | 10 ++++------ lib/hedwig/adapters/test.ex | 2 +- lib/mix/tasks/hedwig.gen.robot.ex | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/hedwig/adapter.ex b/lib/hedwig/adapter.ex index 32ec0c5..aa771ab 100644 --- a/lib/hedwig/adapter.ex +++ b/lib/hedwig/adapter.ex @@ -7,8 +7,6 @@ defmodule Hedwig.Adapter do `Hedwig.Message` struct and call `Hedwig.Robot.handle_message(robot, msg)`. """ - use Behaviour - @doc false defmacro __using__(_opts) do quote do @@ -57,7 +55,7 @@ defmodule Hedwig.Adapter do @doc false def start_link(module, opts) do - GenServer.start_link(module, {self, opts}) + GenServer.start_link(module, {self(), opts}) end @type robot :: pid @@ -65,7 +63,7 @@ defmodule Hedwig.Adapter do @type opts :: any @type msg :: Hedwig.Message.t - defcallback send(pid, msg) :: term - defcallback reply(pid, msg) :: term - defcallback emote(pid, msg) :: term + @callback send(pid, msg) :: term + @callback reply(pid, msg) :: term + @callback emote(pid, msg) :: term end diff --git a/lib/hedwig/adapters/test.ex b/lib/hedwig/adapters/test.ex index d8fd504..e51b87a 100644 --- a/lib/hedwig/adapters/test.ex +++ b/lib/hedwig/adapters/test.ex @@ -4,7 +4,7 @@ defmodule Hedwig.Adapters.Test do use Hedwig.Adapter def init({robot, opts}) do - GenServer.cast(self, :after_init) + GenServer.cast(self(), :after_init) {:ok, %{conn: nil, opts: opts, robot: robot}} end diff --git a/lib/mix/tasks/hedwig.gen.robot.ex b/lib/mix/tasks/hedwig.gen.robot.ex index 17d4bc7..5b21426 100644 --- a/lib/mix/tasks/hedwig.gen.robot.ex +++ b/lib/mix/tasks/hedwig.gen.robot.ex @@ -45,11 +45,11 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do """] aka = opts[:aka] || "/" - name = opts[:name] || prompt_for_name + name = opts[:name] || prompt_for_name() robot = opts[:robot] || default_robot(app) adapter = get_adapter_module(deps) - underscored = Mix.Utils.underscore(robot) + underscored = Macro.underscore(robot) file = Path.join("lib", underscored) <> ".ex" robot = Module.concat([robot]) @@ -79,7 +79,7 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do defp default_robot(app) do case Application.get_env(app, :app_namespace, app) do - ^app -> app |> to_string |> Mix.Utils.camelize + ^app -> app |> to_string |> Macro.camelize mod -> mod |> inspect end |> Module.concat(Robot) end @@ -87,7 +87,7 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do defp available_adapters(deps) do deps |> all_modules - |> Kernel.++(hedwig_modules) + |> Kernel.++(hedwig_modules()) |> Enum.uniq |> Enum.filter(&implements_adapter?/1) |> Enum.with_index From bc8dfab94b95b14d56a9dcf133b5a19ace49c911 Mon Sep 17 00:00:00 2001 From: Fredy M Date: Thu, 22 Jun 2017 10:47:01 -0500 Subject: [PATCH 02/13] Update README.md (#68) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0de211..a93dc79 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ pid = :global.whereis_name("alfred") # Create a Hedwig message msg = %Hedwig.Message{ type: "groupchat", - room: "my_room@example.com" + room: "my_room@example.com", text: "hello world" } From 3817edb3d4513068da178794717a6a8085c72b87 Mon Sep 17 00:00:00 2001 From: Sonny Scroggin Date: Fri, 18 Aug 2017 22:50:39 -0500 Subject: [PATCH 03/13] update travis matrix (#72) --- .travis.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9199072..017a723 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,20 @@ language: elixir -elixir: - - 1.3.3 -otp_release: - - 19.1 +matrix: + include: + - otp_release: 18.3 + elixir: 1.3 + - otp_release: 19.3 + elixir: 1.3 + - otp_release: 18.3 + elixir: 1.4 + - otp_release: 19.3 + elixir: 1.4 + - otp_release: 20.0 + elixir: 1.4 + - otp_release: 19.3 + elixir: 1.5 + - otp_release: 20.0 + elixir: 1.5 sudo: false after_script: - MIX_ENV=test mix coveralls.travis From f95c96b4e4cee8bc07ec7ced50f3ff4fffaac456 Mon Sep 17 00:00:00 2001 From: doug schlenker Date: Tue, 22 Aug 2017 12:43:05 -0700 Subject: [PATCH 04/13] Fix Elixir 1.5 compile warnings (#71) * Fix Elixir 1.5 compile warnings Fixes the Elixir 1.5 compile warnings when running `mix hedwig.gen.robot` Added `*.DS_Store` to the .gitignore file as well to prevent accidental adding of macOS drive files. * Feedback from @scrogson Removed the `*.DS_Store` ignore --- .gitignore | 2 +- lib/hedwig/adapters/console/connection.ex | 2 +- lib/hedwig/adapters/console/reader.ex | 2 +- lib/hedwig/responder.ex | 2 +- lib/mix/tasks/hedwig.gen.robot.ex | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5559472..6dc0961 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ erl_crash.dump /mnesia /log /test/tmp -/cover +/cover \ No newline at end of file diff --git a/lib/hedwig/adapters/console/connection.ex b/lib/hedwig/adapters/console/connection.ex index a93068b..7340cbc 100644 --- a/lib/hedwig/adapters/console/connection.ex +++ b/lib/hedwig/adapters/console/connection.ex @@ -43,6 +43,6 @@ defmodule Hedwig.Adapters.Console.Connection do defp get_system_user do System.cmd("whoami", []) |> elem(0) - |> String.strip() + |> String.trim() end end diff --git a/lib/hedwig/adapters/console/reader.ex b/lib/hedwig/adapters/console/reader.ex index 53c42c7..768833b 100644 --- a/lib/hedwig/adapters/console/reader.ex +++ b/lib/hedwig/adapters/console/reader.ex @@ -31,7 +31,7 @@ defmodule Hedwig.Adapters.Console.Reader do end def handle_info(text, {owner, user}) when is_binary(text) do - Kernel.send(owner, {:message, String.strip(text)}) + Kernel.send(owner, {:message, String.trim(text)}) Process.sleep(200) GenServer.cast(self(), :get_io) diff --git a/lib/hedwig/responder.ex b/lib/hedwig/responder.ex index 16fab93..f4a1986 100644 --- a/lib/hedwig/responder.ex +++ b/lib/hedwig/responder.ex @@ -180,7 +180,7 @@ defmodule Hedwig.Responder do @doc false def usage(name) do import String - Enum.map(@usage, &(&1 |> strip |> replace("hedwig", name))) + Enum.map(@usage, &(&1 |> trim |> replace("hedwig", name))) end def init({aka, name, opts, robot}) do diff --git a/lib/mix/tasks/hedwig.gen.robot.ex b/lib/mix/tasks/hedwig.gen.robot.ex index 5b21426..7b0e2a1 100644 --- a/lib/mix/tasks/hedwig.gen.robot.ex +++ b/lib/mix/tasks/hedwig.gen.robot.ex @@ -137,7 +137,7 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do defp prompt_for_name do Mix.shell.prompt("What would you like to name your bot?:") - |> String.strip + |> String.trim end defp prompt_for_adapter(adapters) do From 6d396da79762c7effdb8529429ea8297dce8016b Mon Sep 17 00:00:00 2001 From: doug schlenker Date: Tue, 22 Aug 2017 12:43:48 -0700 Subject: [PATCH 05/13] Update excoveralls & ex_doc deps (#73) updating deps --- mix.exs | 4 ++-- mix.lock | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mix.exs b/mix.exs index aad0e30..c177490 100644 --- a/mix.exs +++ b/mix.exs @@ -38,8 +38,8 @@ defmodule Hedwig.Mixfile do end defp deps do - [{:excoveralls, "~> 0.5", only: :test}, - {:ex_doc, "~> 0.14", only: :dev}] + [{:excoveralls, "~> 0.7.2", only: :test}, + {:ex_doc, "~> 0.16.3", only: :dev}] end defp elixirc_paths(:test), do: ["lib", "test/support"] diff --git a/mix.lock b/mix.lock index 5b67aa5..55458f4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,11 +1,12 @@ -%{"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []}, - "earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []}, - "ex_doc": {:hex, :ex_doc, "0.14.3", "e61cec6cf9731d7d23d254266ab06ac1decbb7651c3d1568402ec535d387b6f7", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, - "excoveralls": {:hex, :excoveralls, "0.5.7", "5d26e4a7cdf08294217594a1b0643636accc2ad30e984d62f1d166f70629ff50", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]}, - "exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, optional: false]}]}, - "hackney": {:hex, :hackney, "1.6.3", "d489d7ca2d4323e307bedc4bfe684323a7bf773ecfd77938f3ee8074e488e140", [:mix, :rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]}, - "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [], []}, - "jsx": {:hex, :jsx, "2.8.0", "749bec6d205c694ae1786d62cea6cc45a390437e24835fd16d12d74f07097727", [:mix, :rebar], []}, +%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.7.2", "f69ede8c122ccd3b60afc775348a53fc8c39fe4278aee2f538f0d81cc5e7ff3a", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], []}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}} + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"}} From 9092cb3fcbb5d938e15b85cf28ad3ae251b202f6 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 8 Jan 2018 18:31:32 +0300 Subject: [PATCH 06/13] add credo check to travis config (#76) --- .credo.exs | 146 ++++++++++++++++++++++ .travis.yml | 1 + lib/hedwig/adapters/console/connection.ex | 3 +- lib/hedwig/responder/supervisor.ex | 2 + lib/hedwig/test/robot_case.ex | 1 + lib/hedwig/test/test_robot.ex | 2 + lib/mix/tasks/hedwig.gen.robot.ex | 11 +- mix.exs | 4 +- mix.lock | 4 +- 9 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 .credo.exs diff --git a/.credo.exs b/.credo.exs new file mode 100644 index 0000000..2738757 --- /dev/null +++ b/.credo.exs @@ -0,0 +1,146 @@ +# This file contains the configuration for Credo and you are probably reading +# this after creating it with `mix credo.gen.config`. +# +# If you find anything wrong or unclear in this file, please report an +# issue on GitHub: https://github.com/rrrene/credo/issues +# +%{ + # + # You can have as many configs as you like in the `configs:` field. + configs: [ + %{ + # + # Run any exec using `mix credo -C `. If no exec name is given + # "default" is used. + # + name: "default", + # + # These are the files included in the analysis: + files: %{ + # + # You can give explicit globs or simply directories. + # In the latter case `**/*.{ex,exs}` will be used. + # + included: ["lib/", "src/", "web/", "apps/"], + excluded: [~r"/_build/", ~r"/deps/"] + }, + # + # If you create your own checks, you must specify the source files for + # them here, so they can be loaded by Credo before running the analysis. + # + requires: [], + # + # If you want to enforce a style guide and need a more traditional linting + # experience, you can change `strict` to `true` below: + # + strict: false, + # + # If you want to use uncolored output by default, you can change `color` + # to `false` below: + # + color: true, + # + # You can customize the parameters of any check by adding a second element + # to the tuple. + # + # To disable a check put `false` as second element: + # + # {Credo.Check.Design.DuplicatedCode, false} + # + checks: [ + {Credo.Check.Consistency.ExceptionNames}, + {Credo.Check.Consistency.LineEndings}, + {Credo.Check.Consistency.ParameterPatternMatching}, + {Credo.Check.Consistency.SpaceAroundOperators}, + {Credo.Check.Consistency.SpaceInParentheses}, + {Credo.Check.Consistency.TabsOrSpaces}, + + # You can customize the priority of any check + # Priority values are: `low, normal, high, higher` + # + {Credo.Check.Design.AliasUsage, priority: :low}, + + # For some checks, you can also set other parameters + # + # If you don't want the `setup` and `test` macro calls in ExUnit tests + # or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just + # set the `excluded_macros` parameter to `[:schema, :setup, :test]`. + # + {Credo.Check.Design.DuplicatedCode, excluded_macros: []}, + + # You can also customize the exit_status of each check. + # If you don't want TODO comments to cause `mix credo` to fail, just + # set this value to 0 (zero). + # + {Credo.Check.Design.TagTODO, exit_status: 2}, + {Credo.Check.Design.TagFIXME}, + + {Credo.Check.Readability.FunctionNames}, + {Credo.Check.Readability.LargeNumbers}, + {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80}, + {Credo.Check.Readability.ModuleAttributeNames}, + {Credo.Check.Readability.ModuleDoc}, + {Credo.Check.Readability.ModuleNames}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs}, + {Credo.Check.Readability.ParenthesesInCondition}, + {Credo.Check.Readability.PredicateFunctionNames}, + {Credo.Check.Readability.PreferImplicitTry}, + {Credo.Check.Readability.RedundantBlankLines}, + {Credo.Check.Readability.StringSigils}, + {Credo.Check.Readability.TrailingBlankLine}, + {Credo.Check.Readability.TrailingWhiteSpace}, + {Credo.Check.Readability.VariableNames}, + {Credo.Check.Readability.Semicolons}, + {Credo.Check.Readability.SpaceAfterCommas}, + + {Credo.Check.Refactor.DoubleBooleanNegation}, + {Credo.Check.Refactor.CondStatements}, + {Credo.Check.Refactor.CyclomaticComplexity, false}, + {Credo.Check.Refactor.FunctionArity}, + {Credo.Check.Refactor.LongQuoteBlocks, false}, + {Credo.Check.Refactor.MatchInCondition}, + {Credo.Check.Refactor.NegatedConditionsInUnless}, + {Credo.Check.Refactor.NegatedConditionsWithElse}, + {Credo.Check.Refactor.Nesting}, + {Credo.Check.Refactor.PipeChainStart}, + {Credo.Check.Refactor.UnlessWithElse}, + + {Credo.Check.Warning.BoolOperationOnSameValues}, + {Credo.Check.Warning.ExpensiveEmptyEnumCheck}, + {Credo.Check.Warning.IExPry}, + {Credo.Check.Warning.IoInspect}, + {Credo.Check.Warning.LazyLogging}, + {Credo.Check.Warning.OperationOnSameValues}, + {Credo.Check.Warning.OperationWithConstantResult}, + {Credo.Check.Warning.UnusedEnumOperation}, + {Credo.Check.Warning.UnusedFileOperation}, + {Credo.Check.Warning.UnusedKeywordOperation}, + {Credo.Check.Warning.UnusedListOperation}, + {Credo.Check.Warning.UnusedPathOperation}, + {Credo.Check.Warning.UnusedRegexOperation}, + {Credo.Check.Warning.UnusedStringOperation}, + {Credo.Check.Warning.UnusedTupleOperation}, + {Credo.Check.Warning.RaiseInsideRescue}, + + # Controversial and experimental checks (opt-in, just remove `, false`) + # + {Credo.Check.Refactor.ABCSize, false}, + {Credo.Check.Refactor.AppendSingleItem, false}, + {Credo.Check.Refactor.VariableRebinding, false}, + {Credo.Check.Warning.MapGetUnsafePass, false}, + {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, + + # Deprecated checks (these will be deleted after a grace period) + # + {Credo.Check.Readability.Specs, false}, + {Credo.Check.Warning.NameRedeclarationByAssignment, false}, + {Credo.Check.Warning.NameRedeclarationByCase, false}, + {Credo.Check.Warning.NameRedeclarationByDef, false}, + {Credo.Check.Warning.NameRedeclarationByFn, false}, + + # Custom checks can be created using `mix credo.gen.check`. + # + ] + } + ] +} diff --git a/.travis.yml b/.travis.yml index 017a723..681ce9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,3 +18,4 @@ matrix: sudo: false after_script: - MIX_ENV=test mix coveralls.travis + - mix credo diff --git a/lib/hedwig/adapters/console/connection.ex b/lib/hedwig/adapters/console/connection.ex index 7340cbc..a39354c 100644 --- a/lib/hedwig/adapters/console/connection.ex +++ b/lib/hedwig/adapters/console/connection.ex @@ -41,7 +41,8 @@ defmodule Hedwig.Adapters.Console.Connection do end defp get_system_user do - System.cmd("whoami", []) + "whoami" + |> System.cmd([]) |> elem(0) |> String.trim() end diff --git a/lib/hedwig/responder/supervisor.ex b/lib/hedwig/responder/supervisor.ex index 6ce5005..0d1f6ea 100644 --- a/lib/hedwig/responder/supervisor.ex +++ b/lib/hedwig/responder/supervisor.ex @@ -1,4 +1,6 @@ defmodule Hedwig.Responder.Supervisor do + @moduledoc false + def start_link do import Supervisor.Spec, warn: false diff --git a/lib/hedwig/test/robot_case.ex b/lib/hedwig/test/robot_case.ex index 6138876..54ab0d8 100644 --- a/lib/hedwig/test/robot_case.ex +++ b/lib/hedwig/test/robot_case.ex @@ -1,6 +1,7 @@ defmodule Hedwig.RobotCase do use ExUnit.CaseTemplate + @moduledoc false @robot Hedwig.TestRobot @default_responders [{Hedwig.Responders.Help, []}, {TestResponder, []}] diff --git a/lib/hedwig/test/test_robot.ex b/lib/hedwig/test/test_robot.ex index 9a2cf3d..41b4f67 100644 --- a/lib/hedwig/test/test_robot.ex +++ b/lib/hedwig/test/test_robot.ex @@ -3,6 +3,8 @@ Code.ensure_compiled(Hedwig.Adapters.Test) defmodule Hedwig.TestRobot do use Hedwig.Robot, otp_app: :hedwig, adapter: Hedwig.Adapters.Test + @moduledoc false + def handle_connect(%{name: name} = state) do if :undefined == :global.whereis_name(name) do :yes = :global.register_name(name, self()) diff --git a/lib/mix/tasks/hedwig.gen.robot.ex b/lib/mix/tasks/hedwig.gen.robot.ex index 7b0e2a1..e2ea8e5 100644 --- a/lib/mix/tasks/hedwig.gen.robot.ex +++ b/lib/mix/tasks/hedwig.gen.robot.ex @@ -78,10 +78,16 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do end defp default_robot(app) do + app + |> alias_module + |> Module.concat(Robot) + end + + defp alias_module(app) do case Application.get_env(app, :app_namespace, app) do ^app -> app |> to_string |> Macro.camelize mod -> mod |> inspect - end |> Module.concat(Robot) + end end defp available_adapters(deps) do @@ -136,7 +142,8 @@ defmodule Mix.Tasks.Hedwig.Gen.Robot do end defp prompt_for_name do - Mix.shell.prompt("What would you like to name your bot?:") + "What would you like to name your bot?:" + |> Mix.shell.prompt |> String.trim end diff --git a/mix.exs b/mix.exs index c177490..fdb8eff 100644 --- a/mix.exs +++ b/mix.exs @@ -39,7 +39,9 @@ defmodule Hedwig.Mixfile do defp deps do [{:excoveralls, "~> 0.7.2", only: :test}, - {:ex_doc, "~> 0.16.3", only: :dev}] + {:ex_doc, "~> 0.16.3", only: :dev}, + {:credo, "~> 0.8", only: [:dev, :test], runtime: false} + ] end defp elixirc_paths(:test), do: ["lib", "test/support"] diff --git a/mix.lock b/mix.lock index 55458f4..71000d9 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,6 @@ -%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, +%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, "excoveralls": {:hex, :excoveralls, "0.7.2", "f69ede8c122ccd3b60afc775348a53fc8c39fe4278aee2f538f0d81cc5e7ff3a", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, From 550b8623bce6de418093811c1150df0d3317d295 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 8 Jan 2018 18:31:51 +0300 Subject: [PATCH 07/13] fix Hedwig.Adapter doc (#77) --- lib/hedwig/adapter.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hedwig/adapter.ex b/lib/hedwig/adapter.ex index aa771ab..27c9105 100644 --- a/lib/hedwig/adapter.ex +++ b/lib/hedwig/adapter.ex @@ -4,7 +4,7 @@ defmodule Hedwig.Adapter do An adapter is the interface to the service your bot runs on. To implement an adapter you will need to translate messages from the service to the - `Hedwig.Message` struct and call `Hedwig.Robot.handle_message(robot, msg)`. + `Hedwig.Message` struct and call `Hedwig.Robot.handle_in(robot, msg)`. """ @doc false From fafe89b8545750a8275ab26241bdeb4dc00d559e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 8 Jan 2018 18:32:02 +0300 Subject: [PATCH 08/13] fix Supervisor test name (#78) --- test/hedwig/robot/supervisor_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hedwig/robot/supervisor_test.exs b/test/hedwig/robot/supervisor_test.exs index 4da3512..a48442e 100644 --- a/test/hedwig/robot/supervisor_test.exs +++ b/test/hedwig/robot/supervisor_test.exs @@ -1,4 +1,4 @@ -defmodule Hedwig.ConfigTest do +defmodule Hedwig.Robot.SupervisorTest do use ExUnit.Case test "missing otp config" do From 05c8cffb2fe158250e85d191c79dbbcc4b6757bb Mon Sep 17 00:00:00 2001 From: Sonny Scroggin Date: Fri, 26 Jan 2018 14:21:08 -0600 Subject: [PATCH 09/13] bump version --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index fdb8eff..8da662f 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Hedwig.Mixfile do use Mix.Project - @version "1.0.0" + @version "1.0.1" def project do [app: :hedwig, From f4b9c5f30e137ad9c604e9ad2c616562cd82369f Mon Sep 17 00:00:00 2001 From: Sonny Scroggin Date: Fri, 26 Jan 2018 14:23:38 -0600 Subject: [PATCH 10/13] update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b32108e..c886201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.0.1 (2018-01-26) + +- Clean up warnings + ## v1.0.0 (2016-11-20) - Improvements From 91a342c283609663e9a09d4c8fef1446000de9b8 Mon Sep 17 00:00:00 2001 From: Sonny Scroggin Date: Fri, 26 Jan 2018 14:27:53 -0600 Subject: [PATCH 11/13] add elixir 1.6 to the mix --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 681ce9b..b22df55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,14 @@ matrix: elixir: 1.4 - otp_release: 19.3 elixir: 1.4 - - otp_release: 20.0 + - otp_release: 20.2 elixir: 1.4 - otp_release: 19.3 elixir: 1.5 - - otp_release: 20.0 + - otp_release: 20.2 elixir: 1.5 + - otp_release: 20.2 + elixir: 1.6 sudo: false after_script: - MIX_ENV=test mix coveralls.travis From 2f0a996675a9dd4f9a2ae410d6ce29ba435d2159 Mon Sep 17 00:00:00 2001 From: Sonny Scroggin Date: Fri, 26 Jan 2018 14:32:49 -0600 Subject: [PATCH 12/13] add parens around tmp_path --- test/support/file_helpers.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/file_helpers.ex b/test/support/file_helpers.ex index f1f3e6b..8e75c97 100644 --- a/test/support/file_helpers.ex +++ b/test/support/file_helpers.ex @@ -13,7 +13,7 @@ defmodule Hedwig.FileHelpers do tailored for this test case and test. """ defmacro in_tmp(fun) do - path = Path.join([tmp_path, "#{__CALLER__.module}", "#{elem(__CALLER__.function, 0)}"]) + path = Path.join([tmp_path(), "#{__CALLER__.module}", "#{elem(__CALLER__.function, 0)}"]) quote do path = unquote(path) File.rm_rf!(path) From d8c03c96f6ebf3a804b2a5984f5401223b630a13 Mon Sep 17 00:00:00 2001 From: GhostLLama2x <98776786+GhostLLama2x@users.noreply.github.com> Date: Sat, 3 Sep 2022 07:31:19 -0400 Subject: [PATCH 13/13] Update mix.exs ? --- mix.exs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mix.exs b/mix.exs index 8da662f..401059e 100644 --- a/mix.exs +++ b/mix.exs @@ -4,14 +4,17 @@ defmodule Hedwig.Mixfile do @version "1.0.1" def project do - [app: :hedwig, - version: @version, - elixir: "~> 1.2", - docs: docs(), + [app: :hedwig, :hedwig_telegram, + version: 1.0.1, + elixir: "~> 1.9", + build_embedded: Mix.env() == :prod, + start_permanent: Mix.env() == :prod,docs: docs(), deps: deps(), + docs: docs(), package: package(), name: "Hedwig", elixirc_paths: elixirc_paths(Mix.env), + do: ["lib","Mix.env", "test/support" ] description: "An adapter-based chat bot framework", source_url: "https://github.com/hedwig-im/hedwig", homepage_url: "https://github.com/hedwig-im/hedwig", @@ -41,19 +44,21 @@ defmodule Hedwig.Mixfile do [{:excoveralls, "~> 0.7.2", only: :test}, {:ex_doc, "~> 0.16.3", only: :dev}, {:credo, "~> 0.8", only: [:dev, :test], runtime: false} - ] + {:hedwig, "~> 1.0"}, + {:httpoison, "~> 0.10"}, + {:ex_doc, "~> 0.19", only: :dev}, + {:plug, "~> 1.2", optional: true}, + {:plug_cowboy, "~> 1.0"}, {:poison, "~> 3.0"}] end - defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] - defp package do [files: ["lib", "mix.exs", "README*", "LICENSE*"], maintainers: ["Sonny Scroggin"], licenses: ["MIT"], links: %{ - "GitHub" => "https://github.com/hedwig-im/hedwig", - "Docs" => "https://hexdocs.pm/hedwig" + "GitHub" => "https://github.com/hedwig-im/hedwig" + "GitHub" => "https://github.com/fusillicode/hedwig_telegram + "Docs" => "https://hexdocs.pm/hedwig }] end end