Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Latest commit

 

History

History
48 lines (34 loc) · 1.02 KB

README.rdoc

File metadata and controls

48 lines (34 loc) · 1.02 KB

Doily

A Javascript (function) interpreter for Ruby.

Examples

Doily was basically designed to support CouchDB views. So, you can do stuff like this:

class CouchDBView
  def map(function, documents)
    function = Doily(function).delegate(self)

    @results = []
    documents.each { |doc| function.call(doc) }
    @results
  end

  def emit(key, value)
    @results.push(:key => key, :value => value)
  end
end

map_function = <<-END
  function(doc) {
    if (doc.chef_type == 'node') {
      emit(doc.name, doc);
    }
  }
END

CouchDBView.new.map(map_function, Document.all)

Install

gem sources --add http://gems.github.com
gem install matthewtodd-doily

Or, if you want to run tests & features:

gem sources --add http://gems.github.com
gem sources --add http://gems.opscode.com
gem install matthewtodd-doily --development

Alternatives (More or Less)