<commit_before>var
  Vaulted = {},
  Promise = require('bluebird'),
  _ = require('lodash');

module.exports = function extend(Proto) {
  Vaulted.getMountsEndpoint = _.partial(Proto.validateEndpoint, 'sys/mounts/:id');
  Vaulted.getRemountEndpoint = _.partial(Proto.validateEndpoint, 'sys/remount');
  _.extend(Proto, Vaulted);
};

Vaulted.getMounts = function getMounts() {
  return this.getMountsEndpoint()
    .get({
      headers: this.headers
    })
    .promise()
    .bind(this)
    .then(function gotMounts(mounts) {
      this.mounts = mounts;
      return this.mounts;
    });
};

Vaulted.deleteMount = function deleteMount(options) {
  options = options || {};
  return this.getMountsEndpoint()
    .delete({
      id: options.id,
      headers: this.headers
    })
    .promise()
    .bind(this)
    .then(function deletedMount() {
      delete this.mounts[options.id];
      return this;
    });
};

Vaulted.createMount = function createMount(options) {
  options = options || { body: null, id: null };
  var new_mount = {
    type: options.body.type,
    description: options.body.description
  };
  return this.getMountsEndpoint()
    .post({
      headers: this.headers,
      id: options.id,
      body: new_mount
    })
    .promise()
    .bind(this)
    .then(function createdMount() {
      this.mounts[options.id+'/'] = new_mount;
      return this.mounts;
    });
};

Vaulted.reMount = function reMount(options) {
  options = options || {};
  var
    to_mount = options.to,
    from_mount;
  try {
    if( _.isUndefined(to_mount) || to_mount.length === 0) {
      throw new Error('No "to" parameter sent');
    }
    if(_.isUndefined(options.from) || options.from.length === 0) {
      throw new Error('No "from" parameter sent');
    }
    from_mount = this.mounts[options.from];
    if(_.isUndefined(from_mount)) {
      throw new Error();
    }
  } catch(ex) {
    return Promise.reject(new Error('Could not find existing mount named: ' + options.from));
  }
  return this.getRemountEndpoint()
    .post({
      headers: this.headers,
      body: {
        from: options.from,
        to: to_mount
      }
    })
    .promise()
    .bind(this)
    .then(function remounted() {
      this.mounts[to_mount] = this.mounts[options.from];
      delete this.mounts[options.from];
      return this.mounts;
    });
};

<commit_msg>Fixed issue w/ mount naming during remount action<commit_after>var
  Vaulted = {},
  Promise = require('bluebird'),
  _ = require('lodash');

module.exports = function extend(Proto) {
  Vaulted.getMountsEndpoint = _.partial(Proto.validateEndpoint, 'sys/mounts/:id');
  Vaulted.getRemountEndpoint = _.partial(Proto.validateEndpoint, 'sys/remount');
  _.extend(Proto, Vaulted);
};

Vaulted.getMounts = function getMounts() {
  return this.getMountsEndpoint()
    .get({
      headers: this.headers
    })
    .promise()
    .bind(this)
    .then(function gotMounts(mounts) {
      this.mounts = mounts;
      return this.mounts;
    });
};

Vaulted.deleteMount = function deleteMount(options) {
  options = options || {};
  return this.getMountsEndpoint()
    .delete({
      id: options.id,
      headers: this.headers
    })
    .promise()
    .bind(this)
    .then(function deletedMount() {
      delete this.mounts[options.id];
      return this;
    });
};

Vaulted.createMount = function createMount(options) {
  options = options || { body: null, id: null };
  var new_mount = {
    type: options.body.type,
    description: options.body.description
  };
  return this.getMountsEndpoint()
    .post({
      headers: this.headers,
      id: options.id,
      body: new_mount
    })
    .promise()
    .bind(this)
    .then(function createdMount() {
      this.mounts[options.id+'/'] = new_mount;
      return this.mounts;
    });
};

Vaulted.reMount = function reMount(options) {
  options = options || {};
  var
    to_mount = options.to,
    from_mount;

  try {
    if( _.isUndefined(to_mount) || to_mount.length === 0) {
      throw new Error('No "to" parameter sent');
    }
    if(_.isUndefined(options.from) || options.from.length === 0) {
      throw new Error('No "from" parameter sent');
    }
    from_mount = this.mounts[options.from + '/'];
    if(_.isUndefined(from_mount)) {
      throw new Error();
    }
  } catch(ex) {
    return Promise.reject(new Error('Could not find existing mount named: ' + options.from));
  }
  return this.getRemountEndpoint()
    .post({
      headers: this.headers,
      body: {
        from: options.from,
        to: to_mount
      }
    })
    .promise()
    .bind(this)
    .then(function remounted() {
      var from = options.from + '/';
      this.mounts[to_mount + '/'] = this.mounts[from];
      delete this.mounts[from];
      return this.mounts;
    });
};


{'fraction_non_alphanumeric': 0.1476510067114094, 'fraction_numerical': 0.0008389261744966443, 'mean_word_length': 2.7551181102362206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6384803', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1571, 'n_words': 308}