Plugins
I would like to expose a plugin mechanism once the basic features are done. This issue can capture ideas and considerations for implementing the plugins.
Some possible extension points for a Gemstash plugin:
- Hook in as a rack middleware
- Migrations that are run after Gemstash migrations are run
- Additional routes for sinatra handled by the plugin
- Deployed as a separate gem
- Maybe add the plugin via something like
gemstash plugin <xyz> - Alternatively, it could be a hidden feature supported by tweaking a config (like in
Gemstash::Configuration, apluginsarray listing the plugins to load)
Deliberate extension points make sense to me. If you name the gem as a gemstash extension (eg jars-gemstash), I think it even makes sense to have all the integration happen automatically when the gem is in the Gemfile. You would need just a little bit of cooperation from the main repo for that to work, but I am imagining something like this:
# jarstore/gemstash.rb
require 'gemstash'
require 'jarstore/gemstash'
module Jarstore
class Gemstash
def routes
# return an object that can be included into the Sinatra app
end
end
end
Gemstash.register_plugin(Jarstore::Gemstash)
Then you could implement register_plugin to make sure that the module returned by routes is mixed in to the Sinatra app. And you could add migrations via a another method similar to routes, etc.
:+1: that seems perfect
Should using a plugin require a Gemfile then? Right now you can be up and running with gemstash by simply installing the gem and starting it... there is no Gemfile involved unless you want there to be one, so just wondering out loud if it would make sense at all to support plugins when there is no Gemfile. Something simple like a list of things to require in ~/.gemstash/config.yml might be enough to allow running gemstash without a Gemfile, but maybe that's not a strong enough use case to warrant the added complexity.
@smellsblue I think for servers that will be deployed to production a Gemfile makes the most sense. Production servers don't really want to use gem install to manage an application :)
Here's what I would expect to be in the readme around deploying:
# Deploying
$ git clone https://github.com/bundler/gemstash
$ cd gemstash
$ git checkout
$ bundle install --path .bundle
$ bin/gemstash
# You're running a gemstash server!
# If you want to use a server other than Puma, use the config.ru Rack file