# Spur


Loosely based on, a very simple utility for quickly setting up an activity stream in your Elixir/Ecto app.

More detailed examples of configuration and usage are in the tests.

## Installation

Basic steps are 

1. Add Spur to your application deps
2. Generate and run a migration that adds an activities table to your repo (see priv/test/migrations)
3. Add the following config:

    config :spur, ecto_repos: [MyApp.Repo],
                  repo: MyApp.Repo

That's enough to start tracking arbitrary activities.

%Spur.Activity{actor: "caesar", action: "came", object: "your-county", meta: %{also: ["saw", "conquered"]}}
Fields are based on

If you want to make use of automatic tracking of inserts, updates and deletes, make sure your objects implement the required fields as functions.

defmodule Battle do
  defimpl Spur.Trackable, for: Diddit do
    def actor(war), do: "Accounts.User:#{war.general_id}"
    def object(war), do: "war:#{}"
    def target(_chore), do: nil
Now instead of using `Repo` to perform your operation, use `Spur` instead.

%MyApp.Battle{general_id: 5}
|> MyApp.Battle.changeset
|> Spur.insert

A record for both your `Battle` and an `Activity` with action set to insert will be stored in the DB. Of course, the `Battle` fails validations, neither will be inserted and the changeset will be returned with errors, just as Repo would.


> <<Someone who finds a trace [Spur] certainly also knows that something has existed before and is now left behind. But one does not just take note of this. One begins to search and to ask oneself where it leads.>> 
> Hans Georg-Gadamer, "Hermeneutik auf dem Spur"