README.md in sandthorn-0.0.1 vs README.md in sandthorn-0.0.2

- old
+ new

@@ -1,7 +1,12 @@ +[![Build Status](https://travis-ci.org/Sandthorn/sandthorn.svg?branch=master)](https://travis-ci.org/Sandthorn/sandthorn) +[![Coverage Status](https://coveralls.io/repos/Sandthorn/sandthorn/badge.png?branch=master)](https://coveralls.io/r/Sandthorn/sandthorn?branch=master) +[![Code Climate](https://codeclimate.com/github/Sandthorn/sandthorn.png)](https://codeclimate.com/github/Sandthorn/sandthorn) +[![Gem Version](https://badge.fury.io/rb/sandthorn.png)](http://badge.fury.io/rb/sandthorn) + # Sandthorn Event Sourcing -A ruby framwork for saving an object's state as a series of events, and tracking non state changing events. +A ruby framework for saving an object's state as a series of events, and tracking non state changing events. ## What is Event Sourcing "Capture all changes to an application state as a sequence of events." [Event Sourcing](http://martinfowler.com/eaaDev/EventSourcing.html) @@ -11,57 +16,60 @@ Think of it as an object database where you not only what the new value of the attribute is but when and why it changed. _Example:_ ```ruby -#Setup the Aggregate +# Setup the Aggregate -require 'sandthorn/aggregate_root_dirty_hashy' #the one available right now +# The one available right now +require 'sandthorn' +require 'sandthorn_driver_sequel' +require 'sandthorn/aggregate_root_dirty_hashy' class Ship - include Sandthorn::AggregateRoot::DirtyHashy - attr_reader :name + include Sandthorn::AggregateRoot::DirtyHashy + attr_reader :name - def initialize name: nil, shipping_company: nil - @name = name - end + def initialize name: nil, shipping_company: nil + @name = name + end - # state-changing command - def rename! new_name: "" - unless new_name.empty? or new_name == name - @name = new_name - ship_was_renamed - end - end - private - # commit the event and state-change is automatically recorded. - def ship_was_renamed - commit - end + # State-changing command + def rename! new_name: "" + unless new_name.empty? or new_name == name + @name = new_name + ship_was_renamed + end + end + + private + + # Commit the event and state-change is automatically recorded. + def ship_was_renamed + commit + end end -#Setup the framework with the sequel driver for persistance -url = "path to sql" #Example sqlite://path/sequel_driver.sqlite3 +# Setup the framework with the sequel driver for persistance +url = "sqlite://spec/db/sequel_driver.sqlite3" catch_all_config = [ { driver: SandthornDriverSequel.driver_from_url(url: url) } ] Sandthorn.configuration = catch_all_config -#migrate db schema for the sequel driver +# Migrate db schema for the sequel driver migrator = SandthornDriverSequel::Migration.new url: url SandthornDriverSequel.migrate_db url: url -#Usage -ship = Ship.new "Titanic" -ship.rename! "Vasa" -puts ship.aggregate_events +# Usage +ship = Ship.new name: "Titanic" +ship.rename! new_name: "Vasa" + ship.save new_ship = Ship.find ship.id puts ship.name -. -. -For more info look at the specs. +# For more info look at the specs. ``` ## Installation @@ -78,9 +86,14 @@ $ gem install sandthorn ## Usage TODO: Write usage instructions here + +## Development + +run: + `rake console` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)