Merge pull request #213 from jgandt/convert_from_exfswatch_to_file_system
Convert from ExFSWatch to FileSystem
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
before_install:
|
||||||
|
- sudo apt-get -qq update
|
||||||
|
- sudo apt-get install -y inotify-tools
|
||||||
language: elixir
|
language: elixir
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
defmodule Watcher do
|
defmodule Watcher do
|
||||||
use ExFSWatch, dirs: ["lib/koans"]
|
use GenServer
|
||||||
|
|
||||||
def start_link do
|
def start_link() do
|
||||||
start()
|
GenServer.start_link(__MODULE__, [dirs: ["lib/koans"]])
|
||||||
end
|
end
|
||||||
|
|
||||||
def callback(file, events) do
|
def init(args) do
|
||||||
|
{:ok, watcher_pid} = FileSystem.start_link(args)
|
||||||
|
FileSystem.subscribe(watcher_pid)
|
||||||
|
{:ok, %{watcher_pid: watcher_pid}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_info({:file_event, watcher_pid, {path, events}}, %{watcher_pid: watcher_pid}=state) do
|
||||||
if Enum.member?(events, :modified) do
|
if Enum.member?(events, :modified) do
|
||||||
file |> normalize |> reload
|
path |> normalize |> reload
|
||||||
end
|
end
|
||||||
|
{:noreply, state}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp reload(file) do
|
defp reload(file) do
|
||||||
|
|||||||
4
mix.exs
4
mix.exs
@@ -11,11 +11,11 @@ defmodule Koans.Mixfile do
|
|||||||
|
|
||||||
def application do
|
def application do
|
||||||
[mod: {ElixirKoans, []},
|
[mod: {ElixirKoans, []},
|
||||||
applications: [:exfswatch, :logger]]
|
applications: [:file_system, :logger]]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp deps do
|
defp deps do
|
||||||
[{:exfswatch, "~> 0.3"}]
|
[{:file_system, "~> 0.2"}]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp elixirc_path(:test), do: ["lib/", "test/support"]
|
defp elixirc_path(:test), do: ["lib/", "test/support"]
|
||||||
|
|||||||
3
mix.lock
3
mix.lock
@@ -1,2 +1 @@
|
|||||||
%{"exfswatch": {:hex, :exfswatch, "0.4.1", "008db817f6096eec69d17c7ca562c572fb4409728a09f465dea7e31190fb983c", [:mix], []},
|
%{"file_system": {:hex, :file_system, "0.2.2", "7f1e9de4746f4eb8a4ca8f2fbab582d84a4e40fa394cce7bfcb068b988625b06", [], [], "hexpm"}}
|
||||||
"fs": {:hex, :fs, "2.12.0", "ad631efacc9a5683c8eaa1b274e24fa64a1b8eb30747e9595b93bec7e492e25e", [:rebar3], []}}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user