<commit_before>var _ = require("lodash");
var path = require("path");
var Q = require("q");
var fs = require("./utils/fs");

var Plugin = require("./plugin");

var BaseGenerator = function(book) {
    this.book = book;

    Object.defineProperty(this, "options", {
        get: function () {
            return this.book.options;
        }
    });

    // Base for assets in plugins
    this.pluginAssetsBase = "book";

    _.bindAll(this);
};

BaseGenerator.prototype.callHook = function(name, data) {
    return this.plugins.hook(name, data);
};

// Prepare the genertor
BaseGenerator.prototype.prepare = function() {
    return this.preparePlugins();
};

BaseGenerator.prototype.preparePlugins = function() {
    var that = this;
    return Plugin.normalize(that.book.plugins)
    .then(function(_plugins) {
        that.plugins = _plugins;
    });
};

// Write a parsed file to the output
BaseGenerator.prototype.writeParsedFile = function(page, input) {
    return Q.reject(new Error("Could not convert "+input));
};

// Copy file to the output (non parsable)
BaseGenerator.prototype.transferFile = function(input) {
    return fs.copy(
        path.join(this.book.root, input),
        path.join(this.options.output, input)
    );
};

// Copy a folder to the output
BaseGenerator.prototype.transferFolder = function(input) {
    return fs.mkdirp(
        path.join(this.book.options.output, input)
    );
};

// Copy the cover picture<commit_msg>Call hook "init" when preparing generator<commit_after>var _ = require("lodash");
var path = require("path");
var Q = require("q");
var fs = require("./utils/fs");

var Plugin = require("./plugin");

var BaseGenerator = function(book) {
    this.book = book;

    Object.defineProperty(this, "options", {
        get: function () {
            return this.book.options;
        }
    });

    // Base for assets in plugins
    this.pluginAssetsBase = "book";

    _.bindAll(this);
};

BaseGenerator.prototype.callHook = function(name, data) {
    return this.plugins.hook(name, data);
};

// Prepare the genertor
BaseGenerator.prototype.prepare = function() {
    var that = this;

    return this.preparePlugins()
    .then(function() {
        return that.callHook("init");
    });
};

BaseGenerator.prototype.preparePlugins = function() {
    var that = this;
    return Plugin.normalize(that.book.plugins)
    .then(function(_plugins) {
        that.plugins = _plugins;
    });
};

// Write a parsed file to the output
BaseGenerator.prototype.writeParsedFile = function(page, input) {
    return Q.reject(new Error("Could not convert "+input));
};

// Copy file to the output (non parsable)
BaseGenerator.prototype.transferFile = function(input) {
    return fs.copy(
        path.join(this.book.root, input),
        path.join(this.options.output, input)
    );
};

// Copy a folder to the output
BaseGenerator.prototype.transferFolder = function(input) {
    return fs.mkdirp(
        path.join(this.book.options.output, input)
    );
};

// Copy the cover picture
{'fraction_non_alphanumeric': 0.1399735274652548, 'fraction_numerical': 0.0, 'mean_word_length': 3.1639118457300275, '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': '7082484', 'n_tokens_mistral': 913, 'n_tokens_neox': 897, 'n_words': 216}