matth-growl-gmail 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/growl-gmail ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'growl-gmail'
5
+
6
+ GrowlGmail.check
data/lib/gmail.png ADDED
Binary file
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'growl'
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'rexml/document'
6
+
7
+ module GrowlGmail
8
+
9
+ VERSION = "0.0.1"
10
+
11
+ def GrowlGmail.check
12
+
13
+ cache_file = 'cache'
14
+
15
+ system("touch #{cache_file}")
16
+
17
+ # Download it
18
+ http = Net::HTTP.new('mail.google.com', 443)
19
+ req = Net::HTTP::Get.new('/mail/feed/atom/')
20
+ http.use_ssl = true
21
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
22
+ req.basic_auth '', ''
23
+ response = http.request(req)
24
+
25
+ # Parse it
26
+ include REXML
27
+
28
+ doc = Document.new response.body
29
+ doc.elements.each('//entry') {|entry|
30
+
31
+ id = entry.elements['id'].text
32
+
33
+ if (!system("grep #{id} #{cache_file} > /dev/null"))
34
+
35
+ GrowlGmail.notify({
36
+ :message => entry.elements['title'].text,
37
+ :title => entry.elements['author/name'].text
38
+ })
39
+
40
+ system("echo #{id} >> #{cache_file}")
41
+
42
+ end
43
+
44
+ }
45
+
46
+ end
47
+
48
+ def GrowlGmail.notify(options)
49
+ image = File.join(File.expand_path(File.dirname(__FILE__)), "gmail.png")
50
+ Growl.notify 'New Mail', options.merge({:name => 'GrowlGmail', :image => image, :host => 'localhost'})
51
+ end
52
+
53
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matth-growl-gmail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Haynes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-08 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: growl
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.6
24
+ version:
25
+ description:
26
+ email: matt@matthaynes.net
27
+ executables:
28
+ - growl-gmail
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - lib/growl-gmail.rb
35
+ - lib/gmail.png
36
+ has_rdoc: false
37
+ homepage: http://matthaynes.net/blog/
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Create growl notifications for incoming Gmail messages
62
+ test_files: []
63
+