Class: GrowlAtom::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/growl-atom.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ Checker

Returns a new instance of Checker.



19
20
21
22
23
# File 'lib/growl-atom.rb', line 19

def initialize(config_file)
	
	@config_file = config_file

end

Instance Method Details

#check(url, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/growl-atom.rb', line 25

def check(url, options = {}) 
=begin				
	cache_file = 'cache'

	system("touch #{cache_file}")
	
	# Download it
	http = Net::HTTP.new('mail.google.com', 443)
	req = Net::HTTP::Get.new('/mail/feed/atom/')
	http.use_ssl = true
	http.verify_mode = OpenSSL::SSL::VERIFY_NONE
	req.basic_auth '', ''
	response = http.request(req)
	
	# Parse it	
	include REXML
	
	doc = Document.new response.body
	doc.elements.each('//entry') {|entry| 
		
		id = entry.elements['id'].text			
		
		if (!system("grep #{id} #{cache_file} > /dev/null")) 
		
			GrowlGmail.notify({
				:message => entry.elements['title'].text,
				:title => entry.elements['author/name'].text
			})
			
			system("echo #{id} >> #{cache_file}")
		
		end
	
	}				
			  
=end		
end

#notify(options) ⇒ Object



63
64
65
66
# File 'lib/growl-atom.rb', line 63

def notify(options)
#			#image = File.join(File.expand_path(File.dirname(__FILE__)), "gmail.png")
	Growl.notify 'Growl Atom', options.merge({:name => 'GrowlGmail', :image => image, :host => 'localhost'})
end