defmodule Kitto.Job.DSL do
  defmacro __using__(_opts) do
    quote do
      import Kitto.Job.DSL
      import Kitto.Notifier, only: [broadcast!: 2]
    end
  end

  defmacro job(name, options, contents \\ []) do
    quote do
      Kitto.Job.register unquote(name), unquote(options), fn ->
        unquote(contents[:do])
      end
    end
  end
end

Add Kitto.Job.DSL providing `job` macro
Add Kitto.Job.DSL providing `job` macro

The main reason behind adding this macro is having named jobs for
easier monitoring and stats gathering.

An alternative would be to keep stats about jobs per file, but
a file can declare multiple jobs.

Usage:

Example: A job to fetch today's weather
File: jobs/weather.ex

```elixir
use Kitto.Job.DSL

job :weather, every: :second do
  broadcast! :london_weather, %{value: Weather.for(:london)}
  broadcast! :athens_weather, %{value: Weather.for(:athens)}
end

job :weather_tweets do
  spawn fn ->
    for tweet <- TwitterClient.stream_filter(track: "weather") do
      broadcast! :tweets, %{value: tweet.text}
    end
  end
end
```

kittoframework/kitto,kittoframework/kitto