plugins/trello_plugin.rb in ladder_drive-0.6.3 vs plugins/trello_plugin.rb in ladder_drive-0.6.4

- old
+ new

@@ -78,29 +78,30 @@ return if disabled? return if config[:events].nil? @config[:events].each do |event| begin - + event_id = event.object_id triggered = false now = Time.now device = nil case event[:trigger][:type] when "interval" - t = @times[event.object_id] || now + t = @times[event_id] || now triggered = t <= now if triggered triggered = true t += event[:trigger][:interval] || 300 - @times[event.object_id] = t + @times[event_id] = t end else device = plc.device_by_name event[:trigger][:device] v = device.send event[:trigger][:value_type], event[:trigger][:text_length] || 8 - unless @values[device.name] == v - @values[device.name] = v + @values[event_id] ||= {} + unless @values[event_id][device.name] == v + @values[event_id][device.name] = v case event[:trigger][:type] when "raise" triggered = !!v when "fall" triggered = !v @@ -114,10 +115,12 @@ @worker_queue.push event:event, device_name:device.name, value:v, time: now rescue => e p e +puts $! +puts $@ end end end private @@ -135,11 +138,11 @@ board = Trello::Board.all.find{|b| b.name == event[:board_name]} next unless board card_name = event[:card_name].dup || "" - card_name.gsub!(/__value__/, arg[:value] || "") + card_name.gsub!(/__value__/, arg[:value] || "") if arg[:value].is_a? String next if (card_name || "").empty? list_name = event[:list_name] next unless list_name list = board.lists.find{|l| l.name == list_name} @@ -153,9 +156,11 @@ end rescue => e # TODO: Resend if it fails. p e +puts $! +puts $@ end end end end