This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit e1346faf85cfbe5f8a2c78f4e4ae3997f8792ff0
tree 6a9a62e9eee9a2981a613774a5f36f4d7ff3c475
parent 8a02c3d6d1489a39f0e6d67e1e294d7f35df20a0
tree 6a9a62e9eee9a2981a613774a5f36f4d7ff3c475
parent 8a02c3d6d1489a39f0e6d67e1e294d7f35df20a0
pottery /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Apr 10 06:40:55 -0700 2008 | |
| |
CHANGELOG | ||
| |
LICENSE | Thu Apr 10 06:40:55 -0700 2008 | |
| |
Manifest | Thu Apr 10 06:40:55 -0700 2008 | |
| |
README | ||
| |
Rakefile | ||
| |
lib/ | ||
| |
spec/ |
README
Pottery allows you to emerge class definitions via calling assignment methods and
persist instances to a database; requires Morph and Soup gems.
[Note API subject to change]
== Pottery example
Here's example code showing Pottery playing with Hpricot:
> sqlite3 soup.db
> irb
require 'rubygems'
require 'pottery'; require 'hpricot'; require 'open-uri'
class Hubbit
include Pottery
def initialize name=nil
if name
doc = Hpricot open("http://github.com/#{name}")
(doc/'label').collect do |node|
label = node.inner_text
value = node.next_sibling.inner_text.strip
morph(label, value)
end
morph(:id_name, name)
end
end
end
The model emerges from the data. Let's start by looking up 'why':
why = Hubbit.new 'why'
What new methods do we have?
Hubbit.morph_methods # => ["email", "email=", "followers", "followers=",
"id_name", "id_name=", "member_since", "member_since=", "name", "name=",
"public_repos", "public_repos="]
Ah-ha, so we have a name attribute now:
why.name #=> "why the lucky stiff"
Let's save why for later
why.save
Ok, now it's later, let's restore why from the database
why = Hubbit.restore('why') #=> <Hubbit @id_name="why", @name="why the lucky stiff" ...>
See LICENSE for the terms of this software.








