Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

malte (1708)

malte
  (email not shown publicly)
http://www.yur.tv/

Perl hacker for this [schaffhausen.de] company. My Dad's Practice [praxisamhogenkamp.de]

Journal of malte (1708)

Sunday April 06, 2008
02:52 PM

Joose

Joose has turned from an experiment to something really cool. It has pretty much the same effect of JS programming like Moose has on Perl-Programming. There is now some some documentation on Google code. If you want to join in on the development just email me at malte.ubl (at) gmail.com or drop by at #moose, so I can get you a commit bit for the repository and the wiki.
Wednesday March 26, 2008
06:32 PM

Joose Blog

I moved by JavaScript and Joose-related blogging to a new blog to give it more wide exposure to the general non-perl-related internet community.
Monday March 24, 2008
08:14 AM

Attribute meta classes

Attributes now have their own meta class in Joose. Support for attribute traits is currently quite limited, but you can say:

Class("Car", {
    has: {
        leftRearWheel: {
            init: new Wheel(),
            isa: Wheel,
            is: rw,
            handles: "*"
        }
    }
})
to only allow Wheels in the attribute leftRearWheel and to delegate all of Wheel's methods to the leftRearWheel.

In other news:

  • Joose is now hosted in the Moose svn
  • Joose now supports the Moose JSON Storage format and allows round trips between Moose and Joose (at least for basic tests)
  • Joose now works in IE and Opera
  • Joose now supports class methods
Saturday March 22, 2008
08:52 AM

Joose can write TPS-Reports

While advancing at least two computer science zen levels I augmented my brain enough to implement the augment method modifier in Joose.

Class("HTMLDoc", {
    augment: {
        html: function () { return "<html>"+this.INNER()+"</html>" }
    }
})

Class("HTMLDocBody", {
    isa: HTMLDoc,
    augment: {
        html: function () { return "<body>"+this.INNER()+"</body>" }
    }
})

Class("TPSReport", {
    isa: HTMLDocBody,
    augment: {
        html: function () { return "<h1>TPS-Report</h1>" }
    }
})
While making method modifiers stackable was really easy for all the other modifiers, I had to roll my own reverse call stack to make it happen with augment.
Friday March 21, 2008
02:34 PM

Google Gears support in Joose

You can now automatically execute methods of a Joose.Class in a different thread using Google Gears. All you need to do is use the meta class Joose.Gears and add a worker method. All the Gears-Interfacing is handled for you. If Gears is not present, the worker is executed in the main thread. The workers result will be sent to a method called "on".ucfirst($worker_name) if available:

Class("HardWork", {
    meta: Joose.Gears,
    has: {
        data: {is: rw, init: {}}
    },
    methods: {
        onDoWork: function (result) {
            ok(result == 1001, "Gear Worker returns correct result")
        }
    },
    workers: {
        doWork: function (start) {
            var counter = start;
            for(var i = 0; i < 1000; i++) {
                counter++
            }
            return counter
        }
    }
})

var hw = new HardWork();

hw.doWork(1)
05:21 AM

Joose now has method modifiers

You can now use the following method modifiers in Joose:

Class("S3", {
    isa: S2,
    override: {
        two: function () {
            this.result2 += "3"
            this.SUPER();
        }
    },
    before: {
        add: function () { this.result += "5" }
    }
    after: {
        add: function () { this.result += "7" }
    },
    wrap: {
        add: function (original) { this.result += "8"; original(); this.result += "9" }
    }
})

By using the excplicit override modifier you get access to the overridden method using this.SUPER(). This is basically the same as the wrap modifier, but it keeps the methods signature intact (wrap passes the wrapped function as the first parameter).

Wednesday March 19, 2008
04:55 PM

New builder syntax for Joose

Joose now supports two new ways to create Joose.Classes

joosify(MyClass) now turns regular classes into Joose.Clases.

...and you can now use a more JavaScript like Syntax to build Joose.Classes:

Class("Currency", {
    does: Eq,
    has:  ["value", {is: rw}],
    methods: {
        initialize: function (value) {
            this.setValue(value)
        },

        isEqual: function (cur) {
            return this.getValue() == cur.getValue()
        }
    }
})
Wednesday March 05, 2008
04:29 PM

Joose has Roles

Joose the JavaScript implementation of Moose now has Roles.

A direct translation of the Synopsis from Moose::Role looks like this:

Class("Eq", {meta: Joose.Role});
requires("isEqual");

methods({
    notEqual: function (para) {
        return !this.isEqual(para)
    }
})

Class("Currency");
does(Eq)
has("value", {is: rw})

methods({

    initialize: function (value) {
        this.setValue(value)
    },

    isEqual: function (cur) {
        return this.getValue() == cur.getValue()
    }
})

check()

The check() makes a "compile time" check of the role requirements. This might later be implemented as an onload-event in browsers.

Joose.Roles are themselves implemented as Joose.Classes. The source looks like this:

Class("Joose.Role");
isa(Joose.Class);
has("requiresMethodNames")
methods({

    initialize: function () {
        this.name                = "Joose.Role"
        this.requiresMethodNames = [];
    },

    addRequirement: function (methodName) {
        this.requiresMethodNames.push(methodName)
    },

    exportTo: function (classObject) {
        classObject.meta.importMethods(this.getClassObject())
    },

    hasRequiredMethods: function (classObject) {
        var complete = true
        this.requiresMethodNames.each(function (value) {
            var found = classObject.meta.can(value)
            if(!found) {
                complete = false
            }
        })
        return complete
    },

    isImplementedBy: function (classObject) {

        var complete = this.hasRequiredMethods(classObject);

        if(complete) {
            complete = this.implementsMyMethods(classObject);
        }
        return complete
    }
})
Tuesday March 04, 2008
06:07 PM

Moose in JavaScript

This must have been done before, but it was fun anyway. I have written a partial implementation of Moose (and Class::MOP) in JavaScript. It's called Joose. It is self-hosting, so you can write meta classes in Joose and you get some of the syntactic sugar from Moose.

A typical example would be:

Class("Animal");

methods({
    multiply: function () { return this.meta.instantiate() }
})

Class("Cat");
isa(Animal)

methods({
    likes: function () { return "fish" }
})

Class("Dog");
isa(Animal)
has("owner", {is: rw})

methods({
    balksAt: function () { return this.owner },
    hates: function () { Cat }
})

ok(Cat.meta.isa(Animal), "Cats are animals");
ok(Dog.meta.isa(Animal), "Dogs are animals too");
ok(!Animal.meta.isa(Cat), "Not all animals are cats")
ok(new Cat().likes() == "fish", "Cats like fish");
ok(new Cat().multiply().likes() == "fish", "Cat babies like fish")
ok(new Cat().multiply().meta.isa(Cat), "Cat babies are Cats")
Thursday February 28, 2008
03:16 PM

xssinterface

There seems to be some interest in xssinterface in the javascript community so I put it up as a project on Google Code.

Meanwhile I implemented the usage of the new HTML 5 postMessage() method that implements the same behavior for new browsers where available.

Does anybody here have a clue about p3p xml privacy policies? Looks like the worst, over engineered spec since SOAP WS-*