// Generated by IcedCoffeeScript 1.7.1-c
(function() {
  var PresetBase, constants, fs, iced, path, __iced_k, __iced_k_noop;

  iced = require('iced-runtime').iced;
  __iced_k = __iced_k_noop = function() {};

  fs = require('fs');

  path = require('path');

  constants = require('../constants');

  PresetBase = PresetBase = (function() {
    function PresetBase() {}

    PresetBase.prototype.handle = function(root_dir, path_to_file, cb) {

      /*
        root_dir is the base directory of what we're studying; we won't look above
        this for configuration files in most presets.
      
        cb() with NONE, DONT_IGNORE, or IGNORE
       */
      throw new Error('Preset::handle is a virtual function');
      return cb(constants.ignore_res.DONT_IGNORE);
    };

    PresetBase.parent_paths = function(root_dir, path_to_file) {

      /*
        returns an array of directory names, starting with
        the parent of path_to_file, and traversing up
        to root_dir; if path_to_file is a directory itself,
        should not include that. Example reply:
          [
            '/foo/root/car/3/'
            '/foo/root/car/'
            '/foo/root/'
          ]
       */
      var full_path_to_file, i, parts, rel_path_to_file, res, _i, _ref;
      res = [];
      full_path_to_file = path.resolve(root_dir, path_to_file);
      rel_path_to_file = path.relative(root_dir, full_path_to_file);
      parts = rel_path_to_file.split(path.sep);
      for (i = _i = 0, _ref = parts.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
        res.push(path.join(root_dir, path.join.apply(this, parts.slice(0, i))));
      }
      res.reverse();
      return res;
    };

    PresetBase.file_to_array = function(f, cb) {
      var body, err, line, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
      __iced_k = __iced_k_noop;
      ___iced_passed_deferral = iced.findDeferral(arguments);
      res = [];
      (function(_this) {
        return (function(__iced_k) {
          __iced_deferrals = new iced.Deferrals(__iced_k, {
            parent: ___iced_passed_deferral,
            filename: "/Users/max/src/keybase/codesign/src/preset/preset_base.iced",
            funcname: "PresetBase.file_to_array"
          });
          fs.readFile(f, {
            encoding: 'utf8'
          }, __iced_deferrals.defer({
            assign_fn: (function() {
              return function() {
                err = arguments[0];
                return body = arguments[1];
              };
            })(),
            lineno: 58
          }));
          __iced_deferrals._fulfill();
        });
      })(this)((function(_this) {
        return function() {
          var _i, _len, _ref;
          if (typeof body !== "undefined" && body !== null) {
            _ref = body.split(/[\n\r]+/);
            for (_i = 0, _len = _ref.length; _i < _len; _i++) {
              line = _ref[_i];
              res.push(line);
            }
          }
          return cb(res);
        };
      })(this));
    };

    return PresetBase;

  })();

  module.exports = PresetBase;

}).call(this);
