design-patterns-ruby icon indicating copy to clipboard operation
design-patterns-ruby copied to clipboard

GOF design patterns in Ruby

Design Patterns for Ruby

Build Status Coverage Status Code Climate


Design Patterns

Creational Patterns

Design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.

  • Abstract Factory - For creating and using families of related/dependent objects
  • Builder - For creating different types of complex objects step by step
  • Factory Method - For creating one type of object out of many which can be used in its place
  • Prototype - Up next.
  • Singleton - Coming soon ( Explain Ruby's singleton too )

Structural Patterns

  • Explain what a Structural Pattern means
  • Add Patterns and links to examples here

Behavioral Patterns

  • Explain what a Behavioral Pattern means
  • Add Patterns and links to examples here

About reading code and running tests

The code is heavily documented, and has 100% test coverage. Browse through the Documentation online. It contains explanations of each pattern example. It's also recommended to go throught the tests in spec/ directory to get an idea of how the examples work.

To run the tests :

bundle install
rake

Contributing

Step 1 : Fork

Step 2 :

  1. Add Ruby examples to Design Patterns.
  2. Each example should have 100% green test coverage.
  3. Each example should have RDocs/YARDocs that explain what each class does.
  4. Each pattern should have its own README.md explaining it.
  5. If there is a Ruby way that bakes in the pattern in the language, do not re-invent the wheel and show the Ruby way. Explain how the example works.

Step 3 : Send a pull request