Sha256: dd28f994ceed35dbe239bb74ea31485afce3b70ef833a3b481e7fc309f905b56

Contents?: true

Size: 931 Bytes

Versions: 5

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true

module Fushin
  class Monitor
    attr_reader :rss
    def initialize
      @rss = RSS.new
    end

    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

    def self.check
      new.check
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fushin-0.4.2 lib/fushin/monitor.rb
fushin-0.4.1 lib/fushin/monitor.rb
fushin-0.4.0 lib/fushin/monitor.rb
fushin-0.3.4 lib/fushin/monitor.rb
fushin-0.3.3 lib/fushin/monitor.rb