Help Wanted - Chambermaid

F

Florian Aßmann

Hi folks,

I'm working on a lib called Chambermaid that creates snapshots of ruby
objects and stores them in a git repository.

The main objective of Chambermaid is not to mess with your classes or
objects. Instead Chambermaid should provide a simple but powerful API.

You work with browsers which will give you access to specific diaries
(repos) and diaries which will give you access to specific pages =20
(commits).
These pages contain snapshots of your ruby object.

Still neither documentation nor write support is available. I'm =20
currently
struggling on how to snapshot files.


So here is my question:
__Do you have an idea how I should treat files and other more complex =20=

types?__


P.S.: *Maybe at some point I can Chambermaid keep a diary on =20
herself... :D*

Resources: http://github.com/boof/chambermaid


### ./example.rb
require 'chambermaid'
require 'person'

PeopleBrowser =3D Chambermaid.browser Person # =3D> a Browser
foo_master_page =3D PeopleBrowser[1].last_page # =3D> a Page
person_foo =3D foo_master_page.target # =3D> a Person

# method missing binds a Context to the method called returning =20
the value
# returned by method
person_foo.id =3D=3D foo_master_page.id


### ./person.rb:
class Person
attr_accessor :id, :firstname, :lastname, :email

# tell Chambermaid where to find the repositories
Chambermaid.keed_diary self,
:in =3D> File.join(File.dirname(__FILE__), 'people'),
:as =3D> :id
end


### ./people/init.rb
Chambermaid.ascribe Person do |has|
# tell chambermaid where attributes should be read from and =20
write to

# tell Chambermaid that the id is located in 'id.*' which reads
# the value like:
#
# 1. a Context tries to find the correct filename =3D> id.int.1
# 2. the filename is divided based on '.' =3D> id, int, '1'
# 3. the last n-1 parts are filters that manipulate the value =20
=3D> int, '1'
# 4. filters are applied in reverse order =3D> '1', int
# 5. unrecognized filters, like '1', return itself as value =3D> =20=

'1'
# 6. the int filter calls to_i on '1' =3D> 1
# 7. the result is assigned to the attribute id
has.attribute :id, 'int.%i', :id

# tell Chambermaid the meta.yml file contains the =20
attributes :firstname and
# :lastname where .map adds the yml filter chain if not defined.
has.map :meta do |meta|
meta.reads:)firstname) { |meta| meta['firstname'] }
meta.reads:)lastname) { |meta| meta['lastname'] }
end

has.attribute :email, 'uri'

end


### ./people/1/id.int.1
1


### ./people/1/meta.yml
---
firstname: Foo
lastname: Bar
...


### ./people/1/email.uri
mailto:[email protected]


Florian A=DFmann

Fork Unstable Media | Hamburg
www.fork.de <http://www.fork.de/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top