diff --git a/.gitignore b/.gitignore index 0352a7b..f7fc783 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ lib *.tgz - +node_modules diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 0000000..0c535e5 --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,61 @@ +#global module:false +module.exports = (grunt) -> + + # Project configuration. + grunt.initConfig + watch: + files: ["src/**/*.coffee"] + tasks: ["coffee", "jshint"] + + nodeunit: { + all: ['test/**/*_test.js'] + } + + jshint: + files: ["Gruntfile.js", "src/**/*.js", "test/**/*.js"] + options: + curly: true + eqeqeq: true + immed: true + latedef: true + newcap: true + noarg: true + sub: true + undef: true + boss: true + eqnull: true + + globals: + jQuery: true + require: true + module: true + process: true + + coffee: + compile: + files: + "lib/irc.js": "src/irc.coffee" + + coffeelint: + client: ["src/**/*.coffee"] + options: + indentation: + value: 2 + level: 'error' + no_empty_param_list: + level: 'ignore' + no_implicit_braces: + level: 'ignore' + no_implicit_parens: + level: 'ignore' + max_line_length: + level: 'ignore' + + grunt.loadNpmTasks "grunt-contrib-watch" + grunt.loadNpmTasks "grunt-contrib-jshint" + grunt.loadNpmTasks "grunt-contrib-coffee" + grunt.loadNpmTasks "grunt-contrib-nodeunit" + grunt.loadNpmTasks "grunt-coffeelint" + + # Default task. + grunt.registerTask "default", ["coffee", "jshint", "coffeelint"] diff --git a/package.json b/package.json index 5d7b727..192cecb 100644 --- a/package.json +++ b/package.json @@ -22,5 +22,12 @@ "dependencies": { "irc": "0.3.6" }, - "devDependencies": {} + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-coffee": "~0.6.2", + "grunt-contrib-jshint": "~0.3.0", + "grunt-contrib-watch": "~0.3.1", + "grunt-contrib-nodeunit": "~0.2.0", + "grunt-coffeelint": "~0.0.6" + } } diff --git a/src/irc.coffee b/src/irc.coffee index afb50a3..ea56bba 100644 --- a/src/irc.coffee +++ b/src/irc.coffee @@ -66,17 +66,17 @@ class IrcBot extends Adapter return @userForId id createUser: (channel, from) -> - user = @getUserFromName from - unless user? - id = new Date().getTime().toString() - user = @getUserFromId id - user.name = from - - if channel.match(/^[&#]/) - user.room = channel - else - user.room = null - user + user = @getUserFromName from + unless user? + id = new Date().getTime().toString() + user = @getUserForId id + user.name = from + + if channel.match(/^[&#]/) + user.room = channel + else + user.room = null + user kick: (channel, client, message) -> @bot.emit 'raw',