Exemplo n.º 1
0
def api():
    """Generates the API viewer for the current project"""

    profile = Profile.Profile(session)
    profile.registerPart("kernel", className="core.apibrowser.Kernel")
    profile.registerPart("main", className="core.apibrowser.Browser")
    profile.setField("debug", False)
    profile.setCopyAssets(True)

    # Build application code
    Build.run(profile)

    # Copy files from Core project
    fileManager = profile.getFileManager()
    sourceFolder = session.getProjectByName("core").getPath() + "/source/"
    fileManager.updateFile(sourceFolder + "/apibrowser.html",
                           "{{destination}}/index.html")

    # Rewrite template as jsonp
    for tmpl in [
            "main", "error", "entry", "type", "params", "info", "origin",
            "tags"
    ]:
        jsonTemplate = json.dumps({
            "template":
            open(sourceFolder + "/tmpl/apibrowser/%s.mustache" % tmpl).read()
        })
        fileManager.writeFile(
            "{{destination}}/tmpl/%s.js" % tmpl,
            "apiload(%s, '%s.mustache')" % (jsonTemplate, tmpl))

    # Write API data
    ApiWriter(profile).write("{{destination}}/data")
Exemplo n.º 2
0
def test(target="source",
         tool="phantom",
         browsers=None,
         main="test.Main",
         kernel="test.Kernel"):
    """
    Automatically executes tests in either PhantomJS, NodeJS or via Testem CI
    """

    # Initialize profile
    profile = Profile.Profile(session)
    profile.registerPart("kernel", className=kernel)
    profile.registerPart("main", className=main)

    # Destination should match target name
    profile.setDestinationPath(target)

    if target == "source":

        # Force debug enabled
        profile.setField("debug", True)

        # Load all scripts/assets from source folder
        profile.setUseSource(True)

        # Start actual build
        Build.run(profile)

    elif target == "build":

        # Copy assets
        profile.setCopyAssets(True)

        # Start actual build
        Build.run(profile)

        # Copy files from source
        for name in ["index.html", "testem.html", "phantom.js", "node.js"]:
            fileManager.updateFile("source/%s" % fileName,
                                   "{{destination}}/%s" % fileName)

    else:

        Console.error("Unsupported target: %s" % target)

    if tool == "phantom":
        return test_phantom(profile)
    elif tool == "node":
        return test_node(profile)
    elif tool == "testem":
        return test_testem(profile, target, browsers)
    else:
        Console.error("Unsupported tool: %s" % tool)
Exemplo n.º 3
0
def test(target="source", tool="phantom", browsers=None, main="test.Main", kernel="test.Kernel"):
    """
    Automatically executes tests in either PhantomJS, NodeJS or via Testem CI
    """

    # Initialize profile
    profile = Profile.Profile(session)
    profile.registerPart("kernel", className=kernel)
    profile.registerPart("main", className=main)

    # Destination should match target name
    profile.setDestinationPath(target)

    if target == "source":

        # Force debug enabled
        profile.setField("debug", True)

        # Load all scripts/assets from source folder
        profile.setUseSource(True)

        # Start actual build
        Build.run(profile)

    elif target == "build":

        # Copy assets
        profile.setCopyAssets(True)

        # Start actual build
        Build.run(profile)

        # Copy files from source
        for name in ["index.html", "testem.html", "phantom.js", "node.js"]:
            fileManager.updateFile("source/%s" % fileName, "{{destination}}/%s" % fileName)

    else:

        Console.error("Unsupported target: %s" % target)

    if tool == "phantom":
        return test_phantom(profile)
    elif tool == "node":
        return test_node(profile)
    elif tool == "testem":
        return test_testem(profile, target, browsers)
    else:
        Console.error("Unsupported tool: %s" % tool)
Exemplo n.º 4
0
def api():
    """Generates the API viewer for the current project"""

    profile = Profile.Profile(session)
    profile.registerPart("kernel", className="core.apibrowser.Kernel")
    profile.registerPart("main", className="core.apibrowser.Browser")
    profile.setField("debug", False)
    profile.setCopyAssets(True)

    # Build application code
    Build.run(profile)

    # Copy files from Core project
    fileManager = profile.getFileManager()
    sourceFolder = session.getProjectByName("core").getPath() + "/source/"
    fileManager.updateFile(sourceFolder + "/apibrowser.html", "{{destination}}/index.html")

    # Rewrite template as jsonp
    for tmpl in ["main", "error", "entry", "type", "params", "info", "origin", "tags"]:
        jsonTemplate = json.dumps({ "template" : open(sourceFolder + "/tmpl/apibrowser/%s.mustache" % tmpl).read() })
        fileManager.writeFile("{{destination}}/tmpl/%s.js" % tmpl, "apiload(%s, '%s.mustache')" % (jsonTemplate, tmpl))

    # Write API data
    ApiWriter(profile).write("{{destination}}/data")