* <code>
*
-var x = new JSON.Packer();
+var x = new JSON.Packer(target, debugTarget);
+
x.files = an array of files
x.srcfiles = array of files (that list other files...) << not supported?
x.target = "output.pathname.js"
*
*/
-const Packer = function(cfg)
+namespace JSDOC
{
-
- XObject.extend(this, cfg);
- var _this = this;
- if (this.srcfiles && this.srcfiles.length) {
- this.srcfiles.forEach(function(f) {
- _this.loadSourceFile(f);
- });
-
- }
-
- if (!this.files) {
- throw "No Files";
- }
-
- var link = false;
- if (cfg.autoBuild) {
-
- function dateString(d){
- function pad(n){return n<10 ? '0'+n : n}
- return d.getFullYear() +
- pad(d.getMonth()+1)+
- pad(d.getDate())+'_'+
- pad(d.getHours())+
- pad(d.getMinutes())+
- pad(d.getSeconds());
- }
-
-
- var version = 0;
- this.files.forEach(function(f) {
- version = Math.max(File.mtime(f), version);
- });
- var version = dateString(new Date(version));
-
- var dirname = GLib.path_get_dirname(this.files[0]);
- var outname = this.module ? this.module : GLib.path_get_basename(dirname);
- this.target = dirname + '/compiled/' + outname + '-' + version + '.js';
- if (File.exists(this.target)) {
- print("Target file already exists: " + this.target);
- Seed.quit();
- }
- this.prefix = dirname +'/';
- this.translateJSON = dirname + '/compiled/_translation_.js';
-
- }
-
- print(this.translateJSON);
- this.timer = new Date() * 1;
- this.packAll();
-
-
-
-
-}
-Packer.prototype = {
- /**
- * @cfg {String} srcfiles file containing a list of files/or classes to use.
- */
- srcfile : false,
-
- /**
- * @cfg {Array} files list of files to compress (must be full path)
- */
- files : false,
- /**
- * @cfg {String} target to write files to - must be full path.
- */
- target : '',
- /**
- * @cfg {Boolean} autoBuild - turn on autobuild feature (puts files in compiled directory,
- * and enables translation toolkit.
- */
- autoBuild : false,
- /**
- * @cfg {String} module used with autoBuild to force a file name
- */
- module: false,
- /**
- * @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
- */
- debugTarget : '', // merged file without compression.
- /**
- * @cfg {String} debugTranslateTarget target to write files debug version
- * to (uncompacted) but with translation- must be full path.
- */
-
- debugTranslateTarget : '',
-
- /**
- * @cfg {String} tmpDir (optional) where to put the temporary files.
- * if you set this, then files will not be cleaned up
- */
- tmpDir : '/tmp',
+
+ public class Packer : Object
+ {
+ /**
+ * @cfg {String} target to write files to - must be full path.
+ */
+ string target;
+ /**
+ * @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
+ */
+ string debugTarget;
+
+ /**
+ * @cfg {String} tmpDir (optional) where to put the temporary files.
+ * if you set this, then files will not be cleaned up
+ */
+ public tmpDir = "/tmp"; // FIXME??? in ctor?
+
+ Gee.ArrayList<string> files;
+
+ public Packer(string target, string debugTarget)
+ {
+ this.target = target;
+ this.debugTarget = debugTarget;
+
+ }
+
+ public void loadSourceIndexes(Gee.ArrayList<string> indexes)
+ {
+ foreach(var f in indexes) {
+ this.loadSourceIndex(f);
+ }
+ }
+
+ public void loadFiles(Gee.ArrayList<string> fs)
+ {
+ foreach(var f in fs) {
+ this.files.add(f); //?? easier way?
+ }
+ }
+
+ public void pack()
+ {
+ if (!this.files) {
+ throw new Packer.ArgumentError("No Files loaded before pack() called");
+ }
+ this.packAll();
+ }
+
+
+
+
translateJSON : '', // json based list of strings in all files.
*
*/
- loadSourceFile : function(srcfile)
+ loadSourceIndexes : function(srcfile)
{
var lines = File.read(srcfile).split("\n");
var _this = this;