hughbien/thyme — pull request #11 by dtinth (2014-10-14 04:01:40+00:00)
Title: Plugin System

This pull-request adds a plugin system to Thyme.

A plugin is class that:

- has a constructor that accepts the Thyme instance and other options supplied by the user.
- optionally has hook functions that will be called on various events: `before`, `tick`, and `after`.

When it is used inside `~/.thymerc`, the plugin class is instantiated.

A more detailed documentation is in the README.md file.

Behavior Changes
------------------------

The `before`, `tick`, and `after` hook is now implemented as a plugin.

```ruby
before do
something
end
```

is a syntactic sugar for

```ruby
use Plugins::BeforeHook do
something
end
```

So that in the `start_timer` method, we don't worry anymore about having to call all hooks. We instead just send a message to each plugin. Another step further would be to move tmux-related code into its own plugin, and use it when the tmux option is set.

However, this introduces a small behavior change (which should not be a problem): You can now have multiple `before`, `tick`, and `after` block, and they will all be executed. Previously, setting a hook will overwrite the previous one.