module GitlabNotifier

Constants

CONFIG_FILE
VERSION

Public Class Methods

notify(body, title: nil) click to toggle source
# File lib/gitlab_notifier.rb, line 12
def self.notify(body, title: nil)
  TerminalNotifier.notify(body, title: title)
end
read_rss() click to toggle source
# File lib/gitlab_notifier.rb, line 16
def self.read_rss
  configs = YAML.load_file(CONFIG_FILE)
  configs['atom'].each do |atom|
    atom_type, atom_address = atom
    atom_last_read = configs['last_read']["#{atom_type}"]
    rss = RSS::Parser.parse(atom_address, false)
    next if !atom_last_read.nil? && rss.updated.content <= atom_last_read
    rss.items.select do |item|
      notify "#{item.title.content}", title: "#{atom_type.capitalize}" if atom_last_read.nil? || item.updated.content > atom_last_read
    end
    configs['last_read']["#{atom_type}"] = rss.updated.content
    File.open(CONFIG_FILE, 'w') { |f| YAML.dump(configs, f) }
  end
end