Пример #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")
Пример #2
0
def clean():
    """Deletes generated JavaScript files, the build folder and clears all caches."""

    session.clean()

    profile = Profile.Profile(session)
    fm = profile.getFileManager()

    fm.removeDir("build")
    fm.removeDir("source/script")
Пример #3
0
    def test_locale(self):
        session = Session.Session()
        session.addProject(self.createProject(session, []))

        profile = Profile.Profile(session)
        profile.setLocales(["de", "en_", "fr"])

        counter = 0
        for p in profile.permutate():
            counter += 1
        self.assertEqual(counter, 24)
Пример #4
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)
Пример #5
0
def distclean():
    """Deletes all generated folders like api, build, external and all caches."""

    session.clean()
    Repository.distclean()
    session.close()

    profile = Profile.Profile(session)
    fm = profile.getFileManager()

    fm.removeDir("build")
    fm.removeDir("source/script")

    fm.removeDir("api")
    fm.removeDir("external")
Пример #6
0
    def test_permutate(self):
        session = Session.Session()
        session.addProject(self.createProject(session, []))

        profile = Profile.Profile(session)

        counter = 0
        for p in profile.permutate():
            counter += 1
        self.assertEqual(counter, 8)

        profile.permutateField("engine", values=["webkit", "gecko", "trident"])
        counter = 0
        for p in profile.permutate():
            counter += 1
        self.assertEqual(counter, 6)

        profile.setField("debug", True)
        counter = 0
        for p in profile.permutate():
            counter += 1
        self.assertEqual(counter, 3)
Пример #7
0
if __name__ == "__main__":
    jasyroot = os.path.normpath(
        os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir,
                     os.pardir, os.pardir))
    sys.path.insert(0, jasyroot)
    print("Running from %s..." % jasyroot)

import jasy.style.Engine as Engine

from jasy.env.State import session

session.init()

import jasy.core.Profile as Profile

profile = Profile.Profile(session)

profile.addCommand("jasy.asset", lambda fileId: "resolved/%s" % fileId, "url")
profile.addCommand("jasy.width", lambda fileId: 42, "px")
profile.addCommand("jasy.height", lambda fileId: 38, "px")


class Tests(unittest.TestCase):
    def process(self, code):
        callerName = inspect.stack()[1][3][5:]

        tree = Engine.getTree(code, callerName)
        tree = Engine.reduceTree(tree, profile)
        return Engine.compressTree(tree)

    def test_param(self):