Permalink
Browse files

updated: Big cleanup. Some proper testing.

  • Loading branch information...
1 parent e782d65 commit 783d176e064e097778c975b90ebf3e1870f42513 @gf3 committed Aug 12, 2011
Showing with 334 additions and 1,230 deletions.
  1. +2 −1 .gitignore
  2. +13 −0 Makefile
  3. +2 −2 lib/compiler.js
  4. +26 −38 lib/irc.js
  5. +0 −2 node_modules/.gitignore
  6. +0 −70 node_modules/coloured-log/README.md
  7. +0 −24 node_modules/coloured-log/UNLICENSE
  8. +0 −51 node_modules/coloured-log/lib/coloured-log.js
  9. +0 −81 node_modules/coloured-log/node_modules/coloured/README.md
  10. +0 −25 node_modules/coloured-log/node_modules/coloured/UNLICENSE
  11. +0 −8 node_modules/coloured-log/node_modules/coloured/example/example.js
  12. +0 −9 node_modules/coloured-log/node_modules/coloured/example/example2.js
  13. +0 −81 node_modules/coloured-log/node_modules/coloured/lib/coloured.js
  14. +0 −17 node_modules/coloured-log/node_modules/coloured/package.json
  15. +0 −17 node_modules/coloured-log/node_modules/log/History.md
  16. +0 −14 node_modules/coloured-log/node_modules/log/Makefile
  17. +0 −99 node_modules/coloured-log/node_modules/log/Readme.md
  18. +0 −18 node_modules/coloured-log/node_modules/log/examples/file.js
  19. +0 −16 node_modules/coloured-log/node_modules/log/examples/file.log
  20. +0 −15 node_modules/coloured-log/node_modules/log/examples/reader.js
  21. +0 −17 node_modules/coloured-log/node_modules/log/examples/stdout.js
  22. +0 −329 node_modules/coloured-log/node_modules/log/index.html
  23. +0 −2 node_modules/coloured-log/node_modules/log/index.js
  24. +0 −254 node_modules/coloured-log/node_modules/log/lib/log.js
  25. +0 −9 node_modules/coloured-log/node_modules/log/package.json
  26. +0 −17 node_modules/coloured-log/package.json
  27. +0 −4 package.json
  28. +2 −3 spec/lib/compiler.spec.js
  29. +276 −0 spec/lib/irc.spec.js
  30. +4 −7 spec/mock_internals.js
  31. +9 −0 spec/spec_helper.js
View
@@ -1,4 +1,5 @@
tags
doc
-lib/.irc.pdoc.yaml
+node_modules/*
+!node_modules/PanPG
tmp*.js
View
@@ -0,0 +1,13 @@
+# Macro Definitions
+CTAGS= jsctags
+NODE= node
+
+# Explicit Rules
+tags:
+ $(CTAGS) lib/irc.js lib/compiler.js lib/walker.js spec/**/*.js
+
+parser:
+ $(NODE) util/generate.js
+
+test:
+ $(NODE) spec/lib/*.js -a
View
@@ -1,5 +1,5 @@
-var Parser = require( 'parser' )
- , Walker = require( 'walker' )
+var Parser = require( './parser' )
+ , Walker = require( './walker' )
, Compiler = {}
/* ------------------------------ Compiler ------------------------------ */
View
@@ -93,7 +93,7 @@ function doConnect() {
// Privmsg queue for flood protection
internal.privmsg_queue_timer = setInterval( function tick() { var m
if ( m = internal.privmsg_queue.shift() )
- privmsg.call( this, m.receiver, m.message )
+ sendPrivmsg.call( this, m.receiver, m.message )
}.bind( this ), 200 )
internal.emitter.emit( 'connected' )
@@ -155,24 +155,26 @@ function parseMessage( data ) { var buffer, last, message, command, i
/**
* IRC#connect( [hollaback] ) -> self
* - hollaback ( Function ): Optional callback to be executed when the
- * connection is established an ready.
+ * connection is established an ready.
*
* Connect to the server.
**/
IRC.prototype.connect = function connect ( hollaback ) {
// Client setup
var not_open
- if ( !internal.socket || ( not_open = ( [ 'open', 'opening' ].indexOf( internal.socket.readyState ) < 0 ) ) ) {
- if ( not_open ) {
- internal.socket.end()
- internal.socket.removeAllListeners()
- internal.socket = null
- }
+ if ( typeof IRCExposeInternals != 'undefined' || !internal.socket || ( not_open = ( [ 'open', 'opening' ].indexOf( internal.socket.readyState ) < 0 ) ) ) {
+ if ( typeof IRCExposeInternals == 'undefined' ) {
+ if ( internal.socket != null ) {
+ internal.socket.end()
+ internal.socket.removeAllListeners()
+ internal.socket = null
+ }
- if ( this.options.ssl )
- internal.socket = require( 'tls' ).connect( this.options.port, this.options.server )
- else
- internal.socket = new require( 'net' ).Socket()
+ if ( this.options.ssl )
+ internal.socket = require( 'tls' ).connect( this.options.port, this.options.server )
+ else
+ internal.socket = new require( 'net' ).Socket()
+ }
internal.socket.setEncoding( this.options.encoding )
internal.socket.setTimeout( 0 )
@@ -228,7 +230,7 @@ IRC.prototype.disconnect = function disconnect () {
**/
IRC.prototype.raw = function raw ( data ) {
if ( internal.socket.readyState == 'open' ) {
- data = data.slice( 0, 509 )
+ data = data.slice( 0, 510 )
if ( !/\r\n$/.test( data ) )
data += "\r\n"
internal.socket.write( data )
@@ -305,21 +307,8 @@ IRC.prototype.removeListener = function removeListener ( event, hollaback ) { va
* irc_instance.once( 'ping', pingListener ) // Listens for the *next* PING message from server, then unregisters itself
**/
IRC.prototype.once = function once ( event, hollaback ) {
- // TODO GIANN: Switch to EventEmitter#once
- // Store reference and wrap
- internal.single_listener_cache[hollaback] = function( hollaback, message ) {
- // Call function
- hollaback.call( this, message )
-
- // Unregister self
- setTimeout( function() {
- internal.emitter.removeListener( event, internal.single_listener_cache[hollaback] )
- delete internal.single_listener_cache[hollaback]
- }, 0 )
- }.bind( this, hollaback )
-
- // Listen
- internal.emitter.addListener( event, internal.single_listener_cache[hollaback] )
+ internal.emitter.once( event, hollaback.bind( this ) )
+ return this
}
/** alias of: IRC#once
@@ -646,11 +635,11 @@ IRC.prototype.version = function version ( server, hollaback ) {
// 4.3.1
if ( !hollaback )
hollaback = server, server = null
- return this.once( '351', hollaback ).raw( 'VERSION' + if_exists( server ) )
-}
-
-IRC.prototype.stats = function stats () {
- // 4.3.2
+ return this
+ .once( '351', function( message ) {
+ hollaback.call( this, message.params.slice(1) )
+ })
+ .raw( 'VERSION' + if_exists( server ) )
}
/**
@@ -668,24 +657,23 @@ IRC.prototype.stats = function stats () {
*
* irc_instance.privmsg( '#asl', 'What\'s up ladiiieeeessssss!?' ) // Ask the ladies `what's up`
**/
-IRC.prototype.privmsg = function privmsg ( receiver, msg, protect ) { var max_length, private_messages, i
+IRC.prototype.privmsg = function privmsg ( receiver, msg, protect ) { var private_messages, i
// 4.4.1
if ( msg == '' )
return this
protect = protect === undefined ? this.options.flood_protection : protect
- max_length = 510 - 8 - receiver.length - 1 - 1
- private_messages = msg.match( new RegExp( '.{1,' + max_length + '}', 'g' ) )
+ private_messages = msg.match( new RegExp( '.{1,' + ( 510 - 8 - receiver.length - 1 - 1 ) + '}', 'g' ) )
for ( i = 0; i < private_messages.length; i++ )
if ( protect && i > 0 )
internal.privmsg_queue.push({ receiver: receiver, message: private_messages[i] })
else
- privmsg.call( this, receiver, private_messages[i] )
+ sendPrivmsg.call( this, receiver, private_messages[i] )
return this
}
-function privmsg ( receiver, msg ) {
+function sendPrivmsg ( receiver, msg ) {
this.raw( 'PRIVMSG' + param( receiver ) + ' ' + param( msg || '', null, ':' ) )
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 783d176

Please sign in to comment.