What have you found for these years?

2008-08-15

[ANN] dm-mapping 0.5.0


dm-mapping version 0.5.0
by Lin Jen-Shin (a.k.a. godfat 真常)
http://github.com/godfat/dm-mapping

== DESCRIPTION

DataMapper plugin that helps you manipulate an existing database.
It creates mappings between existing columns and model's properties.

== CHANGES

=== dm-mapping 0.5.0, 2008-08-14
* feature added
- added mysql support.
- reflect size 65535 in TEXT for sqlite3.
* bug fixed
- reflect VARCHAR(size) instead of default size in sqlite3.
* misc
- renamed sqlite3adapter to sqlite3_adapter.

== LINKS

* rdoc[http://ludy.rubyforge.org/dm-mapping]
* github-project[http://github.com/godfat/dm-mapping]
* rubyforge-project[http://rubyforge.org/projects/ludy]

== SYNOPSIS

require 'dm-mapping'
dm = DataMapper.setup :default, 'sqlite3:db/development.sqlite3'

class User
include DataMapper::Resource
# mapping all
mapping /.*/

# mapping for ended with _at, and started with salt_
mapping /_at$/, /^salt_/

# mapping id and email
mapping :id, :email

# mapping all fields with type String, and id
mapping String, :id

# mapping login, and all fields with type Integer
mapping :login, Integer
end

# there's no guarantee of the order in storages array
dm.storages
# => ['users']

# there's no guarantee of the order in fields array
User.fields.sort
# => [['created_at', DateTime, {:nullable => true}],
['email', String, {:nullable => true, :size => 255,
:default => 'nospam@nospam.tw'}],
['id', Integer, {:nullable => false, :serial => true,
:key => true}],
['salt_first', String, {:nullable => true, :size => 50}],
['salt_second', String, {:nullable => true, :size => 50}]]

dm.fields('users').sort == User.fields.sort
# => true

dm.storages_and_fields
# => {'users' => [['id', Integer, {:nullable => false,
:serial => true,
:key => true}],
['email', String, {:nullable => true,
:default => 'nospam@nospam.tw'}],
['created_at', DateTime, {:nullable => true}],
['salt_first', String, {:nullable => true, :size => 50}],
['salt_second', String, {:nullable => true, :size => 50}]]}

# there's no guarantee of the order in returned array
dm.auto_genclass!
# => [DataMapper::Mapping::User,
DataMapper::Mapping::SchemaInfo,
DataMapper::Mapping::Session]

# you can change the scope of generated models:
dm.auto_genclass! Object
# => [User, SchemaInfo, Session]

== REQUIREMENTS

* dm-core 0.9.3
* at least one do_* adapter (currently supports sqlite3 and mysql)

== INSTALL

> sudo gem install dm-mapping

== LICENSE

Apache License 2.0

Copyright (c) 2008, Lin Jen-Shin (a.k.a. godfat 真常)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

0 retries:

Post a Comment

All texts are licensed under CC Attribution 3.0