Commit a52e17b6 authored by François Perrad's avatar François Perrad

switch to MkDocs

parent ede45529
/site
/MANIFEST
/README.html
/*.tar
......
......@@ -31,8 +31,6 @@ my @files = qw{MANIFEST}; \
while (<>) { \
chomp; \
next if m{^\.}; \
next if m{^doc/\.}; \
next if m{^doc/google}; \
next if m{^rockspec/}; \
push @files, $$_; \
} \
......@@ -68,10 +66,7 @@ dist.info:
tag:
git tag -a -m 'tag release $(VERSION)' $(VERSION)
doc:
git read-tree --prefix=doc/ -u remotes/origin/gh-pages
MANIFEST: doc
MANIFEST:
git ls-files | perl -e '$(manifest_pl)' > MANIFEST
$(TARBALL): MANIFEST
......@@ -79,8 +74,6 @@ $(TARBALL): MANIFEST
perl -ne 'print qq{lua-CoatPersistent-$(VERSION)/$$_};' MANIFEST | \
tar -zc -T - -f $(TARBALL)
rm lua-CoatPersistent-$(VERSION)
rm -rf doc
git rm doc/*
dist: $(TARBALL)
......@@ -127,8 +120,10 @@ coveralls:
README.html: README.md
Markdown.pl README.md > README.html
gh-pages:
mkdocs gh-deploy --clean
clean:
rm -rf doc
rm -f MANIFEST *.bak *.db src/luacov.*.out src/*.db src/*.png test/*.png *.rockspec README.html
realclean: clean
......
## Overview
lua-CoatPersistent is an Object-Relational Mapping
for [lua-Coat](http://fperrad.github.io/lua-Coat).
It is built over the modules
[LuaSQL](http://www.keplerproject.org/luasql/) and
[Dado](http://www.ccpa.puc-rio.br/software/dado).
It could support all database engine which has a driver in LuaSQL.
Another variant is built over the module
[lsqlite3](http://lua.sqlite.org/) instead of LuaSQL.
## Lineage
lua-CoatPersistent is a Lua port of
[Coat::Persistent](http://search.cpan.org/~sukria/Coat-Persistent/)
, a Perl module, which is inspired by Ruby on Rails
[Active Record](http://rubyonrails.org/).
## Status
lua-CoatPersistent is in early stage.
It's developed for Lua 5.1, 5.2 & 5.3.
## Download
lua-CoatPersistent source can be downloaded from
[GitHub](http://github.com/fperrad/lua-CoatPersistent/releases/).
## Installation
Two variants are available, LuaSQL or lsqlite3 based
lua-CoatPersistent is available via LuaRocks:
luarocks install lua-coatpersistent-luasql
# luarocks install lua-coatpersistent-lsqlite3
or manually, with:
make install.luasql
# make install.lsqlite3
## Test
The test suite requires the module
[lua-TestMore](http://fperrad.github.io/lua-TestMore/)
and LuaSQL-SQLite3.
make test.luasql
# make test.lsqlite3
## Copyright and License
Copyright © 2010-2014 François Perrad
[![OpenHUB](http://www.openhub.net/accounts/4780/widgets/account_rank.gif)](http://www.openhub.net/accounts/4780?ref=Rank)
[![LinkedIn](http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif)](http://www.linkedin.com/in/fperrad)
This library is licensed under the terms of the MIT/X11 license,
like Lua itself.
## Reference
### Global Functions
#### persistent( modname, [ { primary_key = val, table_name = val } ] )
Create a Coat Persistent class as a standard Lua module.
The default `primary_key` is `id`.
The default `table_name` is `modname`
with lower case and `.` replaced by `_`.
### Functions in the built Class
#### create( args )
Instanciates and saves and returns an object or an array of object.
#### connection()
Returns the current LuaSQL connection object.
#### obj:delete()
Deletes the object.
#### establish_connection( driver, options, ... )
Create and returns an connection using the LuaSQL driver.
`options` are forwarded to the LuaSQL method `env:conn()`.
#### find()
Returns an iterator over all records.
#### find( id )
Returns an iterator over record with the primary key is the number `id`.
#### find( condition )
Returns an iterator over record selected by the SQL `condition`.
#### find_by_*name*( val )
Returns an iterator over record with the attribute name is `val`.
#### find_by_sql( sql )
Returns an iterator over record found by a raw SQL `select` request.
#### has_p.name = { options }
Adds a persistent attribute name, all options are forwarded to `Coat.has`.
And adds a method _`find_by_name`_.
#### has_one.name = { class_name = val, foreign_key = val }
#### has_many.name = { class_name = val }
#### obj:save()
Saves the object and returns the value of its primary key.
## Examples
```lua
require 'Coat.Persistent'
persistent 'Person'
has_p.name = { is = 'rw', isa = 'string' }
has_p.age = { is = 'rw', isa = 'number' }
sql_create = [[
CREATE TABLE person (
id INTEGER,
name CHAR(64),
age INTEGER
)
]]
```
```lua
local conn = Person.establish_connection('sqlite3', 'test.db')
conn:execute(Person.sql_create)
```
```lua
Person.create { name = 'John', age = 23 }
Person.create {
{ name = 'Brenda', age = 31 },
{ name = 'Nate', age = 34 },
{ name = 'Dave', age = 29 },
}
for p in Person.find() do
print(p.id, p.name, p.age)
end
p = Person.find_by_name('Brenda')()
p.age = p.age + 1
p:save()
p = Person.find(1)()
p:delete()
for p in Person.find 'age > 30' do
print(p.id, p.name, p.age)
end
```
## Reference
Just an alternate implementation using
[LuaSQLite3](http://lua.sqlite.org/) (instead of
[LuaSQL](http://www.keplerproject.org/luasql/) library).
## Examples
```lua
require 'Coat.Persistent.lsqlite3' -- instead of require 'Coat.Persistent'
```
site_name: lua-CoatPersistent
site_description: an ORM for lua-Coat
site_author: François Perrad
repo_url: https://github.com/fperrad/lua-CoatPersistent
pages:
- Home: index.md
- API:
- Coat.Persistent: persistent.md
- Coat.Persitent.lsqlite3: sqlite3.md
theme: mkdocs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment