Skip to content

Commit e1a3cf6

Browse files
committed
finished implementing stupid build system
1 parent eed3881 commit e1a3cf6

31 files changed

Lines changed: 2793 additions & 2796 deletions

Gruntfile.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,49 @@ module.exports = function(grunt) {
1313
},
1414
dist: {
1515
src: [
16-
'src/head.js.part',
17-
'src/jSQL.js',
18-
'src/foot.js.part'
16+
'src/wrapper/head.js.part',
17+
'src/error_handling/jSQL_Error.js',
18+
'src/error_handling/error_handling.js',
19+
'src/data_types/jSQLDataTypeList.js',
20+
'src/table/jSQLTable.js',
21+
'src/query_types/jSQLQuery.js',
22+
'src/query_types/jSQLDeleteQuery.js',
23+
'src/query_types/jSQLDropQuery.js',
24+
'src/query_types/jSQLInsertQuery.js',
25+
'src/query_types/jSQLSelectQuery.js',
26+
'src/query_types/jSQLUpdateQuery.js',
27+
'src/query_types/jSQLCreateQuery.js',
28+
'src/parser/jSQLParseQuery.js',
29+
'src/parser/jSQLWhereClause.js',
30+
'src/persistence/API.js',
31+
'src/persistence/persistenceManager.js',
32+
'src/sugar/createTable.js',
33+
'src/sugar/select.js',
34+
'src/sugar/update.js',
35+
'src/sugar/insertInto.js',
36+
'src/sugar/dropTable.js',
37+
'src/sugar/deleteFrom.js',
38+
'src/helpers/jSQLReset.js',
39+
'src/helpers/jSQLMinifier.js',
40+
'src/helpers/removeQuotes.js',
41+
'src/wrapper/foot.js.part'
1942
],
2043
dest: 'jSQL.js',
2144
},
2245
},
46+
'string-replace': {
47+
version: {
48+
files: {
49+
"jSQL.js": "jSQL.js"
50+
},
51+
options: {
52+
replacements: [{
53+
pattern: /{{ VERSION }}/g,
54+
replacement: '"<%= pkg.version %>"'
55+
}]
56+
}
57+
}
58+
},
2359
uglify: {
2460
options: {
2561
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> */'
@@ -32,10 +68,12 @@ module.exports = function(grunt) {
3268
});
3369

3470
grunt.loadNpmTasks('grunt-contrib-concat');
71+
grunt.loadNpmTasks('grunt-string-replace');
3572
grunt.loadNpmTasks('grunt-contrib-uglify');
3673

3774
grunt.registerTask('default', [
3875
'concat',
76+
'string-replace',
3977
'uglify'
4078
]);
4179
};

jSQL.js

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
var isNode = !!(typeof module !== 'undefined' && module.exports);
1111
var jSQL = (function(){
1212
"use strict";
13-
////////////////////////////////////////////////////////////////////////////
14-
// jSQL Error Handling /////////////////////////////////////////////////////
15-
////////////////////////////////////////////////////////////////////////////
1613

14+
/**
15+
* Error object constructor
16+
* @param {String} error_no
17+
*/
1718
function jSQL_Error(error_no) {
1819
this.error = error_no;
1920
this.stack = undefined;
@@ -96,6 +97,7 @@
9697
return "jSQL Error #"+this.error+" - "+this.message;
9798
};
9899
}
100+
99101

100102
var error_handler_function = function(){};
101103
var mute_jsql_errors = false;
@@ -107,12 +109,9 @@
107109
function onError(funct){
108110
if(typeof funct === "function") error_handler_function = funct;
109111
}
112+
110113

111-
////////////////////////////////////////////////////////////////////////////
112-
// jSQLDataTypeList ////////////////////////////////////////////////////////
113-
////////////////////////////////////////////////////////////////////////////
114-
115-
function jSQLDataTypeList(){
114+
function jSQLDataTypeList(){
116115
this.list = [{
117116
type: "NUMERIC",
118117
aliases: ["NUMBER", "DECIMAL", "FLOAT"],
@@ -332,10 +331,7 @@
332331
return _throw(new jSQL_Error("0007"));
333332
};
334333
}
335-
336-
////////////////////////////////////////////////////////////////////////////
337-
// jSQL Table constructor //////////////////////////////////////////////////
338-
////////////////////////////////////////////////////////////////////////////
334+
339335

340336
function jSQLTable(name, columns, data, types, keys, auto_increment){
341337
var self = this;
@@ -611,10 +607,7 @@
611607

612608
self.init(name, columns, data, types, keys, auto_increment);
613609
}
614-
615-
////////////////////////////////////////////////////////////////////////////
616-
// jSQL Query constructor //////////////////////////////////////////////////
617-
////////////////////////////////////////////////////////////////////////////
610+
618611

619612
function jSQLQuery(type){
620613
var self = this;
@@ -649,10 +642,7 @@
649642
};
650643
})(i);
651644
}
652-
653-
////////////////////////////////////////////////////////////////////////////
654-
// jSQL Query Type constructors ////////////////////////////////////////////
655-
////////////////////////////////////////////////////////////////////////////
645+
656646

657647
function jSQLDeleteQuery(){
658648
this.init = function(tablename){
@@ -733,6 +723,7 @@
733723
return this;
734724
};
735725
}
726+
736727

737728
function jSQLDropQuery(){
738729
this.init = function(tablename){
@@ -748,6 +739,7 @@
748739
this.fetch = function(){ return null; };
749740
this.fetchAll = function(){ return []; };
750741
}
742+
751743

752744
function jSQLInsertQuery(){
753745
this.init = function(table){
@@ -779,6 +771,7 @@
779771
this.fetch = function(){ return null; };
780772
this.fetchAll = function(){ return []; };
781773
}
774+
782775

783776
function jSQLSelectQuery(){
784777
this.init = function(columns){
@@ -863,6 +856,7 @@
863856
return this;
864857
};
865858
}
859+
866860

867861
function jSQLUpdateQuery(){
868862
this.init = function(table){
@@ -1020,10 +1014,6 @@
10201014
this.fetchAll = function(){ return []; };
10211015
}
10221016

1023-
////////////////////////////////////////////////////////////////////////////
1024-
// Parse String Query //////////////////////////////////////////////////////
1025-
////////////////////////////////////////////////////////////////////////////
1026-
10271017
function jSQLParseQuery(query){
10281018

10291019
// Predcit the correct casing for column and table names
@@ -1712,10 +1702,7 @@
17121702
return _throw(new jSQL_Error("0041"));
17131703
}
17141704
}
1715-
1716-
////////////////////////////////////////////////////////////////////////////
1717-
// Where caluse ////////////////////////////////////////////////////////////
1718-
////////////////////////////////////////////////////////////////////////////
1705+
17191706

17201707
function jSQLWhereClause(context){
17211708
var self = this;
@@ -1980,10 +1967,7 @@
19801967
return resultRowIndexes;
19811968
};
19821969
}
1983-
1984-
////////////////////////////////////////////////////////////////////////////
1985-
// Data Storage APIs ///////////////////////////////////////////////////////
1986-
////////////////////////////////////////////////////////////////////////////
1970+
19871971

19881972
var API = {
19891973

@@ -2386,10 +2370,7 @@
23862370

23872371
}
23882372
};
2389-
2390-
////////////////////////////////////////////////////////////////////////////
2391-
// Persistence Manager /////////////////////////////////////////////////////
2392-
////////////////////////////////////////////////////////////////////////////
2373+
23932374

23942375
var persistenceManager = new (function(){
23952376
var self = this;
@@ -2589,10 +2570,6 @@
25892570

25902571
})();
25912572

2592-
////////////////////////////////////////////////////////////////////////////
2593-
// Syntactic sugar /////////////////////////////////////////////////////////
2594-
////////////////////////////////////////////////////////////////////////////
2595-
25962573
function createTable(name, columnsOrData, types, keys, auto_increment){
25972574

25982575
// allow for all params to be passed in a single object
@@ -2653,15 +2630,18 @@
26532630
if(!Array.isArray(keys)) keys=[keys];
26542631
return new jSQLQuery("CREATE").init(name, columnsOrData, types, keys, auto_increment);
26552632
}
2633+
26562634

26572635
function select(cols){
26582636
if(!Array.isArray(cols)) cols=[cols];
26592637
return new jSQLQuery("SELECT").init(cols);
26602638
}
2639+
26612640

26622641
function update(table){
26632642
return new jSQLQuery("UPDATE").init(table);
26642643
}
2644+
26652645

26662646
function insertInto(tablename){
26672647
return new jSQLQuery("INSERT").init(tablename);
@@ -2670,20 +2650,19 @@
26702650
function dropTable(tablename){
26712651
return new jSQLQuery("DROP").init(tablename);
26722652
}
2653+
26732654

26742655
function deleteFrom(tablename){
26752656
return new jSQLQuery("DELETE").init(tablename);
26762657
}
2677-
2678-
////////////////////////////////////////////////////////////////////////////
2679-
// Helper/Misc Methods /////////////////////////////////////////////////////
2680-
////////////////////////////////////////////////////////////////////////////
2658+
26812659

26822660
function jSQLReset(){
26832661
jSQL.tables = {};
26842662
jSQL.commit();
26852663
}
2686-
2664+
2665+
26872666
function jSQLMinifier(sql){
26882667
var cleanSQL = "";
26892668
var lines = sql.split("\n");
@@ -2756,7 +2735,7 @@
27562735
}
27572736

27582737
return {
2759-
version: 0,
2738+
version: "2.9.1",
27602739
tables: {},
27612740
query: jSQLParseQuery,
27622741
createTable: createTable,

jSQL.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"devDependencies": {
3737
"grunt": "^1.0.1",
3838
"grunt-contrib-concat": "^1.0.1",
39-
"grunt-contrib-uglify": "^3.1.0"
39+
"grunt-contrib-uglify": "^3.1.0",
40+
"grunt-string-replace": "^1.3.1"
4041
}
4142
}

0 commit comments

Comments
 (0)