--- layout: default title: "Contribute" current: "contribute" ---

Contributing to Merb

Sharing Your Merb Know-How

Merb has a fledgling wiki that would love to meet you. The wiki is a great place to garner and contribute up-to-date information on all things Merb.

Reporting bugs

Found a bug? Ticket it! Go to our Lighthouse app and set up a login, then add your ticket. For any tickets that you do add, please try to be as descriptive as possible, the developers well thank you for it.

Even if you don’t feel you contribute code, reporting bugs is a huge help, so please report anything awry you encounter.

Contributing Code to Merb

Contributing to Merb is as easy as checking the source out from Github, editing it, and creating a patch. Learn all about using git, Github, and making patches.

$ git clone git://github.com/merb/merb.git
$ cd merb-core
$ vim the_source_file.rb
$ git commit -a -m "fix a bug"
$ git-format-patch master..

Code Style Guidelines

There are a few guidelines your code should follow.

1. Parentheses around parameter lists for methods

# BAD!
def my_method param, arg
puts "OH NOEZ!"
end

# GOOD!
def my_method(param, arg)
puts "HOORAYZ!" end

2. Two space indent

# BAD!
def tabby
puts "A fat tab!"
end

# GOOD!
def tabby
puts "Two spaces!"
end

3. Documentation is required

We would like to move merb over to a YARD based documentation system. To that end, we ask if you touch a file, update it to YARD syntax.

The old style of the documentation follows this system:

There are a number of available types:

  • Class (e.g. String)
  • Array[Type] (e.g. Array[String], an Array of Strings)
  • Array[Type, Type] (e.g. Array[String, Symbol], an Array of two elements: a String followed by a Symbol)
  • Hash{Type => Type} (e.g. Hash{Symbol => String}, a Hash whose keys are Symbols and values are Strings)
  • Hash{Type => Type, Type => Type} (e.g. Hash{Symbol => String, Class => String}, a Hash with two elements)
  • Union Types: (String, Symbol); (e.g. Array[(String, Symbol)], an Array whose elements are Strings or Symbols)
  • Duck Typing Types: ~to_s (responds_to? :to_s)

Certain types of parameters do not require types:

  • Splats: *args
  • Blocks: &blk

Parameters are defined in parameter blocks:


==== Parameters
foo<String>:: My foo string
bar<String>:: My bar string
      

The return value of a function is required:


==== Returns
String:: A cool string                  
      

If the method might possibly raise an error (including as a result of calling another method), it must be specified:


==== Raises
Exception:: A crazy Exception
      

If one of the parameters is an options Hash, it must be specified:


==== Options (opts)
:foo<String>:: The foo option
:bar<Symbol>:: The bar option
      

4. Be wary of clever code!

Cleverness for cleverness sake is not our friend; if something is only slightly more handy but infinitely more complex, then please reconsider your implementation.

5. Column width

80 column line width except in exceptional situations