<commit_before>var DirectoryDataStore = Packages.org.geotools.data.directory.DirectoryDataStore;
var Workspace = require("geoscript/workspace/workspace").Workspace;
var util = require("geoscript/util");
var file = require("file");
var ShapefileDataStoreFactory = Packages.org.geotools.data.shapefile.ShapefileDataStoreFactory;

var prepConfig = function(config) {
    if (typeof config === "string" || config instanceof file.Path) {
        config = {path: String(config)};
    }
    if (!config.path) {
        throw "Directory config must include a path.";
    } else {
        if (!file.isDirectory(config.path)) {
            throw "Directory path must exist.";
        }
    }
    return config;
};

/** api: (define)
 *  module = workspace
 *  class = Directory
 */

/** api: (extends)
 *  workspace/workspace.js
 */
var Directory = util.extend(Workspace, {
    
    /** api: property[path]
     *  ``String``
     *  The absolute directory path.
     */
    
    /** api: constructor
     *  .. class:: Directory
     *
     *      :arg path: ``String`` Path to the directory.
     *
     *      Create a workspace from a directory.
     */
    constructor: function Directory(config) {
        Workspace.prototype.constructor.apply(this, [prepConfig(config)]);
    },
    
    /** private: method[_create]<commit_msg>Make prepConfig safe for directory workspace.<commit_after>var DirectoryDataStore = Packages.org.geotools.data.directory.DirectoryDataStore;
var Workspace = require("geoscript/workspace/workspace").Workspace;
var util = require("geoscript/util");
var file = require("file");
var ShapefileDataStoreFactory = Packages.org.geotools.data.shapefile.ShapefileDataStoreFactory;

var prepConfig = function(config) {
    if (typeof config === "string" || config instanceof file.Path) {
        config = {path: String(config)};
    }
    if (config) {
        if (!config.path) {
            throw "Directory config must include a path.";
        } else {
            if (!file.isDirectory(config.path)) {
                throw "Directory path must exist.";
            }
        }        
    }
    return config;
};

/** api: (define)
 *  module = workspace
 *  class = Directory
 */

/** api: (extends)
 *  workspace/workspace.js
 */
var Directory = util.extend(Workspace, {
    
    /** api: property[path]
     *  ``String``
     *  The absolute directory path.
     */
    
    /** api: constructor
     *  .. class:: Directory
     *
     *      :arg path: ``String`` Path to the directory.
     *
     *      Create a workspace from a directory.
     */
    constructor: function Directory(config) {
        Workspace.prototype.constructor.apply(this, [prepConfig(config)]);
    },
    
    /** private: method[_create]
{'fraction_non_alphanumeric': 0.1323851203501094, 'fraction_numerical': 0.0, 'mean_word_length': 2.595019659239843, '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': '2120759', 'n_tokens_mistral': 804, 'n_tokens_neox': 784, 'n_words': 186}