GithubHelp home page GithubHelp logo

iomoduleconfig's Introduction

IoModuleConfig

A module configuration library for Io language to allow for self-contained modules to be packaged and configured. Has a dependency on LibPath and PathUtil protos:

(Links will be put here when libraries are versioned independently. For now, both of these protos are in this package. Simply put them in your project and make them available in your Importer search path.)

Setup

To set up your module, first add the LibPath.io and PathUtil.io files from the IoPathUtils repository based on the instructions in the readme.

Nex, create a package file in your package root named like the following:

<packageName>Package.io

Finally, set up a base configuration which should look similar to the following:

LibPath addPathWithBaseByDirName("<baseDirectoryName>", "libs/ModuleConfig")

<packageName>Package := ModuleConfig clone \
    do(
        setName("<packageName>")
        setVersion("1.0.0")

        initializeModuleLoader()
    )

<packageName>Package init := method(
    prodConfig(block(
        moduleLoader \
            configure()
    ))

    devConfig(block(
        moduleLoader \
            configure()
    ))
)

Usage

At the top of your main script or proto, include the following:

<packageName>Package clone production call

If you have a development script or test package, included, you can set up for development by doing the following instead:

<packageName>Package clone development call

This will ensure all configuration and libraries are properly set up for your project when it runs.

Examples

The IoTest package uses IoModuleConfig. The following examples are the current configuration in IoTest:

IoTestPackage:

LibPath addPathWithBaseByDirName("iotest", "libs/ModuleConfig")

IoTestPackage := ModuleConfig clone \
    do(
        setName("iotest")
        setVersion("1.0.0")

        initializeModuleLoader()
    )

IoTestPackage init := method(
    prodConfig(block(
        moduleLoader \
            addSearchPath("core") \
            addSearchPath("core/runnerCore") \
            addSearchPath("core/assertionCore") \
            addSearchPath("core/testCore") \
            configure()
    ))

    devConfig(block(

    ))
)

IoTest test runner:

packageConfig := IoTestPackage clone
cwd := PathUtil getSearchPathByDirName(packageConfig name)

packageConfig development call

IoTestRunnerFactory \
    buildRunner() \
        setCwd(cwd) \
        setTestExtension(".test") \
        addTestPath("tests") \
        run()

API

ModuleConfig

devConfig

Sets the development configuration block for use later

Contract: devConfig(devConfigBlock:Block)

initializeModuleLoader

Creates a new module loader instance and performs a base configuration

Contract: initializeModuleLoader()

moduleLoader

An instance of ModuleLoader, see API below for this object

prodConfig

Sets the production configuration block for use later

Contract: prodConfig(prodConfigBlock:Block)

ModuleLoader

addSearchPath

Adds a new search path to the list of paths to be registered with Importer. All search paths are expected to be relative to the base path.

Contract: addSearchPath(searchPath:string)

setBasePathByName

Sets module base path based on the directory name provided. Base path is captured from Importer search paths.

Contract: setBasePathByName(dirName:string)

configure

Configures search paths for all found libraries and other registered search paths with Importer.

Contract: configure()

iomoduleconfig's People

Contributors

cmstead avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.