<commit_before>'use strict';

const filez = require('./filez');
const fs    = require('fs-extra-promise');
const path  = require('path');

const log   = require('debug')('akasha:Renderer');
const error = require('debug')('akasha:error-Renderer');

module.exports = class Renderer {
    constructor(name, regex) {
        this._name  = name;
        if (regex instanceof RegExp) {
            this._regex = [ regex ];
        } else if (regex instanceof Array) {
            this._regex = regex;
        } else {
            throw new Error('regex must be RegExp or Array of RegExp');
        }
    }

    get name() { return this._name; }

    match(fname) {
        var matches;
        for (var regex of this._regex) {
            if ((matches = fname.match(regex)) !== null) {
                return true;
            }
        }
        return false;
    }

    /* {
    	path: matches[0],
    	renderedFileName: matches[1],
    	extension: matches[2]
    }; */

    filePath(fname) {
        // log(`${this._name} filePath ${fname}`);
        var matches;
        for (var regex of this._regex) {
            if ((matches = fname.match(regex)) !== null) {
                return matches[1];
            }
        }
        return null;
    }

    fileExtension(fname) {
        var matches;
        for (var regex of this._regex) {
            if ((matches = fname.match(regex)) !== null) {
                return matches[2];
            }
        }
        return null;
    }

    readFile(basedir, fpath) {
        return fs.readFileAsync(path.join(basedir, fpath), 'utf8');
    }

    writeFile(renderTo, fpath, text) {
        return filez.writeFile(renderTo, fpath, text);
    }

    render(text, metadata) {
        throw new Error('implement render method');
    }

    renderSync(text, metadata) {<commit_msg>Convert to Symbol and getter<commit_after>'use strict';

const filez = require('./filez');
const fs    = require('fs-extra-promise');
const path  = require('path');

const log   = require('debug')('akasha:Renderer');
const error = require('debug')('akasha:error-Renderer');

const _renderer_name = Symbol('name');
const _renderer_regex = Symbol('regex');


module.exports = class Renderer {
    constructor(name, regex) {
        this[_renderer_name]  = name;
        if (regex instanceof RegExp) {
            this[_renderer_regex] = [ regex ];
        } else if (regex instanceof Array) {
            this[_renderer_regex] = regex;
        } else {
            throw new Error('regex must be RegExp or Array of RegExp');
        }
    }

    get name() { return this[_renderer_name]; }
    get regex() { return this[_renderer_regex]; }

    match(fname) {
        var matches;
        for (var regex of this.regex) {
            if ((matches = fname.match(regex)) !== null) {
                return true;
            }
        }
        return false;
    }

    /* {
    	path: matches[0],
    	renderedFileName: matches[1],
    	extension: matches[2]
    }; */

    filePath(fname) {
        // log(`${this._name} filePath ${fname}`);
        var matches;
        for (var regex of this.regex) {
            if ((matches = fname.match(regex)) !== null) {
                return matches[1];
            }
        }
        return null;
    }

    fileExtension(fname) {
        var matches;
        for (var regex of this.regex) {
            if ((matches = fname.match(regex)) !== null) {
                return matches[2];
            }
        }
        return null;
    }

    readFile(basedir, fpath) {
        return fs.readFileAsync(path.join(basedir, fpath), 'utf8');
    }

    writeFile(renderTo, fpath, text) {
        return filez.writeFile(renderTo, fpath, text);
    }

    render(text, metadata) {
        throw new Error('implement render method');
    }

    renderSync(text, metadata) {
{'fraction_non_alphanumeric': 0.13349007314524555, 'fraction_numerical': 0.003134796238244514, 'mean_word_length': 1.9340996168582376, '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': '6361236', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1122, 'n_words': 276}