Permalink
Browse files

Remove trailing whitespace from the project

  • Loading branch information...
1 parent d460497 commit f07dca0eb66911a805af60feb0fd9347cdc78e3b @smtlaissezfaire committed Mar 1, 2010
View
@@ -6,7 +6,7 @@ task :jsl do
def jsl_file(filename)
puts `jsl -process #{filename}`
end
-
+
Dir.glob("**/*.js").each do |file|
unless file =~ /vendor/
jsl_file(file)
@@ -19,4 +19,4 @@ task :spec do
`open spec/suite.html`
end
-task :default => :jsl
+task :default => :jsl
View
@@ -1,3 +1,3 @@
require("./espionage/helpers");
require("./espionage/spy");
-require("./espionage/stub");
+require("./espionage/stub");
View
@@ -5,50 +5,50 @@ Espionage.Helpers = function() {
F.prototype = obj;
return new F();
};
-
+
var alias = function(obj, new_name, old_name) {
obj[new_name] = obj[old_name];
};
-
+
var numberToWordMapper = function() {
var mapping = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
var count = mapping.length;
-
+
function throwIfInvalidNumber(number) {
if (number < 0 || isNaN(number)) {
throw({
- name: "TypeError",
+ name: "TypeError",
message: "Invalid number. numberToWord only accepts positive integers"
});
}
}
-
+
function mapToString(number) {
return mapping[number];
}
-
+
function numToString(number) {
return parseInt(number, 10).toString();
}
-
+
function convertToString(number) {
return (number >= count) ? numToString(number) : mapToString(number);
}
-
+
function map(number) {
throwIfInvalidNumber(number);
return convertToString(number);
}
-
+
return {
map: map
};
}();
-
+
var numberToWord = function(number) {
return numberToWordMapper.map(number);
};
-
+
var numberOfTimesInWords = function(number) {
switch(number) {
case 1:
@@ -59,16 +59,16 @@ Espionage.Helpers = function() {
return numberToWord(number) + " times";
}
};
-
+
// the following is coppied from jQuery
-
+
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
var isFunction = function( obj ) {
return toString.call(obj) === "[object Function]" || obj instanceof Function;
};
-
+
var grep = function( elems, callback, inv ) {
var ret = [];
@@ -98,15 +98,15 @@ Espionage.Helpers = function() {
return ret.concat.apply( [], ret );
};
-
+
var merge = function( first, second ) {
var i = first.length, j = 0;
if ( typeof second.length === "number" ) {
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
-
+
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
@@ -117,7 +117,7 @@ Espionage.Helpers = function() {
return first;
};
-
+
var makeArray = function( array, results ) {
var ret = results || [];
@@ -134,7 +134,7 @@ Espionage.Helpers = function() {
return ret;
};
-
+
var each = function( object, callback, args ) {
var name, i = 0,
length = object.length,
@@ -171,14 +171,14 @@ Espionage.Helpers = function() {
return object;
};
-
-
+
+
return {
object: object,
alias: alias,
numberToWord: numberToWord,
numberOfTimesInWords: numberOfTimesInWords,
-
+
// jquery methods
makeArray: makeArray,
isFunction: isFunction,
@@ -1,14 +1,14 @@
Espionage.ScrewUnit = function() {
var addMatchers = function() {
var matchers = Espionage.ScrewUnit.Matchers;
-
+
for (property in matchers) {
if (matchers.hasOwnProperty(property)) {
Screw.Matchers[property] = matchers[property];
}
}
};
-
+
return {
addMatchers: addMatchers
};
@@ -25,19 +25,19 @@ Espionage.ScrewUnit.Matchers = function () {
}
};
};
-
+
var haveReceived = function(message) {
var number_of_times_called;
-
+
function wordify(number) {
return (number === 0) ? "no arguments" : Espionage.Helpers.numberToWord(number);
}
-
+
var argument = {
match: function(__ignored__, object) {
var matching_elements,
argument_size = object.argumentsFor(message);
-
+
if (argument_size) {
matching_elements = jQuery.grep(argument_size, function(element) {
return number_of_times_called === element.length;
@@ -51,37 +51,37 @@ Espionage.ScrewUnit.Matchers = function () {
var string = "Expected '" + message + "' ",
arguments_for = object.argumentsFor(message),
was_called = object.argumentsFor(message).length > 0;
-
+
function times_called() {
return arguments_for[0].length;
}
-
+
if (negation) {
string += "not to be called with one argument, but it was";
} else {
string += "to be called with one argument, but was ";
string += was_called ? "called with " + wordify(times_called()) : "not called";
}
-
+
return string;
}
};
-
+
var arguments = argument;
-
+
var match = function(__ignored__, object) {
return haveBeenCalledOn(object).match(__ignored__, message);
};
-
+
var failure_message = function(__ignored__, object, not) {
return haveBeenCalledOn(object).failure_message(null, message, not);
};
-
+
var With = function(number) {
number_of_times_called = number;
return this;
};
-
+
return {
match: match,
failure_message: failure_message,
@@ -90,11 +90,11 @@ Espionage.ScrewUnit.Matchers = function () {
arguments: arguments
};
};
-
+
return {
haveBeenCalledOn: haveBeenCalledOn,
haveReceived: haveReceived
};
}();
-Espionage.ScrewUnit.addMatchers();
+Espionage.ScrewUnit.addMatchers();
View
@@ -4,7 +4,7 @@ Espionage.Spy = function() {
isFunction = Espionage.Helpers.isFunction,
grep = Espionage.Helpers.grep,
map = Espionage.Helpers.map;
-
+
function redefineMethod(obj, property) {
var old_method = obj[property];
obj[property] = function() {
@@ -16,37 +16,37 @@ Espionage.Spy = function() {
old_method();
};
}
-
+
function redefineEachMethod(obj) {
for (property in obj) {
if (isFunction(obj[property])) {
redefineMethod(obj, property);
}
}
}
-
+
function findReceivedMethod(obj, method_name) {
var received_methods = findAllReceivedMethods(obj, method_name);
-
+
if(received_methods) {
return received_methods[0];
}
}
-
+
function findAllReceivedMethods(obj, method_name) {
return grep(received_messages, function(message_pair) {
if (message_pair.object === obj && message_pair.property === method_name) {
return message_pair;
}
});
}
-
+
function addReceivedMethod(obj) {
obj.received = function(method_name) {
return findReceivedMethod(obj, method_name) ? true : false;
};
}
-
+
function addArgumentsForMethod(obj) {
obj.argumentsFor = function(method_name) {
var pairs = findAllReceivedMethods(obj, method_name);
@@ -57,30 +57,30 @@ Espionage.Spy = function() {
}
};
}
-
+
function addMethods(obj) {
addReceivedMethod(obj);
addArgumentsForMethod(obj);
}
-
+
function callFunction(fun) {
fun.call();
}
-
+
var spyOn = function(obj, fun) {
redefineEachMethod(obj);
addMethods(obj);
callFunction(fun);
};
-
+
var reset = function(obj) {
received_messages = [];
};
-
+
return {
spyOn: spyOn,
reset: reset
};
}();
-spyOn = Espionage.Spy.spyOn;
+spyOn = Espionage.Spy.spyOn;
Oops, something went wrong.

0 comments on commit f07dca0

Please sign in to comment.