diff --git a/apps/zapdos/lib/zapdos.ex b/apps/zapdos/lib/zapdos.ex index 5d96d2b..ec731ae 100644 --- a/apps/zapdos/lib/zapdos.ex +++ b/apps/zapdos/lib/zapdos.ex @@ -8,8 +8,14 @@ defmodule Zapdos do def get_tweets(query) do ExTwitter.stream_filter(track: query) |> Stream.map(fn(tweet) -> tweet.text end) - |> Stream.map(fn(text) -> ColorParsing.get_color(text) |> ColorParsing.hex_to_number |> IO.puts end) + |> Stream.map(&(update_color(&1))) |> Enum.to_list end + defp update_color(text) do + ColorParsing.get_color(text) + |> ColorParsing.parse_rgb_hex + |> Lightning.Control.change_color(150) + end + end diff --git a/apps/zapdos/lib/zapdos/pluck.ex b/apps/zapdos/lib/zapdos/pluck.ex deleted file mode 100644 index babf6df..0000000 --- a/apps/zapdos/lib/zapdos/pluck.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Zapdos.Pluck do - use GenServer - - def start_link do - GenServer.start_link(__MODULE__, %{}) - end - - def init(state) do - schedule_work() # Schedule work to be performed at some point - {:ok, state} - end - - def handle_info(:work, state) do - # Do the work you desire here - Zapdos.get_tweets("#cmm_storm", 1) - |> IO.inspect - - schedule_work() # Reschedule once more - {:noreply, state} - end - - defp schedule_work() do - Process.send_after(self(), :work, 15 * 1000) - end -end diff --git a/apps/zapdos/mix.exs b/apps/zapdos/mix.exs index be3aec0..5808870 100644 --- a/apps/zapdos/mix.exs +++ b/apps/zapdos/mix.exs @@ -35,6 +35,7 @@ defmodule Zapdos.Mixfile do defp deps do [ {:extwitter, "~> 0.8"}, + {:lightning, in_umbrella: true} ] end end diff --git a/apps/zeus/lib/zeus.ex b/apps/zeus/lib/zeus.ex index 01f4242..770a835 100644 --- a/apps/zeus/lib/zeus.ex +++ b/apps/zeus/lib/zeus.ex @@ -18,9 +18,6 @@ defmodule Zeus do # for other strategies and supported options opts = [strategy: :one_for_one, name: Zeus.Supervisor] Supervisor.start_link(children, opts) - - :timer.apply_interval(:timer.seconds(15), Zapdos, :get_tweet("#cmm_storm", 1)) - |> IO.puts end # Tell Phoenix to update the endpoint configuration