A library to easily manage a Mongrel2 configuration database
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
sample
spec
.gitignore
.travis.yml
Gemfile
Guardfile
LICENSE
README.md
Rakefile
m2config.gemspec

README.md

CAVEAT EMPTOR

THIS LIB IS STILL YOUNG. ALTHOUGH IT SEEMS TO WORK SO FAR, I AM JUST STARTING TO USE IT IN THE FIELD SO EVEN THOUGH THE SPECS PASS IT MAY BREAK STUFF.

M2config

Build Status Code Climate
Gem Version
Manage your Mongrel2 configuration database using handy model classes that map Servers, Hosts, Routes, Directories, Proxies, Handlers and Settings.

Installation

Add this line to your application's Gemfile:

gem 'm2config'

And then execute:

$ bundle

Or install it yourself as:

$ gem install m2config

Usage

Thanks to the sane default values set by M2Config, creating a basic Mongrel2 configuration can be as simple as running:

require "m2config"

cfg       = M2Config::Config.new
server    = M2Config::Server.new
exComHost = M2Config::Host.new({name: "ex", matching:"example.com"})
pubDir    = M2Config::Dir.new({base:"public"})
pubRoute  = M2Config::Route.new({path:"/", target:pubDir})

exComHost.add_route pubRoute
server.add_host exComHost

Keep in mind that these lines will create their corresponding database records every time the script is run. For simplicity there is no check for duplicates. This has the benefit of complete flexibility and control but you must ensure that the DB ends up looking the way you want.

You can swiftly dump your config using this at the end of your script:

require "pp"

pp Server.all
pp Host.all
pp Handler.all
pp Dir.all
pp Route.all

Default values

TODO

This is Sequel

The classes mapping the configuration are Sequel models. I just added some syntactic sugar but you can use them as plain Sequel::Model objects.

TODO

A few features that you may miss if your needs go beyond mine:

  • MIME types are not handled (trivial to add, just ask)
  • Support forcing redefinition of existing extension in MimeType
  • Multiple DBs in same process (must use Sequel's sharding support)
  • A DSL-like syntax (likely to improve readability in complex setups)
  • Declare proper associations
  • Cleanup / consolidate DB (delete unreferenced entries)

Contributing

Start simply with an issue (even for a feature request).

Otherwise if you feel like helping directly:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request