class Fushin::Monitor

Attributes

rss[R]

Public Class Methods

check() click to toggle source
# File lib/fushin/monitor.rb, line 30
def self.check
  new.check
end
new() click to toggle source
# File lib/fushin/monitor.rb, line 6
def initialize
  @rss = RSS.new
end

Public Instance Methods

check() click to toggle source
# File lib/fushin/monitor.rb, line 10
def check
  rss.items.each do |item|
    next if Cache.cached?(item.link)

    attachements = [].tap do |out|
      out << item.post.btcs.map(&:to_attachements)
      out << item.post.urls.map(&:to_attachements)
      out << item.post.attachements.map(&:to_attachements)
    end.flatten
    attachements << { text: "IoC is not found." } if attachements.empty?
    Notifier.notify("#{item.title} (#{item.link})", attachements)
  rescue StandardError => e
    attachements = []
    attachements << { text: "#{e.class} (#{e}) is happened during processing." }
    Notifier.notify("#{item.title} (#{item.link})", attachements)
  ensure
    Cache.save(item.link, true)
  end
end