<commit_before>/**
 * Created with JetBrains RubyMine.
 * User: teamco
 * Date: 11/5/12
 * Time: 9:51 PM
 * To change this template use File | Settings | File Templates.
 */

define([
    'config/anthill',
    'modules/CRUD'
], function initModel(AntHill, CRUD) {

    /**
     * Define Base model
     * @class BaseModel
     * @extends CRUD
     * @extends AntHill
     * @constructor
     */
    var BaseModel = function BaseModel() {

    };

    return BaseModel.extend('BaseModel', {

        /**
         * Create a two way data-binding between model and controller
         * @member BaseModel
         * @param {object} obj
         * @param {string} property
         * @param {function} fnCallback
         * Example:
         *      user = {};
         *      inputElem = document.getElementById("foo");
         *      bindModelInput(user,'name',inputElem);
         *      user.name = "Joe";
         *      alert("input value is now "+inputElem.value) //input is now 'Joe';
         *      inputElem.value = 'Bob';
         *      alert("user.name is now "+user.name) //model is now 'Bob';
         */
        bindModelObserver: function bindModelObserver(obj, property, fnCallback) {
            Object.defineProperty(obj, property, {
                get: function get() {
                    return fnCallback();
                },
                set: function set(newValue) {
                    fnCallback(newValue);
                },
                configurable: true
            });
        },

        /**
         * Get scope config
         * @member BaseModel
         * @param {String} [key]
         * @returns {*}
         */
        getConfig: function getConfig(key) {
            var scope = this.scope,
                config = scope.config,
                reference = scope.config;

            if (typeof(key) === 'undefined') {
                return config;
            }

            /**
             * Split key by slash
             * @type {Array}
             */
            var path = key.split('/');

            for (var i = 0, l = path.length; i < l; i++) {

                /**
                 * Get config node
                 */
                var node = path[i];

                if (reference.hasOwnProperty(node)) {

                    scope.logger.debug('Get config by key', node);
                    reference = reference[node];

                } else {
                    scope.logger.warn('Undefined config key', node);
                    return false;
                }
            }

            scope.logger.debug('Get config', reference);

            return reference;
        },

        /**
         * Set scope config
         * @member BaseModel
         * @param {String} [key]
         * @param {*} [value]
         * @returns {scope.config}
         */
        setConfig: function setConfig(key, value) {

            var scope = this.scope,
                config = scope.config;

            if (config.hasOwnProperty(key)) {
                scope.logger.debug('Update config', key, value);
                config[key] = value;
            }

            scope.logger.debug('Set config new data', key, value);
            config[key] = value;

            return this.getConfig(key);
        },

        /**
         * Get scope namespace
         * @member BaseModel
         * @param {*} node
         * @returns {string}
         */
        getNameSpace: function getNameSpace(node) {
            var base = this.base,
                scope = base.isDefined(node) ?
                    node : this.scope,
                constructor = base.isFunction(scope) ?
                    scope : scope.constructor;

            return constructor.constructor.prototype.name.toLowerCase();
        },

        /**
         * Find item in a whole project
         * @member BaseModel
         * @param {*} root
         * @param {string} uuid
         * @return {*}
         */
        findItemByUUID: function findItemByUUID(root, uuid) {<commit_msg>fix getnamespace<commit_after>/**
 * Created with JetBrains RubyMine.
 * User: teamco
 * Date: 11/5/12
 * Time: 9:51 PM
 * To change this template use File | Settings | File Templates.
 */

define([
    'config/anthill',
    'modules/CRUD'
], function initModel(AntHill, CRUD) {

    /**
     * Define Base model
     * @class BaseModel
     * @extends CRUD
     * @extends AntHill
     * @constructor
     */
    var BaseModel = function BaseModel() {

    };

    return BaseModel.extend('BaseModel', {

        /**
         * Create a two way data-binding between model and controller
         * @member BaseModel
         * @param {object} obj
         * @param {string} property
         * @param {function} fnCallback
         * Example:
         *      user = {};
         *      inputElem = document.getElementById("foo");
         *      bindModelInput(user,'name',inputElem);
         *      user.name = "Joe";
         *      alert("input value is now "+inputElem.value) //input is now 'Joe';
         *      inputElem.value = 'Bob';
         *      alert("user.name is now "+user.name) //model is now 'Bob';
         */
        bindModelObserver: function bindModelObserver(obj, property, fnCallback) {
            Object.defineProperty(obj, property, {
                get: function get() {
                    return fnCallback();
                },
                set: function set(newValue) {
                    fnCallback(newValue);
                },
                configurable: true
            });
        },

        /**
         * Get scope config
         * @member BaseModel
         * @param {String} [key]
         * @returns {*}
         */
        getConfig: function getConfig(key) {
            var scope = this.scope,
                config = scope.config,
                reference = scope.config;

            if (typeof(key) === 'undefined') {
                return config;
            }

            /**
             * Split key by slash
             * @type {Array}
             */
            var path = key.split('/');

            for (var i = 0, l = path.length; i < l; i++) {

                /**
                 * Get config node
                 */
                var node = path[i];

                if (reference.hasOwnProperty(node)) {

                    scope.logger.debug('Get config by key', node);
                    reference = reference[node];

                } else {
                    scope.logger.warn('Undefined config key', node);
                    return false;
                }
            }

            scope.logger.debug('Get config', reference);

            return reference;
        },

        /**
         * Set scope config
         * @member BaseModel
         * @param {String} [key]
         * @param {*} [value]
         * @returns {scope.config}
         */
        setConfig: function setConfig(key, value) {

            var scope = this.scope,
                config = scope.config;

            if (config.hasOwnProperty(key)) {
                scope.logger.debug('Update config', key, value);
                config[key] = value;
            }

            scope.logger.debug('Set config new data', key, value);
            config[key] = value;

            return this.getConfig(key);
        },

        /**
         * Get scope namespace
         * @member BaseModel
         * @param {*} node
         * @returns {string}
         */
        getNameSpace: function getNameSpace(node) {
            var base = this.base,
                scope = base.isDefined(node) ?
                    node : this.scope,
                constructor = base.isFunction(scope) ?
                    scope : scope.constructor;

            return constructor.prototype.name.toLowerCase();
        },

        /**
         * Find item in a whole project
         * @member BaseModel
         * @param {*} root
         * @param {string} uuid
         * @return {*}
         */
        findItemByUUID: function findItemByUUID(root, uuid) {
{'fraction_non_alphanumeric': 0.11379181693819176, 'fraction_numerical': 0.002238527546325084, 'mean_word_length': 1.2931280296549759, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5392472', 'n_tokens_mistral': 2123, 'n_tokens_neox': 2014, 'n_words': 517}