Permalink
Browse files

* Code updates, docs, packager ready

  • Loading branch information...
1 parent 0c7fd50 commit bf72031c01e35f222653e2f3db4c49a7ec4a2dec @cpojer committed Jul 29, 2010
Showing with 59 additions and 31 deletions.
  1. +24 −0 LICENSE
  2. +8 −0 README.md
  3. +10 −26 Source/Interface.js
  4. +17 −5 package.yml
View
24 LICENSE
@@ -0,0 +1,24 @@
+MooTools Interface - MIT License
+
+Copyright (c) 2010 Christoph Pojer
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
8 README.md
@@ -7,6 +7,14 @@ Only works with MooTools 1.3.0+.
Checks *after* creating an instance of a MooTools Class.
+Build
+-----
+
+Build via [Packager](http://github.com/kamicane/packager), requires MooTools Core to be registered to Packager already
+
+ ./packager register /path/to/interface
+ ./packager build Interface/* > interface.js
+
How to use
----------
View
36 Source/Interface.js
@@ -1,39 +1,23 @@
/*
---
-description: Interfaces for Class to ensure certain properties are defined
-authors:
- - Christoph Pojer
- - Luis Merino
+name: Interface
-requires:
- core/1.3.0:
- - Core
- - Type
- - typeOf
- - instanceOf
- - Class
+description: Interfaces for Class to ensure certain properties are defined.
-provides:
- - Interface
+authors: Christoph Pojer (@cpojer), Luis Merino (@Rendez)
-license:
- MIT-style license
+license: MIT-style license.
+
+requires: [Core/Type, Core/Class]
+
+provides: Interface
-version:
- 0.1
...
*/
(function(context){
-var Moo = (typeof require != 'undefined') ? require('MooTools') : this,
- Type = Moo.Type,
- Class = Moo.Class,
- typeOf = Moo.typeOf,
- instanceOf = Moo.instanceOf,
- nil = Moo.nil;
-
this.Interface = new Type('Interface', function(object){
if (object.Implements){
Array.from(object.Implements).each(function(item){
@@ -63,7 +47,7 @@ Class.Mutators.initialize = function(fn){
var item = this[key],
object = iface[key];
- if (object == nil) continue;
+ if (object == null) continue;
var type = typeOf(item),
oType = typeOf(object);
@@ -75,7 +59,7 @@ Class.Mutators.initialize = function(fn){
throw new Error('Property "' + key + '" is implemented but not an instance of ' + (name ? '"' + name + '"' : 'the expected type'));
}
- if (oType == 'function' && object != nil && item.$origin.length < object.length)
+ if (oType == 'function' && item.$origin.length < object.length)
throw new Error('Property "' + key + '" does not implement at least ' + object.length + ' parameter' + (object.length != 1 ? 's' : ''));
}
}
View
22 package.yml
@@ -1,5 +1,17 @@
-name: Interface
-author: cpojer
-category: Native
-tags: [type, interface, class]
-demo: http://github.com/cpojer/mootools-interface/blob/master/Demos/Example.js
+name: "Interface"
+
+exports: "interface.js"
+
+web: "[cpojer.net](http://cpojer.net)"
+
+description: "Interfaces for Class to ensure certain properties are defined."
+
+license: "[MIT License](http://mootools.net/license.txt)"
+
+copyright: "&copy; [Christoph Pojer](http://cpojer.net/)"
+
+author: "cpojer"
+authors: "[Christoph Pojer](http://cpojer.net)"
+
+sources:
+ - "Source/Interface.js"

0 comments on commit bf72031

Please sign in to comment.