/*jslint es5:true, indent:2, maxlen:80, node:true*/
/*jslint nomen:true*/ // Underscore.JS and __dirname
'use strict';

// Node.JS standard modules

var path = require('path');

// 3rd-party modules

// custom modules

var Action = require(path.join(__dirname, 'action'));

// promise-bound anti-callbacks

// this module

/**
 * represents a collection of actions
 * @constructor
 * @param {Array} [actions] initial set of Action objects
 */
function ActionList(actions) {
  var arr = [];
  if (Array.isArray(actions)) {
    arr.push.apply(arr, actions);
  }

  /**
   * populate self based on comparison of two lists of files
   * @param {FileList} local list of files at the local source
   * @param {FileList} remote list of files at the remote destination
   */
  arr.compareFileLists = function (local, remote) {
    var index, otherFile;
    local.forEach(function (file) {
      index = remote.indexOf(file.path);
      if (index === -1) {
        arr.push(new Action({ file: file, doUpload: true }));
      } else {
        otherFile = remote[index];
        if (file.size !== otherFile.size) {
          arr.push(new Action({ file: file, doUpload: true }));
        } else if (file.md5 !== otherFile.md5) {
          arr.push(new Action({ file: file, doUpload: true }));
        } else if (file.mime !== otherFile.mime) {
          arr.push(new Action({ file: file, doHeaders: true }));
        }
      }
    });
    remote.forEach(function (file) {
      index = local.indexOf(file.path);
      // TODO: handle GZIP'ed files that aren't locally present
      if (index === -1) {
        arr.push(new Action({ file: file, doDelete: true }));
      }
    });
  };

  return arr;
}
ActionList.prototype = {};

// exports

module.exports = ActionList;

@@ -560,14 +560,220 @@
 %0A%0A  
+Object.keys(ActionList.prototype).forEach(function (method) %7B%0A    arr%5Bmethod%5D = ActionList.prototype%5Bmethod%5D;%0A  %7D);%0A%0A  return arr;%0A%7D%0AActionList.prototype = %7B%7D;%0AActionList.prototype.constructor = ActionList;%0A%0A
 /**%0A
-  
  * p
@@ -827,18 +827,16 @@
 f files%0A
-  
  * @para
@@ -888,18 +888,16 @@
  source%0A
-  
  * @para
@@ -960,19 +960,32 @@
 ion%0A
-  
  */%0A
-  arr
+ActionList.prototype
 .com
@@ -1027,18 +1027,16 @@
 mote) %7B%0A
-  
   var in
@@ -1049,20 +1049,35 @@
 therFile
+, me;%0A  me = this
 ;%0A
-  
   local.
@@ -1098,34 +1098,32 @@
 on (file) %7B%0A    
- 
- 
 index = remote.i
@@ -1141,26 +1141,24 @@
 .path);%0A    
-  
 if (index ==
@@ -1163,37 +1163,34 @@
 === -1) %7B%0A      
-  arr
+me
 .push(new Action
@@ -1224,26 +1224,24 @@
 ue %7D));%0A    
-  
 %7D else %7B%0A   
@@ -1243,18 +1243,16 @@
 %7B%0A      
- 
- 
 otherFil
@@ -1270,18 +1270,16 @@
 index%5D;%0A
-  
       if
@@ -1312,37 +1312,34 @@
 size) %7B%0A        
-  arr
+me
 .push(new Action
@@ -1371,34 +1371,32 @@
 true %7D));%0A      
-  
 %7D else if (file.
@@ -1420,37 +1420,34 @@
 .md5) %7B%0A        
-  arr
+me
 .push(new Action
@@ -1477,26 +1477,24 @@
 : true %7D));%0A
-  
       %7D else
@@ -1534,29 +1534,26 @@
 ) %7B%0A        
-  arr
+me
 .push(new Ac
@@ -1602,30 +1602,22 @@
     
-  
 %7D%0A    
- 
- 
 %7D%0A
-  
   %7D);%0A
-  
   re
@@ -1643,26 +1643,24 @@
 on (file) %7B%0A
-  
     index = 
@@ -1689,74 +1689,8 @@
 h);%0A
-      // TODO: handle GZIP'ed files that aren't locally present%0A  
     
@@ -1715,21 +1715,18 @@
 %7B%0A      
-  arr
+me
 .push(ne
@@ -1776,66 +1776,16 @@
     
-  
 %7D%0A  
- 
- 
 %7D);%0A
-  %7D;%0A%0A  return arr;%0A%7D%0AActionList.prototype = %7B
 %7D;%0A%0A

refactor ActionList to look more like a typical constructor / prototype