<commit_before>'use strict';

var R = require('ramda');
var isEmptyObj = R.pipe(R.keys, R.isEmpty);

function ModelRenderer(model) {
  this.modelName = model.modelName;
  this.attrs = model.attrs;
}

function attrToString(attrName, opts) {
  var attrOutput = '- ' + attrName;
  var lines = R.map(R.apply(optToString), R.toPairs(opts));
  var indentedLines = R.map(function(line) {
    return '  - ' + line;
  }, lines);
  var optsOutput = R.join('\n', indentedLines);

  if (optsOutput) {
    attrOutput += ':\n' + optsOutput;
  }
  return attrOutput;
}

function optToString(opt, value) {
  if (opt === 'primaryKey') {
    return 'primaryKey';
  }
  if (opt === 'description') {
    return 'description: ' + value;
  }
  if (opt === 'type') {
    return 'type: ' + value;
  }
}

Object.defineProperty(ModelRenderer.prototype, 'metadata', {<commit_msg>Refactor optToString to use same code for known options<commit_after>/* globals Set */
'use strict';

var R = require('ramda');
var isEmptyObj = R.pipe(R.keys, R.isEmpty);

function ModelRenderer(model) {
  this.modelName = model.modelName;
  this.attrs = model.attrs;
}

function attrToString(attrName, opts) {
  var attrOutput = '- ' + attrName;
  var lines = R.map(R.apply(optToString), R.toPairs(opts));
  var indentedLines = R.map(function(line) {
    return '  - ' + line;
  }, lines);
  var optsOutput = R.join('\n', indentedLines);

  if (optsOutput) {
    attrOutput += ':\n' + optsOutput;
  }
  return attrOutput;
}

function optToString(opt, value) {
  if (opt === 'primaryKey') {
    return 'primaryKey';
  }

  if (optToString.knownOptions.has(opt)) {
    return opt + ': ' + value;
  }
}
optToString.knownOptions = new Set(['description', 'type']);

Object.defineProperty(ModelRenderer.prototype, 'metadata', {
{'fraction_non_alphanumeric': 0.16441441441441443, 'fraction_numerical': 0.0, 'mean_word_length': 3.8419618528610355, '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': '1604501', 'n_tokens_mistral': 609, 'n_tokens_neox': 606, 'n_words': 136}