Support rebar3
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 3171909..0000000
--- a/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-APP=local
-
-DIALYZER_OPTS=-Werror_handling -Wrace_conditions -Wunmatched_returns
-
-all: compile xref eunit dialyze
-
-init:
-	@eval "if ! [ -f 'src/${APP}.app.src' ]; then ./rebar create-app appid=${APP}; fi"
-	@./rebar prepare-deps
-
-compile:
-	@./rebar -r compile skip_deps=true
-
-refresh:
-	@./rebar refresh-deps
-	@rm -f .dialyzer.plt
-
-xref:
-	@./rebar -r xref skip_deps=true
-
-clean:
-	@./rebar -r clean skip_deps=true
-	@rm -f .dialyzer.plt
-
-distclean:
-	@git clean -d -f -x
-
-eunit:
-	@./rebar -r eunit skip_deps=true
-
-edoc:
-	@./rebar -r doc skip_deps=true
-
-start: compile
-	@erl -pz ebin -eval 'erlang:display({start_app, $(APP), application:ensure_all_started($(APP))}).'
-
-.dialyzer.plt:
-	touch .dialyzer.plt
-	dialyzer --build_plt --plt .dialyzer.plt --apps erts \
-	$(shell erl -noshell -pa ebin -eval '{ok, _} = application:ensure_all_started($(APP)), lists:foreach(fun erlang:display/1, [Name || {Name, _, _} <- application:which_applications(), Name =/= $(APP)]), halt().')
-
-dialyze: compile .dialyzer.plt
-	dialyzer --plt .dialyzer.plt -r ebin $(DIALYZER_OPTS)
diff --git a/doc/local.md b/doc/local.md
deleted file mode 100644
index 7d3eaf8..0000000
--- a/doc/local.md
+++ /dev/null
@@ -1,285 +0,0 @@
-
-
-# Module local #
-* [Description](#description)
-* [Data Types](#types)
-* [Function Index](#index)
-* [Function Details](#functions)
-
-
-A Local Name Registration Facility.
-Copyright (c) 2014, Takeru Ohta <phjgt308@gmail.com>
-
-
-<a name="types"></a>
-
-## Data Types ##
-
-
-
-
-### <a name="type-name">name()</a> ###
-
-
-
-<pre><code>
-name() = {<a href="#type-name_server_name">name_server_name()</a>, <a href="#type-process_name">process_name()</a>}
-</code></pre>
-
-
-
-
-
-### <a name="type-name_server_name">name_server_name()</a> ###
-
-
-
-<pre><code>
-name_server_name() = atom()
-</code></pre>
-
-
-
-
-
-### <a name="type-otp_name">otp_name()</a> ###
-
-
-
-<pre><code>
-otp_name() = {local, Name::atom()} | {global, Name::term()} | {via, module(), Name::term()}
-</code></pre>
-
-
-
-
-
-### <a name="type-otp_ref">otp_ref()</a> ###
-
-
-
-<pre><code>
-otp_ref() = (Name::atom()) | {Name::atom(), node()} | {global, Name::term()} | {via, module(), Name::term()} | pid()
-</code></pre>
-
-
-
-
-
-### <a name="type-process_name">process_name()</a> ###
-
-
-
-<pre><code>
-process_name() = term()
-</code></pre>
-
-
-<a name="index"></a>
-
-## Function Index ##
-
-
-<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#name_server_child_spec-1">name_server_child_spec/1</a></td><td>Equivalent to <a href="#name_server_child_spec-3"><tt>name_server_child_spec(Name, Name, 5000)</tt></a>.</td></tr><tr><td valign="top"><a href="#name_server_child_spec-3">name_server_child_spec/3</a></td><td>Returns the child spec for a local name server that is used in embedded mode.</td></tr><tr><td valign="top"><a href="#otp_name-1">otp_name/1</a></td><td>Returns OTP compatible name.</td></tr><tr><td valign="top"><a href="#register_name-2">register_name/2</a></td><td>Locally assocates the name <code>Name</code> with a pid <code>Pid</code>.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Sends the message <code>Msg</code> to the pid locally registered as <code>Name</code></td></tr><tr><td valign="top"><a href="#start_name_server-1">start_name_server/1</a></td><td>Starts a name server process.</td></tr><tr><td valign="top"><a href="#stop_name_server-1">stop_name_server/1</a></td><td>Stops the name server <code>ServerName</code></td></tr><tr><td valign="top"><a href="#unregister_name-1">unregister_name/1</a></td><td>Removes the locally registered name <code>Name</code></td></tr><tr><td valign="top"><a href="#whereis_name-1">whereis_name/1</a></td><td>Returns the pid with the locally registered name <code>Name</code></td></tr><tr><td valign="top"><a href="#which_name_servers-0">which_name_servers/0</a></td><td>Returns a list of running name server.</td></tr><tr><td valign="top"><a href="#which_processes-1">which_processes/1</a></td><td>Returns a list of registered process.</td></tr><tr><td valign="top"><a href="#which_processes-2">which_processes/2</a></td><td>Returns a list of registered process that has a name which matches the pattern <code>Pattern</code></td></tr></table>
-
-
-<a name="functions"></a>
-
-## Function Details ##
-
-<a name="name_server_child_spec-1"></a>
-
-### name_server_child_spec/1 ###
-
-
-<pre><code>
-name_server_child_spec(Name::<a href="#type-name_server_name">name_server_name()</a>) -&gt; <a href="supervisor.md#type-child_spec">supervisor:child_spec()</a>
-</code></pre>
-
-<br></br>
-
-
-Equivalent to [`name_server_child_spec(Name, Name, 5000)`](#name_server_child_spec-3).
-<a name="name_server_child_spec-3"></a>
-
-### name_server_child_spec/3 ###
-
-
-<pre><code>
-name_server_child_spec(ChildId, ServerName, Shutdown) -&gt; ChildSpec
-</code></pre>
-
-<ul class="definitions"><li><code>ChildId = <a href="supervisor.md#type-child_id">supervisor:child_id()</a></code></li><li><code>ServerName = <a href="#type-name_server_name">name_server_name()</a></code></li><li><code>Shutdown = <a href="supervisor.md#type-shutdown">supervisor:shutdown()</a></code></li><li><code>ChildSpec = <a href="supervisor.md#type-child_spec">supervisor:child_spec()</a></code></li></ul>
-
-
-Returns the child spec for a local name server that is used in embedded mode.
-
-
-To embed a local name server in your application, you can simply add `ChildSpec` to your supervision tree.
-<a name="otp_name-1"></a>
-
-### otp_name/1 ###
-
-
-<pre><code>
-otp_name(Name::<a href="#type-name">name()</a>) -&gt; <a href="#type-otp_name">otp_name()</a>
-</code></pre>
-
-<br></br>
-
-
-Returns OTP compatible name
-<a name="register_name-2"></a>
-
-### register_name/2 ###
-
-
-<pre><code>
-register_name(Name::<a href="#type-name">name()</a>, Pid::pid()) -&gt; yes | no
-</code></pre>
-
-<br></br>
-
-
-
-Locally assocates the name `Name` with a pid `Pid`.
-
-
-
-Let `NameServer` is `element(1, Name)`, the registered name is limited to the name server `NameServer` scope.
-
-
-
-Assumes that the name server is already started, crashes otherwise.
-
-
-The function returns `yes` if successful, `no` if it failes.
-For example, `no` is returned if an attempt is made to register an already registered process or
-to register a process with a name that is already in use.
-<a name="send-2"></a>
-
-### send/2 ###
-
-
-<pre><code>
-send(Name::<a href="#type-name">name()</a>, Msg::term()) -&gt; pid()
-</code></pre>
-
-<br></br>
-
-
-
-Sends the message `Msg` to the pid locally registered as `Name`
-
-
-Failure: If `Name` is not a locally registered name, the calling function will exit with reason `{badarg, {Name, Msg}}`
-<a name="start_name_server-1"></a>
-
-### start_name_server/1 ###
-
-
-<pre><code>
-start_name_server(ServerName::<a href="#type-name_server_name">name_server_name()</a>) -&gt; ok | {error, Reason}
-</code></pre>
-
-<ul class="definitions"><li><code>Reason = already_present</code></li></ul>
-
-
-Starts a name server process
-
-
-
-The process is registered locally as `ServerName` using `register/2`.
-
-
-
-If the process is successfully started the function returns `ok`.
-
-
-If there already exists a process with the specified `ServerName` the function returnes `{error, already_present}`.
-<a name="stop_name_server-1"></a>
-
-### stop_name_server/1 ###
-
-
-<pre><code>
-stop_name_server(ServerName::<a href="#type-name_server_name">name_server_name()</a>) -&gt; ok | {error, Reason}
-</code></pre>
-
-<ul class="definitions"><li><code>Reason = not_found</code></li></ul>
-
-
-Stops the name server `ServerName`
-
-
-If successful, the function returns `ok`.
-If the name server identified by `ServerName` does not exist, the function returns `{error, not_found}`.
-<a name="unregister_name-1"></a>
-
-### unregister_name/1 ###
-
-
-<pre><code>
-unregister_name(Name::<a href="#type-name">name()</a>) -&gt; ok
-</code></pre>
-
-<br></br>
-
-
-Removes the locally registered name `Name`
-<a name="whereis_name-1"></a>
-
-### whereis_name/1 ###
-
-
-<pre><code>
-whereis_name(Name::<a href="#type-name">name()</a>) -&gt; pid() | undefined
-</code></pre>
-
-<br></br>
-
-
-
-Returns the pid with the locally registered name `Name`
-
-
-Returns `undefined` if the name is not locally registered.
-<a name="which_name_servers-0"></a>
-
-### which_name_servers/0 ###
-
-
-<pre><code>
-which_name_servers() -&gt; [<a href="#type-name_server_name">name_server_name()</a>]
-</code></pre>
-
-<br></br>
-
-
-Returns a list of running name server
-<a name="which_processes-1"></a>
-
-### which_processes/1 ###
-
-
-<pre><code>
-which_processes(NameServer::<a href="#type-name_server_name">name_server_name()</a>) -&gt; [{<a href="#type-process_name">process_name()</a>, pid()}]
-</code></pre>
-
-<br></br>
-
-
-Returns a list of registered process
-<a name="which_processes-2"></a>
-
-### which_processes/2 ###
-
-
-<pre><code>
-which_processes(NameServer::<a href="#type-name_server_name">name_server_name()</a>, Pattern::<a href="ets.md#type-match_pattern">ets:match_pattern()</a>) -&gt; [{<a href="#type-process_name">process_name()</a>, pid()}]
-</code></pre>
-
-<br></br>
-
-
-Returns a list of registered process that has a name which matches the pattern `Pattern`
diff --git a/rebar b/rebar
deleted file mode 100755
index 1f34128..0000000
--- a/rebar
+++ /dev/null
Binary files differ
diff --git a/rebar.config b/rebar.config
index 8c5a97e..cac510a 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,10 +1,9 @@
 %% vim: set ft=erlang : -*- erlang -*-
-{require_min_otp_vsn, "R16B03"}.
-
 {erl_opts, [
             warnings_as_errors,
             warn_export_all,
-            warn_untyped_record
+            warn_untyped_record,
+            debug_info
            ]}.
 
 {xref_checks, [fail_on_warning, undefined_function_calls]}.
@@ -14,7 +13,6 @@
 {cover_enabled, true}.
 
 {edoc_opts, [
-             %% {doclet, edown_doclet},
              {dialyzer_specs, all},
              {report_missing_type, true},
              {report_type_mismatch, true},
@@ -24,7 +22,15 @@
 
 {validate_app_modules, true}.
 
+{shell, [{apps, [local]}]}.
+
+{plugins, [rebar_covertool]}.
+
+{dialyzer,
+ [
+  {warnings, [error_handling, race_conditions, unmatched_returns, unknown, no_improper_lists]}
+ ]}.
+
 {deps,
   [
-   %% {edown, ".*", {git, "git://github.com/sile/edown.git", {tag, "0.3.2"}}}
   ]}.
diff --git a/rebar.config.script b/rebar.config.script
deleted file mode 100644
index fa7d969..0000000
--- a/rebar.config.script
+++ /dev/null
@@ -1,8 +0,0 @@
-%% vim: set ft=erlang : -*- erlang -*-
-
-case erlang:system_info(version) < "6" of
-    false -> CONFIG;
-    true  ->
-        ErlOpts = proplists:get_value(erl_opts, CONFIG, []) ++ [{d, 'LOCAL_BEFORE_OTP17'}],
-        proplists:delete(erl_opts, CONFIG) ++ [{erl_opts, ErlOpts}]
-end.
diff --git a/rebar.lock b/rebar.lock
new file mode 100644
index 0000000..57afcca
--- /dev/null
+++ b/rebar.lock
@@ -0,0 +1 @@
+[].
diff --git a/src/local.erl b/src/local.erl
index 9ec5975..755a6e5 100644
--- a/src/local.erl
+++ b/src/local.erl
@@ -131,9 +131,9 @@
 %%
 %% To embed a local name server in your application, you can simply add `ChildSpec' to your supervision tree.
 -spec name_server_child_spec(ChildId, ServerName, Shutdown) -> ChildSpec when
-      ChildId    :: supervisor:child_id(),
+      ChildId    :: term(),
       ServerName :: name_server_name(),
-      Shutdown   :: supervisor:shutdown(),
+      Shutdown   :: brutal_kill | timeout(),
       ChildSpec  :: supervisor:child_spec().
 name_server_child_spec(ChildId, ServerName, Shutdown) when is_atom(ServerName) ->
     {ChildId, {local_name_server, start_link, [ServerName]}, permanent, Shutdown, worker, [local_name_server]};
@@ -142,10 +142,5 @@
 
 %% @doc Returns OTP compatible name
 -spec otp_name(name()) -> otp_name().
--ifdef('LOCAL_BEFORE_OTP17').
-otp_name(Name) ->
-    list_to_tuple([via, local, Name]).
--else.
 otp_name(Name) ->
     {via, local, Name}.
--endif.