Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit 6f27760

Browse files
committed
Convert datamapper.org site to Jekyll, Markdown
* 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 <[email protected]>
1 parent c18384c commit 6f27760

File tree

99 files changed

+2727
-2290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2727
-2290
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
output/*
21
_site/
32
.DS_Store
43
*.swp

404.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: default
3+
title: File Not Found
4+
---
5+
6+
<h1>Sorry, that file could not be found</h1>
7+
8+
<p>We recently switched hosts, so some older links no longer exist.</p>
9+
<p>Try the menu above or see the <a href="http://wiki.github.com/datamapper/dm-core">wiki</a>.</p>

content/CNAME renamed to CNAME

File renamed without changes.

Rakefile

Lines changed: 0 additions & 24 deletions
This file was deleted.

Sitefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pygments: true
2+
permalink: none

_layouts/articles.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
layout: default
3+
---
4+
5+
{{ content }}

layouts/default.rhtml renamed to _layouts/default.html

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
---
2-
extension: html
3-
filter: erb
4-
---
51
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
62
"DTD/xhtml1-strict.dtd">
73
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
84

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

18-
<body id="<%= @page.body_id %>">
14+
<body id="home">
1915
<div id="content">
2016
<div id="header">
2117
<h1><a href="/">DataMapper</a></h1>
@@ -29,10 +25,10 @@ <h1><a href="/">DataMapper</a></h1>
2925
</ul>
3026
</div>
3127

32-
<%= @content %>
28+
{{ content }}
3329

3430
<div id="footer">
35-
<p>Copyright Dan Kubb, Sam Smoot <%= Time.now.year %></p>
31+
<p>Copyright Dan Kubb, Sam Smoot 2009</p>
3632
<p>Web Design by <a href="http://www.mr-eel.com/">Luke Matthew Sutton</a> - Community Maintained</p>
3733
</div>
3834
</div>
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
layout: articles
3+
categories: articles
4+
title: The Great Refactoring
5+
created_at: 2008-03-22T15:55:50-05:00
6+
summary: Change is afoot
7+
author: afrench and ssmoot
8+
---
9+
10+
{{ page.title }}
11+
================
12+
13+
"Tip" DataMapper (hosted on [github](http://github.com/datamapper/dm-core)) is
14+
going through a dramatic re-factor. Here's a quick summary of the anticipated
15+
NEW public API.
16+
17+
Not Just for Databases Anymore
18+
------------------------------
19+
20+
DataMapper's class terminology will change and 'de-couple' itself from
21+
database-specific terminology. Gone are "database", "table", "column" and
22+
"join". Say hello to "Repository", "Resource", "Property", and "Link".
23+
24+
"Why would you want to do that?", you ask. Ultimately it's because DataMapper
25+
will soon support different types of persistence layers, not just databases.
26+
It'll talk to all sorts of things like web services (REST and such), XML files,
27+
YAML files, non-relational databases, even custom file-types or services of your
28+
own design. Just implement an Adapter that conforms to a certain API and
29+
DataMapper could support any type of data store. No need for a completely
30+
separate library or anything.
31+
32+
As an added benefit, DataMapper become more "RESTful". [Ryan Tomayko](http://tomayko.com/writings/rest-to-my-wife)
33+
has a very good explanation
34+
of REST that all should read entitled [How I Explained REST to My Wife](http://tomayko.com/writings/rest-to-my-wife).
35+
36+
Model Definitions Are a Little Different
37+
----------------------------------------
38+
39+
Since we're changing up the terminology, model definitions are going to change
40+
up a little bit. Here's what a Planet model would look like using the new API:
41+
42+
{% highlight ruby linenos %}
43+
class Planet
44+
include DataMapper::Resource
45+
46+
resource_names[:legacy] = 'dying_planets'
47+
48+
property :name, String
49+
property :age, Integer
50+
property :core, String, :private => true
51+
end
52+
{% endhighlight %}
53+
54+
A couple of things are going on here. First, DataMapper::Base and
55+
DataMapper::Persistence are gone and replaced with <%=
56+
doc('DataMapper::Resource') %>. Next `set_table_name` has been replaced with
57+
`resource_names` hash where you specify which arena play occurs in. After that
58+
we have a couple of Property definitions that look a little different.
59+
60+
First off, Properties will no longer take `:symbols` for their types and instead
61+
take real constants like String, Integer, DateTime. Also on the docket are the
62+
ability to define your own custom types.
63+
64+
Think about that for a minute. If developers are able to define their own custom
65+
types with their own materialization and serialization methods, DataMapper will
66+
be able to support all kinds of wild data-types like GIS information, network
67+
information, marshaled objects, JSON...pretty much anything a developer might
68+
need, or want.
69+
70+
A Command-Line Interface
71+
------------------------
72+
73+
Taking a lesson from web frameworks, DataMapper will sport an interactive
74+
command-line so that you can browse your resources without the need to load up
75+
the entire environment of your application. Here's an example session:
76+
77+
{% highlight bash linenos %}
78+
$ dm mysql://root@localhost/great_musicians # connecting to a repository
79+
{% endhighlight %}
80+
81+
An IRB session boots up...
82+
83+
{% highlight ruby %}
84+
>> the_king = Person.first(:name => 'elvis')
85+
>> the_king.alive? # => maybe
86+
{% endhighlight %}
87+
88+
This is very similar to `script/console` in Rails or `merb -i` in Merb, only it
89+
won't load up the entire environment of your application, just your DataMapper
90+
resources and their associations, methods, and such. If you prefer "fat models",
91+
this will constitute the core of your application.
92+
93+
How This All Comes Together
94+
---------------------------
95+
96+
This is the coolest new feature of DataMapper: we're skipping all the way from
97+
0.3.0 to 0.9! Get excited, contact the press, fire up the blogosphere! Its a
98+
huge jump and we're honestly concerned that people may not be able to handle it.
99+
100+
Alright, so it's not _that_ big of a deal, but we're confident that all of this
101+
will get DataMapper so close to going 1.0 that we'll be able to taste it. To get
102+
there, DataMapper's more advanced features like single table inheritance,
103+
paranoia, and chained associations will be re-implimented to use all this new
104+
stuff, and then we're sure 0.9 will need a touch up or two.
105+
106+
So close....so very very close...
107+
108+
Stay tuned in to the [mailing list](http://groups.google.com/group/datamapper),
109+
check up on the [wiki](http://datamapper.org/), chat it up in
110+
[#datamapper](irc://irc.freenode.net/#datamapper) and watch
111+
[github commit messages](http://github.com/datamapper/dm-core/commits/master) for updates.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
layout: articles
3+
categories: articles
4+
title: Spotlight on... Composite Keys
5+
created_at: 2008-03-29T19:09:07-05:00
6+
summary: When a Primary Key Just Isn't Enough
7+
author: afrench and ssmoot
8+
---
9+
10+
{{ page.title }}
11+
================
12+
13+
For those of us who have taken a course on database design in college or
14+
university, you may have run across a concept called 'Composite Primary Keys'
15+
(or sometimes 'Compound Keys' or 'Concatenated Keys', and abbreviated
16+
CPK(Composite Primary Keys)s). It's usually right before you tackle JOINs and
17+
right after you fight with the "surrogate key" or "primary key" concept.
18+
19+
Boiling CPK(Composite Primary Keys)s down, they're just a way of identifying a
20+
row by multiple keys rather than one. So instead of an auto_incrementing
21+
"serial" primary key (as in `id`), you'd have a combination of `some_column` and
22+
`some_other_column` that would uniquely identify a row.
23+
24+
CPK(Composite Primary Keys)s aren't as prevalent in the Rails world as Serial
25+
Keys (such as the auto-incrementing `:id` column), but if you're going to
26+
support legacy, integration or reporting databases or just de-normalized schemas
27+
for performance reasons, they can be invaluable. So sure, Surrogate Keys are a
28+
great convenience, but sometimes they just aren't an option.
29+
30+
Let's briefly take a look at how a few ruby ORMs support Composite Primary Keys
31+
and then we'll talk about DataMapper's support for CPK(Composite Primary Keys)s.
32+
33+
ActiveRecord
34+
------------
35+
36+
In short, ActiveRecord doesn't support CPK(Composite Primary Keys)s without the
37+
help of an external library. [Dr. Nic Williams](http://drnicwilliams.com/about/)
38+
[Composite Keys](http://compositekeys.rubyforge.org/) is an effort to overcome
39+
this limitation.
40+
41+
Sequel
42+
------
43+
44+
Unlike ActiveRecord, Sequel supports CPK(Composite Primary Keys)s natively:
45+
46+
{% highlight ruby linenos %}
47+
class Post < Sequel::Model
48+
set_primary_key [ :category, :title ]
49+
end
50+
51+
post = Post.get('ruby', 'hello world')
52+
post.key # => [ 'ruby', 'hello world' ]
53+
{% endhighlight %}
54+
55+
p(attribution). example compiled from <http://code.google.com/p/ruby-sequel/wiki/SequelModels>.
56+
57+
DataMapper
58+
----------
59+
60+
The latest DataMapper was designed from the ground up to support CPK(Composite Primary Keys)s:
61+
62+
{% highlight ruby linenos %}
63+
class Pig
64+
include DataMapper::Resource
65+
66+
property :id, Integer, :key => true
67+
property :slug, String, :key => true
68+
property :name, String
69+
end
70+
71+
pig = Pig.get(1, 'Porky')
72+
73+
pig.key # => [ 1, 'Wilbur' ]
74+
{% endhighlight %}
75+
76+
We declared our keys by adding the `:key => true` to the appropriate properties.
77+
The order is important as it will determine the order keys are addressed
78+
throughout the system.
79+
80+
Next, we mixed and matched the keys' types. `:id` is a Integer, but `:slug` is a
81+
String. DataMapper didn't flinch when we defined a key column as a String
82+
because it supports [Natural Keys](http://en.wikipedia.org/wiki/Natural_key) as
83+
well.
84+
85+
Lastly, when retrieving rows via `get` and `[]` with a CPK(Composite Primary
86+
Keys), we supplied the keys in the order they were defined within our model. For
87+
example, we defined `:id` first, then `:slug` second; later, we retrieved Porky
88+
by specifying his `:id` and `:slug` in the same order. Additionally, when we
89+
asked Wilbur for his keys, he handed us an array in the order the keys were
90+
defined.
91+
92+
We didn't need to mix in an external library to get support for CPK(Composite
93+
Primary Keys)s, nor did we need to call a `set_primary_key` method and then
94+
supply more than one key to it. DataMapper supports Composite Primary Keys
95+
intuitively and without compromise!
96+
97+
In later "Spotlight On..." articles, we'll examine and demonstrate other
98+
DataMapper features or persistence concepts as well as compare similar features
99+
with other ORMs or libraries.
100+
101+
Contribute a "Spotlight On..." Article
102+
--------------------------------------
103+
104+
p(newRelease). Got something important to say? Want something explained a little<br>
105+
better or demonstrated? Contribute or request a "Spotlight On..." <br> article!
106+
Email the [DataMapper Mailing List](http://groups.google.com/group/datamapper) with the request or <br>
107+
contribution and we'll post it here.

0 commit comments

Comments
 (0)