Skip to content

Commit

Permalink
Convert datamapper.org site to Jekyll, Markdown
Browse files Browse the repository at this point in the history
* rely on Maruku as Markdown processor (we're using a couple of MD
  extensions that are not available in vanilla MD).

Signed-off-by: Alex Coles <alex@alexcolesportfolio.com>
  • Loading branch information
myabc committed Nov 15, 2009
1 parent c18384c commit 6f27760
Show file tree
Hide file tree
Showing 99 changed files with 2,727 additions and 2,290 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,4 +1,3 @@
output/*
_site/
.DS_Store
*.swp
Expand Down
9 changes: 9 additions & 0 deletions 404.html
@@ -0,0 +1,9 @@
---
layout: default
title: File Not Found
---

<h1>Sorry, that file could not be found</h1>

<p>We recently switched hosts, so some older links no longer exist.</p>
<p>Try the menu above or see the <a href="http://wiki.github.com/datamapper/dm-core">wiki</a>.</p>
File renamed without changes.
24 changes: 0 additions & 24 deletions Rakefile

This file was deleted.

5 changes: 0 additions & 5 deletions Sitefile

This file was deleted.

2 changes: 2 additions & 0 deletions _config.yml
@@ -0,0 +1,2 @@
pygments: true
permalink: none
5 changes: 5 additions & 0 deletions _layouts/articles.html
@@ -0,0 +1,5 @@
---
layout: default
---

{{ content }}
14 changes: 5 additions & 9 deletions layouts/default.rhtml → _layouts/default.html
@@ -1,21 +1,17 @@
---
extension: html
filter: erb
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>DataMapper - <%= @page.title %></title>
<title>DataMapper - {{ page.title }}</title>
<link rel="stylesheet" href="/css/site.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="/css/coderay.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="/css/code.css" type="text/css" media="screen, projection" />
<!--[if lt IE 7]> <link rel="stylesheet" href="css/ie_hacks.css" type="text/css" media="screen, projection" /> <![endif]-->
<link rel="alternate" type="application/rss+xml" title="News and Notes feed" href="/news.rss" />
</head>

<body id="<%= @page.body_id %>">
<body id="home">
<div id="content">
<div id="header">
<h1><a href="/">DataMapper</a></h1>
Expand All @@ -29,10 +25,10 @@ <h1><a href="/">DataMapper</a></h1>
</ul>
</div>

<%= @content %>
{{ content }}

<div id="footer">
<p>Copyright Dan Kubb, Sam Smoot <%= Time.now.year %></p>
<p>Copyright Dan Kubb, Sam Smoot 2009</p>
<p>Web Design by <a href="http://www.mr-eel.com/">Luke Matthew Sutton</a> - Community Maintained</p>
</div>
</div>
Expand Down
111 changes: 111 additions & 0 deletions _posts/2008-03-22-the_great_refactoring.markdown
@@ -0,0 +1,111 @@
---
layout: articles
categories: articles
title: The Great Refactoring
created_at: 2008-03-22T15:55:50-05:00
summary: Change is afoot
author: afrench and ssmoot
---

{{ page.title }}
================

"Tip" DataMapper (hosted on [github](http://github.com/datamapper/dm-core)) is
going through a dramatic re-factor. Here's a quick summary of the anticipated
NEW public API.

Not Just for Databases Anymore
------------------------------

DataMapper's class terminology will change and 'de-couple' itself from
database-specific terminology. Gone are "database", "table", "column" and
"join". Say hello to "Repository", "Resource", "Property", and "Link".

"Why would you want to do that?", you ask. Ultimately it's because DataMapper
will soon support different types of persistence layers, not just databases.
It'll talk to all sorts of things like web services (REST and such), XML files,
YAML files, non-relational databases, even custom file-types or services of your
own design. Just implement an Adapter that conforms to a certain API and
DataMapper could support any type of data store. No need for a completely
separate library or anything.

As an added benefit, DataMapper become more "RESTful". [Ryan Tomayko](http://tomayko.com/writings/rest-to-my-wife)
has a very good explanation
of REST that all should read entitled [How I Explained REST to My Wife](http://tomayko.com/writings/rest-to-my-wife).

Model Definitions Are a Little Different
----------------------------------------

Since we're changing up the terminology, model definitions are going to change
up a little bit. Here's what a Planet model would look like using the new API:

{% highlight ruby linenos %}
class Planet
include DataMapper::Resource

resource_names[:legacy] = 'dying_planets'

property :name, String
property :age, Integer
property :core, String, :private => true
end
{% endhighlight %}

A couple of things are going on here. First, DataMapper::Base and
DataMapper::Persistence are gone and replaced with <%=
doc('DataMapper::Resource') %>. Next `set_table_name` has been replaced with
`resource_names` hash where you specify which arena play occurs in. After that
we have a couple of Property definitions that look a little different.

First off, Properties will no longer take `:symbols` for their types and instead
take real constants like String, Integer, DateTime. Also on the docket are the
ability to define your own custom types.

Think about that for a minute. If developers are able to define their own custom
types with their own materialization and serialization methods, DataMapper will
be able to support all kinds of wild data-types like GIS information, network
information, marshaled objects, JSON...pretty much anything a developer might
need, or want.

A Command-Line Interface
------------------------

Taking a lesson from web frameworks, DataMapper will sport an interactive
command-line so that you can browse your resources without the need to load up
the entire environment of your application. Here's an example session:

{% highlight bash linenos %}
$ dm mysql://root@localhost/great_musicians # connecting to a repository
{% endhighlight %}

An IRB session boots up...

{% highlight ruby %}
>> the_king = Person.first(:name => 'elvis')
>> the_king.alive? # => maybe
{% endhighlight %}

This is very similar to `script/console` in Rails or `merb -i` in Merb, only it
won't load up the entire environment of your application, just your DataMapper
resources and their associations, methods, and such. If you prefer "fat models",
this will constitute the core of your application.

How This All Comes Together
---------------------------

This is the coolest new feature of DataMapper: we're skipping all the way from
0.3.0 to 0.9! Get excited, contact the press, fire up the blogosphere! Its a
huge jump and we're honestly concerned that people may not be able to handle it.

Alright, so it's not _that_ big of a deal, but we're confident that all of this
will get DataMapper so close to going 1.0 that we'll be able to taste it. To get
there, DataMapper's more advanced features like single table inheritance,
paranoia, and chained associations will be re-implimented to use all this new
stuff, and then we're sure 0.9 will need a touch up or two.

So close....so very very close...

Stay tuned in to the [mailing list](http://groups.google.com/group/datamapper),
check up on the [wiki](http://datamapper.org/), chat it up in
[#datamapper](irc://irc.freenode.net/#datamapper) and watch
[github commit messages](http://github.com/datamapper/dm-core/commits/master) for updates.
107 changes: 107 additions & 0 deletions _posts/2008-03-29-spotlight_on_cpk.markdown
@@ -0,0 +1,107 @@
---
layout: articles
categories: articles
title: Spotlight on... Composite Keys
created_at: 2008-03-29T19:09:07-05:00
summary: When a Primary Key Just Isn't Enough
author: afrench and ssmoot
---

{{ page.title }}
================

For those of us who have taken a course on database design in college or
university, you may have run across a concept called 'Composite Primary Keys'
(or sometimes 'Compound Keys' or 'Concatenated Keys', and abbreviated
CPK(Composite Primary Keys)s). It's usually right before you tackle JOINs and
right after you fight with the "surrogate key" or "primary key" concept.

Boiling CPK(Composite Primary Keys)s down, they're just a way of identifying a
row by multiple keys rather than one. So instead of an auto_incrementing
"serial" primary key (as in `id`), you'd have a combination of `some_column` and
`some_other_column` that would uniquely identify a row.

CPK(Composite Primary Keys)s aren't as prevalent in the Rails world as Serial
Keys (such as the auto-incrementing `:id` column), but if you're going to
support legacy, integration or reporting databases or just de-normalized schemas
for performance reasons, they can be invaluable. So sure, Surrogate Keys are a
great convenience, but sometimes they just aren't an option.

Let's briefly take a look at how a few ruby ORMs support Composite Primary Keys
and then we'll talk about DataMapper's support for CPK(Composite Primary Keys)s.

ActiveRecord
------------

In short, ActiveRecord doesn't support CPK(Composite Primary Keys)s without the
help of an external library. [Dr. Nic Williams](http://drnicwilliams.com/about/)
[Composite Keys](http://compositekeys.rubyforge.org/) is an effort to overcome
this limitation.

Sequel
------

Unlike ActiveRecord, Sequel supports CPK(Composite Primary Keys)s natively:

{% highlight ruby linenos %}
class Post < Sequel::Model
set_primary_key [ :category, :title ]
end

post = Post.get('ruby', 'hello world')
post.key # => [ 'ruby', 'hello world' ]
{% endhighlight %}

p(attribution). example compiled from <http://code.google.com/p/ruby-sequel/wiki/SequelModels>.

DataMapper
----------

The latest DataMapper was designed from the ground up to support CPK(Composite Primary Keys)s:

{% highlight ruby linenos %}
class Pig
include DataMapper::Resource

property :id, Integer, :key => true
property :slug, String, :key => true
property :name, String
end

pig = Pig.get(1, 'Porky')

pig.key # => [ 1, 'Wilbur' ]
{% endhighlight %}

We declared our keys by adding the `:key => true` to the appropriate properties.
The order is important as it will determine the order keys are addressed
throughout the system.

Next, we mixed and matched the keys' types. `:id` is a Integer, but `:slug` is a
String. DataMapper didn't flinch when we defined a key column as a String
because it supports [Natural Keys](http://en.wikipedia.org/wiki/Natural_key) as
well.

Lastly, when retrieving rows via `get` and `[]` with a CPK(Composite Primary
Keys), we supplied the keys in the order they were defined within our model. For
example, we defined `:id` first, then `:slug` second; later, we retrieved Porky
by specifying his `:id` and `:slug` in the same order. Additionally, when we
asked Wilbur for his keys, he handed us an array in the order the keys were
defined.

We didn't need to mix in an external library to get support for CPK(Composite
Primary Keys)s, nor did we need to call a `set_primary_key` method and then
supply more than one key to it. DataMapper supports Composite Primary Keys
intuitively and without compromise!

In later "Spotlight On..." articles, we'll examine and demonstrate other
DataMapper features or persistence concepts as well as compare similar features
with other ORMs or libraries.

Contribute a "Spotlight On..." Article
--------------------------------------

p(newRelease). Got something important to say? Want something explained a little<br>
better or demonstrated? Contribute or request a "Spotlight On..." <br> article!
Email the [DataMapper Mailing List](http://groups.google.com/group/datamapper) with the request or <br>
contribution and we'll post it here.

0 comments on commit 6f27760

Please sign in to comment.