Mapping git repos to ruby objects und vice versa, need ideas

Hi folks,

my last mail got a ambiguous subject so I try again with another one,
since this
isn’t a job offer… :slight_smile:

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
(commits).
These pages contain snapshots of your ruby object.

Still neither documentation nor write support is available. I’m
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
complex types?

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

./example.rb

require 'chambermaid'
require 'person'

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

# method missing binds a Context to the method called returning

the value
# returned by method
person_foo.id == 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 => File.join(File.dirname(__FILE__), 'people'),
      :as => :id
end

./people/init.rb

Chambermaid.ascribe Person do |has|
  # tell chambermaid where attributes should be read from and

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 => id.int.1
  # 2. the filename is divided based on '.' => id, int, '1'
  # 3. the last n-1 parts are filters that manipulate the value =>

int, ‘1’
# 4. filters are applied in reverse order => ‘1’, int
# 5. unrecognized filters, like ‘1’, return itself as value => ‘1’
# 6. the int filter calls to_i on ‘1’ => 1
# 7. the result is assigned to the attribute id
has.attribute :id, ‘int.%i’, :id

  # tell Chambermaid the meta.yml file contains the

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ßmann

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs