PRagger:notify_growlãæ¸ãã¦ã¿ã
æ¸ãã¦ã¿ãã®ã¯ãããï¼PRaggerã®ææ°çãçããªãããã¦ã¦ããã£ãï¼Configã¯ã©ã¹ã¨ãæ¶ãããã ï¼ãã£ã±gemãç´ ç´ã«requireã§ããªãã®ã¯ä¸é½åãªã®ããªï¼ãé°ã§ï¼notify_growlãææ°ç対å¿ããã¨ããå°ãç°¡åã«ãªãããã£ã¦ãã¨ã§ï¼ã¡ãã£ã¨ä¿®æ£ï¼ä»ã«è³ãï¼
å¿ è¦ãªãã®
def notify_growl(config, data) require 'rubygems' begin require 'ruby-growl' rescue LoadError puts <<LERR LoadError: Please install gem "ruby-growl" # gem install ruby-growl LERR exit end default_setting = { :host => "localhost", # host to connect :app_name => "PRagger", # name of the application :password => nil, # needed to send notifications to host :title => "PRagger", # title for notification :sticky => false, # makes the notification stick until clicked :jp => false # notify in Japanese (default English) } default_setting.each do |k, v| unless config[k] config[k] = v end end if data.size > 0 g = Growl.new(config[:host], config[:app_name], ["notify-growl"], nil, config[:password]) if config[:jp] message = "#{data.size}件ã®æ°çãã£ã¼ããããã¾ã" else message = "#{data.size} new feeds available" end begin g.notify("notify_growl", config[:title], message, 0, config[:sticky]) rescue puts <<NOGROWL Error: Please install or start Growl http://growl.info/ NOGROWL exit end end return data end
æã£ããã ãã©ï¼ããPRaggeræ¬ä½ã§rubygemsãããã¯requireãã¨ãã¦æã¯ç¡ããããï¼ã¡ãªã¿ã«ï¼ã½ã¼ã¹ã³ã¼ãä¸ã®è±æã¯é©å½ï¼