From: "Florian Aßmann" Date: 2009-08-21T17:48:58+09:00 Subject: Mapping git repos to ruby objects und vice versa, need ideas --Apple-Mail-23--193090641 Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Hi folks, my last mail got a ambiguous subject so I try again with another one, =20= since this isn't a job offer... :) 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: __Can you give me a hint how I should treat files and other more =20 complex types?__ 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 =3D> = =20 int, '1' # 4. filters are applied in reverse order =3D> '1', int # 5. unrecognized filters, like '1', return itself as value =3D> = '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:foo@bar.url Florian A=DFmann Fork Unstable Media | Hamburg www.fork.de --Apple-Mail-23--193090641--