Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
For mister_solo, as a reply to a question on #ruote (freenode irc)


This is my ruote / ruote-kit setup in non Rails project

A Project Module

I tend to have a Project Module for my non-web projects; so that instead of calling Rails.logger I call Project.logger (Where Project would be the actual name, Such as Fubar or SameOld) same goes for ruote. It mostly ends-up in Project.engine where the code would look something like this:

module Project
  class << self
    attr_accessor :config, :root

    def engine
      @engine ||= setup_ruote_engine

    def setup_ruote_engine
, Project.config[:ruote][:storage]))

    def logger
      @logger ||= setup_logger

    def setup_logger
      logger = File.join(Project.root, Project.config[:log_file])
      logger.formatter = proc { |severity, datetime, progname, msg|
        "[#{datetime}] #{severity}: #{msg}\n"
      return logger

    # etc. etc.

combine that with a nice Yaml file for config and you're half way there.


Another 'Rails Convention' I tend to steal is to have a boot file, where I load up my Project module

# require everything
require 'bundler/setup'

# core dependencies
require 'logger'

# load paths
root   = File.expand_path('../../', __FILE__)
lib    = File.join(root, "lib")
config = File.join(root, "config")

# setup the project
require File.join(lib, "project")
Project.root   = root
Project.config = YAML.load_file(File.join(config, "project.yml"))

# ... project specific requires go here

Rack it up

Now that I have seperated and comparted everything, my rack-up file is plain and simple

require './config/boot'

RuoteKit.engine = Project.engine
RuoteKit.engine.register do

use Rack::CommonLogger
use Rack::Lint

run RuoteKit::Application

And for convenience; a shell script


/usr/bin/env rackup -p 9494 script/

A listing for completion

./script/ruote_web     # the shell script - I tend to drop the extension on executables
./data/ruote_work      # ruote storage directory, configured in project.yml

Hope that is insightfull, helpfull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.