Sequel storage implementation for ruote >= 2.2.0
This is how a ruote engine is setup with a ruote-sequel storage (postgres) and a worker:
require 'rubygems'
require 'json' # gem install json
require 'ruote'
require 'ruote-sequel' # gem install ruote-sequel
sequel = Sequel.connect('postgres://localhost/ruote_test')
#sequel = Sequel.connect('mysql://root:root@localhost/ruote_test')
#sequel = Sequel.connect(
# :adapter => 'mysql2',
# :user => 'root',
# :password => 'root',
# :socket=> '/tmp/mysql.sock',
# :database => 'foo_development')
engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::Sequel::Storage.new(sequel)))
# ...
To create the table in the database:
Ruote::Sequel.create_table(sequel, true)
Tested with sequel 3.20.0, with the postgresql (pg 0.10.1) adapter.
To learn more about connecting Sequel to a database:
http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
A single 'documents' table is used. To change this name:
opts = { 'sequel_table_name' => 'ruote_docs' }
engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::Sequel::Storage.new(sequel, opts)))
In case of reconnection errors (mysql and mysql2), doing something like
sequel = Sequel.connect(
'mysql://root:root@localhost/ruote_test',
:after_connect => proc { |c| c.reconnect = true })
#
# or
#
sequel = Sequel.connect(
'mysql://root:root@localhost/ruote_test',
:after_connect => proc { |c| c.send(:reconnect=, true) })
#
# similar foro mysql2
#
sequel = Sequel.connect(
'mysql2://root@localhost/ruote_test',
:after_connect => proc { |c| c.send(:reconnect=, true) })
might help (seems not OK with mysql2).
assuming you have
ruote/
ruote-sequel/
- unit tests :
get into ruote/ and do
$ ruby test/unit/storage.rb -- --sequel
- functional tests :
get into ruote/ and do
$ ruby test/functional/test.rb -- --sequel
MIT
http://ruote.rubyforge.org/ http://github.com/jmettraux/ruote-sequel
mailing list : http://groups.google.com/group/openwferu-users irc : irc.freenode.net #ruote