Skip to content

Commit

Permalink
Rename ardent → osom
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 9, 2016
1 parent bcef4eb commit a5bd829
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 77 deletions.
14 changes: 0 additions & 14 deletions CHANGELOG.md

This file was deleted.

32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# ardent
# osom

![Last version](https://img.shields.io/github/tag/Kikobeats/ardent.svg?style=flat-square)
[![Build Status](http://img.shields.io/travis/Kikobeats/ardent/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/ardent)
[![Dependency status](http://img.shields.io/david/Kikobeats/ardent.svg?style=flat-square)](https://david-dm.org/Kikobeats/ardent)
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/ardent.svg?style=flat-square)](https://david-dm.org/Kikobeats/ardent#info=devDependencies)
[![NPM Status](http://img.shields.io/npm/dm/ardent.svg?style=flat-square)](https://www.npmjs.org/package/ardent)
![Last version](https://img.shields.io/github/tag/Kikobeats/osom.svg?style=flat-square)
[![Build Status](http://img.shields.io/travis/Kikobeats/osom/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/osom)
[![Dependency status](http://img.shields.io/david/Kikobeats/osom.svg?style=flat-square)](https://david-dm.org/Kikobeats/osom)
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/osom.svg?style=flat-square)](https://david-dm.org/Kikobeats/osom#info=devDependencies)
[![NPM Status](http://img.shields.io/npm/dm/osom.svg?style=flat-square)](https://www.npmjs.org/package/osom)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats)

> Fancy Object Schema Modeling. Inspired in [Mongoose Schema](https://github.com/Automattic/mongoose#defining-a-model) but out of the box.
> An Awesome [/osom/] Object Schema Modeling. Inspired in [Mongoose Schema](https://github.com/Automattic/mongoose#defining-a-model).
## Install

```bash
$ npm install ardent --save
$ npm install osom --save
```

If you want to use in the browser (powered by [Browserify](http://browserify.org/)):

```bash
$ bower install ardent --save
$ bower install osom --save
```

and later link in your HTML:

```html
<script src="bower_components/ardent/dist/ardent.js"></script>
<script src="bower_components/osom/dist/osom.js"></script>
```
## Usage

```js
var Ardent = require('ardent')
var osom = require('osom')

function trim (str) {
return str.trim()
Expand All @@ -45,15 +45,15 @@ var schema = {
}

// creating schema validation
var ardent = Ardent(schema)
var validator = osom(schema)

// schema factory
ardent({age: ' 23 '}).should.be.eql({age: '23'})
validator({age: ' 23 '}).should.be.eql({age: '23'})
```

## API

### ardent(schema, [options])
### osom(schema, [options])

#### schema

Expand All @@ -76,7 +76,7 @@ var basicSchema = {

##### Advanced

The *basic* mode is a simplification of the *advanced* mode.
The *basic* mode is a simplification of the *advanced* mode.

While in *basic* mode only is possible setup `type` casting, in *advanced* mode you can setup more things providing a configurable `object`.

Expand All @@ -90,7 +90,7 @@ The following keys setup your rule:
function trim (str) {
return str.trim()
}

var advancedSchema = {
age: {
type: String,
Expand Down
12 changes: 6 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ardent",
"description": "Fancy Object Schema Modeling. Inspired in Mongoose Schema defintion but out of box.",
"homepage": "https://github.com/Kikobeats/ardent",
"name": "osom",
"description": "An Awesome [/osom/] Object Schema Modeling",
"homepage": "https://github.com/Kikobeats/osom",
"version": "1.0.0",
"main": "./dist/ardent.js",
"main": "./dist/osom.js",
"authors": [
{
"email": "josefrancisco.verdu@gmail.com",
Expand All @@ -13,10 +13,10 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/kikobeats/ardent.git"
"url": "git+https://github.com/kikobeats/osom.git"
},
"bugs": {
"url": "https://github.com/Kikobeats/ardent/issues"
"url": "https://github.com/Kikobeats/osom/issues"
},
"keywords": [
"modeling",
Expand Down
7 changes: 0 additions & 7 deletions dist/ardent.js

This file was deleted.

4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ardent</title>
<title>osom</title>
</head>
<body>
<script src="ardent.js" type="text/javascript" charset="utf-8"></script>
<script src="osom.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function throwValidationError (name, value, desription) {
throw new TypeError(msg)
}

function Ardent (schemaBlueprint, globalRules) {
if (!(this instanceof Ardent)) return new Ardent(schemaBlueprint, globalRules)
function Osom (schemaBlueprint, globalRules) {
if (!(this instanceof Osom)) return new Osom(schemaBlueprint, globalRules)
globalRules = globalRules || {}

var schemaTypes = {}
Expand All @@ -61,7 +61,7 @@ function Ardent (schemaBlueprint, globalRules) {
return schema
}, {})

function ardent (obj) {
function osom (obj) {
obj = obj || {}

return reduce(schema, function applyRule (objSchema, rule, name) {
Expand Down Expand Up @@ -92,7 +92,7 @@ function Ardent (schemaBlueprint, globalRules) {
}, {})
}

return ardent
return osom
}

module.exports = Ardent
module.exports = Osom
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ardent",
"description": "Fancy Object Schema Modeling. Inspired in Mongoose Schema defintion but out of box.",
"homepage": "https://github.com/Kikobeats/ardent",
"name": "osom",
"description": "An Awesome [/osom/] Object Schema Modeling",
"homepage": "https://github.com/Kikobeats/osom",
"version": "1.0.0",
"main": "./index.js",
"author": {
Expand All @@ -11,10 +11,10 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/kikobeats/ardent.git"
"url": "git+https://github.com/kikobeats/osom.git"
},
"bugs": {
"url": "https://github.com/Kikobeats/ardent/issues"
"url": "https://github.com/Kikobeats/osom/issues"
},
"keywords": [
"modeling",
Expand Down
44 changes: 22 additions & 22 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
'use strict'

require('should')
var Ardent = require('..')
var osom = require('..')

describe('schema defintion', function () {
it('simple rule', function () {
[{age: Number}, {age: { type: Number }}].forEach(function (rule) {
Ardent(rule)({age: '23'}).should.be.eql({age: 23})
osom(rule)({age: '23'}).should.be.eql({age: 23})
})
})

Expand All @@ -20,8 +20,8 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
ardent().should.be.eql({age: 23})
var validator = osom(schema)
validator().should.be.eql({age: 23})
})

it('based in a fn', function () {
Expand All @@ -31,8 +31,8 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
ardent().should.be.eql({age: 23})
var validator = osom(schema)
validator().should.be.eql({age: 23})
})
})

Expand All @@ -48,8 +48,8 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
ardent({age: ' 23 '}).should.be.eql({age: '23'})
var validator = osom(schema)
validator({age: ' 23 '}).should.be.eql({age: '23'})
})

describe('support required values', function () {
Expand All @@ -61,9 +61,9 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
var validator = osom(schema)
var errMessage = "Expected a {string} for 'age'."
;(function () { ardent() }).should.throw(errMessage)
;(function () { validator() }).should.throw(errMessage)
})

it('custom error message', function () {
Expand All @@ -74,9 +74,9 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
var validator = osom(schema)
var errMessage = 'your message here'
;(function () { ardent() }).should.throw(errMessage)
;(function () { validator() }).should.throw(errMessage)
})
})

Expand All @@ -89,10 +89,10 @@ describe('schema defintion', function () {
}

var errMessage = "Expected a {string} for 'age'."
var ardent = Ardent(schema)
var validator = osom(schema)

;[null, {age: 23}].forEach(function (obj) {
;(function () { ardent(obj) }).should.throw(errMessage)
;(function () { validator(obj) }).should.throw(errMessage)
})
})

Expand All @@ -107,9 +107,9 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
var validator = osom(schema)
var errMessage = "Fail '25' validation for 'age'."
;(function () { ardent({age: 25}) }).should.throw(errMessage)
;(function () { validator({age: 25}) }).should.throw(errMessage)
})

it('based in a object key', function () {
Expand All @@ -124,9 +124,9 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
var validator = osom(schema)
var errMessage = "Fail '25' validation for 'age'."
;(function () { ardent({age: 25}) }).should.throw(errMessage)
;(function () { validator({age: 25}) }).should.throw(errMessage)
})

it('custom error message', function () {
Expand All @@ -142,9 +142,9 @@ describe('schema defintion', function () {
}
}

var ardent = Ardent(schema)
var validator = osom(schema)
var errMessage = 'expected a millenial instead of 25!'
;(function () { ardent({age: 25}) }).should.throw(errMessage)
;(function () { validator({age: 25}) }).should.throw(errMessage)
})
})
})
Expand All @@ -165,7 +165,7 @@ describe('behavior', function () {
transform: [trim]
}

var ardent = Ardent(schema, globalFields)
ardent({age: ' 23 '}).should.be.eql({age: '23'})
var validator = osom(schema, globalFields)
validator({age: ' 23 '}).should.be.eql({age: '23'})
})
})

0 comments on commit a5bd829

Please sign in to comment.