class Sensor::OutputDistribution::FlowDock

Public Class Methods

new(payload) click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 6
def initialize(payload)
  @payload = payload
  @time_range = payload.time_range
end

Public Instance Methods

distribute() click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 11
def distribute
  flow.push_to_team_inbox({
    subject: "Sensor Output: " +
      "#{format_date(@payload.start_date)} - " +
      "#{format_date(@payload.end_date)}",
    content: content
  })
end

Protected Instance Methods

content() click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 25
def content
  @payload.data.inject("") do |str, key_value|
    str += "<h3>#{key_value[0]}</h3>"

    str += "<ul>"
    key_value[1].each do |attribute, value|
      str += "<li><strong>#{attribute}</strong>: #{value}</li>"
    end
    str += "</ul>"
  end
end
flow() click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 37
def flow
  @flow ||= ::Flowdock::Flow.new(
    api_token: token,
    source: 'Sensor',
    from: {
      name: 'Sensor',
      address: 'hello@sensor.com'
    }
  )
end
format_date(date) click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 21
def format_date(date)
  date.strftime("%m/%d/%Y")
end
token() click to toggle source
# File lib/sensor/output_distribution/flow_dock.rb, line 48
def token
  ENV['FLOWDOCK_TOKEN']
end