Skip to content

Commit

Permalink
ciscospark refactor 2/2
Browse files Browse the repository at this point in the history
  • Loading branch information
ytti committed Dec 3, 2018
1 parent adc2de7 commit 8f56230
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/oxidized/hook/ciscosparkdiff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ def run_hook(ctx)
config.api_key = cfg.accesskey
config.proxy = cfg.proxy if cfg.has_key?('proxy')
end
client = CiscoSpark::Room.new(id: cfg.space)
client.fetch
room = CiscoSpark::Room.new(id: cfg.space)
log "Connected"

if cfg.diff? ? cfg.diff : true
gitoutput = ctx.node.output.new
diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil
title = ctx.node.name.to_s
log "Posting diff as snippet to #{cfg.space}"
room = CiscoSpark::Room.new(id: cfg.space)
room.send_message CiscoSpark::Message.new(text: 'Device ' + title + ' modified:' + "\n" + diff[:patch].lines.to_a[4..-1].join)
end

if cfg.message?
log cfg.message
msg = cfg.message % { node: ctx.node.name.to_s, group: ctx.node.group.to_s, commitref: ctx.commitref, model: ctx.node.model.class.name.to_s.downcase }
log msg
log "Posting message to #{cfg.space}"
room = CiscoSpark::Room.new(id: cfg.space)
room.send_message CiscoSpark::Message.new(text: msg)
end

log "Finished"
end
end

0 comments on commit 8f56230

Please sign in to comment.