Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mass fix, add compiling and travis

  • Loading branch information...
commit 81ef4b5d96e6298ec8b8f075d3d296795a8dcf22 1 parent 8626710
@Meettya authored
View
5 .travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.4
+ - 0.6
+ - 0.7
View
40 Cakefile
@@ -0,0 +1,40 @@
+fs = require 'fs'
+CoffeeScript = require 'coffee-script'
+{spawn, exec} = require 'child_process'
+
+# ANSI Terminal Colors.
+enableColors = no
+unless process.platform is 'win32'
+ enableColors = not process.env.NODE_DISABLE_COLORS
+
+bold = red = green = reset = ''
+if enableColors
+ bold = '\x1B[0;1m'
+ red = '\x1B[0;31m'
+ green = '\x1B[0;32m'
+ reset = '\x1B[0m'
+
+
+# Run a CoffeeScript through our node/coffee interpreter.
+run = (args, cb) ->
+ proc = spawn 'node', ['./node_modules/.bin/coffee'].concat(args)
+ proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
+ proc.on 'exit', (status) ->
+ process.exit(1) if status != 0
+ cb() if typeof cb is 'function'
+
+# Log a message with a color.
+log = (message, color, explanation) ->
+ console.log color + message + reset + ' ' + (explanation or '')
+
+
+task 'build', 'build module from source', build = (cb) ->
+ files = fs.readdirSync 'src'
+ files = ('src/' + file for file in files when file.match(/\.coffee$/))
+ run ['-c', '-o', 'lib/'].concat(files), cb
+ log ' -> build done', green
+
+task 'test', 'test builded module', ->
+ test_file = 'test/run.coffee'
+ run test_file, -> log 'All tests passed :)', green
+
View
9 History.md
@@ -1,3 +1,12 @@
+## 0.9.4 / 2012-05-24 03:08 PM
+
+ - Move .coffee to ./scr, add compiled .js version to ./lib
+ - Move CoffeeScript to develop dependencies
+ - Add Cakefile
+ - Doc improved
+ - Small fix
+
+
## 0.9.1 / 2012-05-17 11:05 AM
- Initial release
View
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Dmitrii Karpich
+
+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
106 lib/extend.js
@@ -0,0 +1,106 @@
+// Generated by CoffeeScript 1.3.3
+
+/*
+ * whet.extend v0.9.4
+ * Standalone port of jQuery.extend that actually works on node.js
+ * https://github.com/Meettya/whet.extend
+ *
+ * Copyright 2012, Dmitrii Karpich
+ * Released under the MIT License
+*/
+
+
+(function() {
+ var extend, _findValue, _isClass, _isOwnProp, _isPlainObj, _isPrimitiveType, _isTypeOf, _prepareClone,
+ __slice = [].slice;
+
+ module.exports = extend = function() {
+ var args, copy, deep, name, options, target, _i, _len, _ref;
+ deep = arguments[0], target = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
+ if (!_isClass(deep, 'Boolean')) {
+ args.unshift(target);
+ _ref = [deep || {}, false], target = _ref[0], deep = _ref[1];
+ }
+ if (_isPrimitiveType(target)) {
+ target = {};
+ }
+ for (_i = 0, _len = args.length; _i < _len; _i++) {
+ options = args[_i];
+ if (options != null) {
+ for (name in options) {
+ copy = options[name];
+ if ((copy != null) && target[name] !== copy) {
+ target[name] = _findValue(deep, copy, target[name]);
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ /*
+ Internal methods from now
+ */
+
+
+ _isClass = function(obj, str) {
+ return ("[object " + str + "]") === Object.prototype.toString.call(obj);
+ };
+
+ _isOwnProp = function(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+ };
+
+ _isTypeOf = function(obj, str) {
+ return str === typeof obj;
+ };
+
+ _isPlainObj = function(obj) {
+ var key;
+ if (!obj) {
+ return false;
+ }
+ if (obj.nodeType || obj.setInterval || !_isClass(obj, 'Object')) {
+ return false;
+ }
+ if (obj.constructor && !_isOwnProp(obj, 'constructor') && !_isOwnProp(obj.constructor.prototype, 'isPrototypeOf')) {
+ return false;
+ }
+ for (key in obj) {
+ key;
+
+ }
+ return key === void 0 || _isOwnProp(obj, key);
+ };
+
+ _isPrimitiveType = function(obj) {
+ return !(_isTypeOf(obj, 'object') || _isTypeOf(obj, 'function'));
+ };
+
+ _prepareClone = function(copy, src) {
+ if (_isClass(copy, 'Array')) {
+ if (_isClass(src, 'Array')) {
+ return src;
+ } else {
+ return [];
+ }
+ } else {
+ if (_isPlainObj(src)) {
+ return src;
+ } else {
+ return {};
+ }
+ }
+ };
+
+ _findValue = function(deep, copy, src) {
+ var clone;
+ if (deep && (_isClass(copy, 'Array') || _isPlainObj(copy))) {
+ clone = _prepareClone(copy, src);
+ return extend(deep, clone, copy);
+ } else {
+ return copy;
+ }
+ };
+
+}).call(this);
View
21 package.json
@@ -1,20 +1,23 @@
{
- "name" : "node.extend-coffeescript",
- "version" : "0.9.1",
- "description" : "A CoffeeScript wersion of port of jQuery.extend that actually works on node.js",
+ "name" : "whet.extend",
+ "version" : "0.9.4",
+ "description" : "A CoffeeScript version of port of jQuery.extend that actually works on node.js",
"keywords" : [ "extend", "jQuery", "jQuery extend", "clone", "copy", "inherit" ],
- "author" : "Meettya <meettya@gmail.com>",
- "dependencies": {
+ "author" : "Dmitrii Karpich <meettya@gmail.com>",
+ "devDependencies": {
+ "should": "0.5.1",
"coffee-script": ">=1.3.3"
},
- "devDependencies": {
- "should": "0.5.1"
+ "scripts": {
+ "test": "cake test"
},
"repository" : {
"type": "git",
- "url" : "https://github.com/dreamerslab/node.extend.git"
+ "url" : "https://github.com/Meettya/whet.extend.git"
},
"main" : "index",
- "engines": [ "node >= 0.4.0" ],
+ "engines": {
+ "node": ">=0.4.0"
+ },
"license": "MIT"
}
View
26 lib/extend.coffee → src/extend.coffee
@@ -1,17 +1,13 @@
###
-* node.extend
-* Copyright 2011, John Resig
-* Dual licensed under the MIT or GPL Version 2 licenses.
-* http://jquery.org/license
-*
-* @fileoverview
-* Port of jQuery.extend that actually works on node.js
-* Refactored and Re-writed at CoffeeScript
+ * whet.extend v0.9.4
+ * Standalone port of jQuery.extend that actually works on node.js
+ * https://github.com/Meettya/whet.extend
+ *
+ * Copyright 2012, Dmitrii Karpich
+ * Released under the MIT License
###
-fs = require 'fs'
-
-extend = (deep, target, args...) ->
+module.exports = extend = (deep, target, args...) ->
unless _isClass deep, 'Boolean'
args.unshift target
@@ -70,11 +66,3 @@ _findValue = (deep, copy, src) ->
extend deep, clone, copy
else
copy
-
-
-###
-* @public
-###
-extend.version = JSON.parse( fs.readFileSync( __dirname + '/../package.json', 'utf8' )).version
-
-module.exports = extend
View
6 test/extend.js
@@ -32,12 +32,6 @@ var deep = {
module.exports = {
- 'test .version' : function (){
- extend.version.should.match( /^\d+\.\d+\.\d+$/ );
-
- console.log( 'version test passed' );
- },
-
'merge string with string' : function (){
var ori = 'what u gonna say';
var target = extend( ori, str );
View
3  test/run.coffee
@@ -0,0 +1,3 @@
+tests = require './extend'
+
+test() for test_name, test of tests
View
10 test/run.js
@@ -1,10 +0,0 @@
-
-require('coffee-script');
-
-var tests = require( './extend' );
-
-Object.keys( tests ).forEach( function( test ){
- tests[ test ]();
-});
-
-console.log( 'All tests passed :)' );
Please sign in to comment.
Something went wrong with that request. Please try again.