Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed the whole application in order to use titanium-jasmine
* updated to the last version of joli.js * now uses the unit tests framework [titanium-jasmine](https://github.com/guilhermechapiewski/titanium-jasmine) * added a bunch of tests, covering almost all the framework classes, under Resources/test * use a Makefile (freely inspired from [this post of Guilherme](http://guilherme.pro/2011/04/06/titanium-mobile-hack-execute-your-projects-from-the-command-line-using-make/))
- Loading branch information
1 parent
5d152e4
commit 9ecbf34
Showing
16 changed files
with
3,088 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Makefile to start Titanium Mobile project from the command line. | ||
# More info at http://github.com/guilhermechapiewski/titanium-jasmine | ||
|
||
PROJECT_NAME=joliDemo | ||
PROJECT_ROOT=$(shell pwd) | ||
|
||
run-iphone: | ||
@DEVICE_TYPE=iphone make run | ||
|
||
run-ipad: | ||
@DEVICE_TYPE=ipad make run | ||
|
||
run: | ||
@if [ "${DEVICE_TYPE}" == "" ]; then\ | ||
echo "Please run \"make run-[iphone|ipad]\" instead.";\ | ||
exit 1;\ | ||
fi | ||
@make launch-titanium | ||
|
||
clean: | ||
@rm -rf ${PROJECT_ROOT}/build/iphone/* | ||
@mkdir -p ${PROJECT_ROOT}//build/iphone/ | ||
@echo "Deleted: ${PROJECT_ROOT}/build/iphone/*" | ||
|
||
launch-titanium: | ||
@echo "Building with Titanium... (DEVICE_TYPE:${DEVICE_TYPE})" | ||
@mkdir -p ${PROJECT_ROOT}/build/iphone/ | ||
@PROJECT_NAME=${PROJECT_NAME} PROJECT_ROOT=${PROJECT_ROOT} DEVICE_TYPE=${DEVICE_TYPE} bash ${PROJECT_ROOT}/bin/titanium.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# joli.js demo project | ||
|
||
[joli.js](https://github.com/xavierlacot/joli.js) is a javascript ORM for the mobile applications framework [Appcelerator Titanium](http://www.appcelerator.com/). | ||
[joli.js](https://github.com/xavierlacot/joli.js) is a javascript ORM for the | ||
mobile applications framework [Appcelerator Titanium](http://www.appcelerator.com/). | ||
|
||
This repository contains a simple example which demonstrates how to use joli.js. This ready-to-use project has been tested with Titanium 1.6.2. | ||
This repository contains a simple example which demonstrates how to use joli.js. This ready-to-use project has been tested with Titanium 1.6.2, and uses the unit tests framework [titanium-jasmine](https://github.com/guilhermechapiewski/titanium-jasmine), based on the excellent [Jasmine BDD framework](http://pivotal.github.com/jasmine/). | ||
|
||
## How to start the project | ||
|
||
* download the source code, | ||
* go to the project root and type: | ||
|
||
$ make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,28 @@ | ||
Ti.include('lib/vendor/joli.js/joli.js'); | ||
Ti.include('lib/model/models.js'); | ||
|
||
Titanium.UI.setBackgroundColor('#fff'); | ||
|
||
// create a Window and a TextArea in it | ||
var win = Titanium.UI.createWindow({ | ||
title:'joli.js demonstration', | ||
backgroundColor:'#fff' | ||
}); | ||
var label = Titanium.UI.createLabel({ | ||
top:10, | ||
left:10, | ||
width:'auto', | ||
height:'auto' | ||
}); | ||
win.add(label); | ||
win.open(); | ||
|
||
|
||
|
||
joli.models.initialize(); | ||
|
||
// create some "City" records and persist them | ||
var newYork = models.city.newRecord({ | ||
name: 'New York', | ||
description: 'A big Apple' | ||
}); | ||
newYork.save(); | ||
var paris = models.city.newRecord({ | ||
name: 'Paris', | ||
description: 'Cheese and Baguette' | ||
}); | ||
paris.save(); | ||
|
||
label.text = 'New York and Paris saved in database'; | ||
|
||
// create a "human" record (not persisted) | ||
var john = models.human.newRecord({ | ||
first_name: 'John', | ||
last_name: 'Doe' | ||
}); | ||
label.text = label.text + '\nJohn created'; | ||
|
||
// move him to New York | ||
john.move('New York'); | ||
label.text = label.text + '\nJohn moved to New York'; | ||
|
||
// persist it | ||
john.save(); | ||
label.text = label.text + '\nJohn saved in database'; | ||
|
||
// create an other "human" record (not persisted) | ||
var sarah = models.human.newRecord({ | ||
first_name: 'Sarah', | ||
last_name: 'Sure' | ||
}); | ||
sarah.move('New York'); | ||
sarah.save(); | ||
label.text = label.text + '\nSarah created and saved in database'; | ||
|
||
// count the number of New York habitants | ||
var count = models.human.countIn('New York'); | ||
label.text = label.text + '\nThere are ' + count + ' inhabitants in New York'; | ||
|
||
var john = models.human.findOneById(1); | ||
john.move('Paris'); | ||
label.text = label.text + '\nJohn moved to Paris'; | ||
john.save(); | ||
|
||
var john = models.human.findOneById(1); | ||
label.text = label.text + '\nJohn now lives in: ' + john.getCityName(); | ||
(function(){ | ||
// load joli library and models definition file | ||
Ti.include('/lib/vendor/joli.js/joli.js'); | ||
Ti.include('/lib/model/models.js'); | ||
|
||
// load jasmine library and adapter | ||
Ti.include('/lib/vendor/jasmine/jasmine-1.0.2.js'); | ||
Ti.include('/lib/vendor/jasmine/jasmine-titanium.js'); | ||
|
||
// initialize the model | ||
joli.models.initialize(); | ||
|
||
// load test facility functions | ||
Ti.include('/test/main.js'); | ||
|
||
// load all the tests | ||
Ti.include('/test/joli.js'); | ||
Ti.include('/test/connection.js'); | ||
Ti.include('/test/migration.js'); | ||
Ti.include('/test/model.js'); | ||
Ti.include('/test/models.js'); | ||
Ti.include('/test/query.js'); | ||
Ti.include('/test/record.js'); | ||
|
||
// execute the tests | ||
jasmine.getEnv().addReporter(new jasmine.TitaniumReporter()); | ||
jasmine.getEnv().execute(); | ||
})(); |
Oops, something went wrong.