public
Description: Lumberjacks cut down trees. This lumberjack builds them (it's a generic DSL for constructing object trees).
Homepage:
Clone URL: git://github.com/ryan-allen/lumberjack.git
joho (author)
Tue Jan 20 19:40:57 -0800 2009
ryan-allen (committer)
Tue Jan 20 19:44:44 -0800 2009
name age message
file MIT-LICENSE Mon Jun 30 22:30:10 -0700 2008 adding '08 to copyright [ryan-allen]
file README.markdown Loading commit data...
directory examples/
file lumberjack.rb
file lumberjack_test.rb
file rakefile.rb Wed Dec 05 19:17:20 -0800 2007 Ensure test failure raises an exception for cru... [crafterm]
README.markdown

Lumberjack is best summed up as a generic DSL for constructing object trees.

It works great for configuration files, for generating a tree of configuration objects for later reflection or what-not. But in reality you could use it for whatever you're willing to dream up.

I apologise for the lack of documentation :) Below is a code example to get you started, any questions, shoot me a message!

Now, that code example:

require 'lumberjack'

class Person

  attr_accessor :age, :gripes, :chums

  def initialize(name)
    @name = name
    @gripes = []
    @chums = []
  end
end

class Gripe
  def initialize(desc)
    @desc = desc
  end
end

tree = Lumberjack.construct do

  # we're in list / instanciate object scope

  @john = person 'John (is a doondy head)' do
    # we instanticated an object, so now we're in attr assignment scope
    age 12 # this is equiv to @john.age = 12
    gripes do # open up a colection on john...
      # now we're back in list / instanticate object scope
      gripe 'untested code' # creating a gripe
      gripe 'no beer' # and another
    end # out of gripes, back to john attr assignment
  end # out of john

  # we're back to creating people:

  person 'Ryan' do
    age 25 
  end

  person 'Tim' do
    age 'Infinite'
    chums @john # instance vars are shared across Lumberjack.construct
  end
end

puts tree.inspect