Skip to content

Commit

Permalink
Update forEach calls to be comprehensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Bell committed Oct 27, 2011
1 parent a4a6d50 commit 56a1115
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
14 changes: 11 additions & 3 deletions src/creator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Creator
#
# path - The destination
copyDefaultScripts: (path) ->
Fs.readdirSync(@scriptsDir).forEach (file) =>
for file in Fs.readdirSync(@scriptsDir)
@copy "#{@scriptsDir}/#{file}", "#{path}/#{file}"

# Run the creator process
Expand All @@ -52,7 +52,15 @@ class Creator

@copyDefaultScripts("#{@path}/scripts")

["Procfile", "package.json", "README.md", ".gitignore", "bin/hubot", "hubot-scripts.json"].forEach (file) =>
@copy "#{@templateDir}/#{file}", "#{@path}/#{file}"
files = [
"Procfile",
"package.json",
"README.md",
".gitignore",
"bin/hubot",
"hubot-scripts.json"
]

@copy "#{@templateDir}/#{file}", "#{@path}/#{file}" for file in files

exports.Creator = Creator
2 changes: 1 addition & 1 deletion src/hubot/campfire.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Campfire extends Robot
bot.Me (err, data) ->
bot.info = data.user
bot.name = bot.info.name
bot.rooms.forEach (room_id) ->
for room_id in bot.rooms
bot.Room(room_id).join (err, callback) ->
bot.Room(room_id).listen()

Expand Down
4 changes: 2 additions & 2 deletions src/hubot/hipchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Wobot = require("wobot").Bot
class HipChat extends Robot
send: (user, strings...) ->
console.log "Sending"
strings.forEach (str) =>
for str in strings
@bot.message user.reply_to, str

reply: (user, strings...) ->
console.log "Replying"
strings.forEach (str) =>
for str in strings
@send user, "@#{user.name} #{str}"

run: ->
Expand Down
2 changes: 1 addition & 1 deletion src/hubot/twilio.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Twilio extends Robot
console.log "successful sending #{body}"

reply: (user, strings...) ->
strings.forEach (str) =>
for str in strings
@send user, "#{user.name}: #{str}"

respond: (regex, callback) ->
Expand Down
4 changes: 2 additions & 2 deletions src/hubot/xmpp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class XmppBot extends Robot
@receive new Robot.TextMessage user, message

send: (user, strings...) ->
strings.forEach (str) =>
for str in strings
console.log "Sending to #{user.room}: #{str}"

to = if user.type in ['direct', 'chat'] then user.room + '/' + user.id else user.room
Expand All @@ -81,7 +81,7 @@ class XmppBot extends Robot
@client.send message

reply: (user, strings...) ->
strings.forEach (str) =>
for str in strings
@send user, "#{user.name}: #{str}"

module.exports = XmppBot
Expand Down
2 changes: 1 addition & 1 deletion src/robot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Robot
#
# Returns nothing.
receive: (message) ->
@listeners.forEach (lst) ->
for lst in @listeners
try
lst.call message
catch ex
Expand Down

0 comments on commit 56a1115

Please sign in to comment.