Tomahawk

Tomahawk helps generating and parsing Apache 2 configuration files. You can for example parse VirtualHost configs, CRUD some directives in your Ruby code and generate a new config file out of it afterwards.

This gem is still in an early alpha stage and may change it's API faster than you blink. Still any contributions are highly appreciated.

Installation

Add this line to your application's Gemfile:

gem 'tomahawk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tomahawk

Usage

require 'tomahawk'

httpd_config = Tomahawk.parse File.read('/etc/apache2/apache.conf')

httpd_config.directives # lists parsed directives such as ServerName and LogLevel

httpd_config.groups # lists parsed directive groups such as <VirtualHost> and <Directory>

httpd_config.directives['server_name'] = 'google.com' # change a directive

httpd_config.directives['some_new_directive'] = 'foo' # create a new directive

File.write('/etc/apache2/apache.conf.new', httpd_config.to_conf) # write your new configuration back to disk

Contributing

  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