imap_notifier 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/bin/imap_notifier +3 -3
- data/lib/imap_notifier.rb +1 -1
- data/lib/imap_notifier/base.rb +10 -4
- data/lib/imap_notifier/config.rb +7 -6
- data/lib/imap_notifier/version.rb +1 -1
- metadata +20 -5
- checksums.yaml +0 -15
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,8 +17,9 @@ Example ~/.imap_notifier file
|
|
17
17
|
- Monitoring
|
18
18
|
- Commits
|
19
19
|
- Team+Status
|
20
|
-
user:
|
20
|
+
user: 'han.solo'
|
21
21
|
domain: 'example.org'
|
22
|
+
server: 'imap.server.com'
|
22
23
|
password: "1H@t3BuG$!"
|
23
24
|
max: 10
|
24
25
|
|
@@ -43,4 +44,4 @@ Tips
|
|
43
44
|
------
|
44
45
|
|
45
46
|
* User name is pulled from your environment via ```ruby ENV['USER'] ```
|
46
|
-
* If the root domain of your IMAP server is the same as your email domain (i.e. imap._gmail.com_ IS the same as user@_gmail.com_) then you only need to specify the IMAP server.
|
47
|
+
* If the root domain of your IMAP server is the same as your email domain (i.e. imap._gmail.com_ IS the same as user@_gmail.com_) then you only need to specify the IMAP server.
|
data/bin/imap_notifier
CHANGED
@@ -28,12 +28,12 @@ opt_parser = OptionParser.new do |opt|
|
|
28
28
|
opts[:config] = c
|
29
29
|
end
|
30
30
|
|
31
|
-
opt.on('-s','--server STR', "Specify imap server.\t[Default: #{
|
32
|
-
|
31
|
+
opt.on('-s','--server STR', "Specify imap server.\t[Default: #{IMAP_SERVER}]") do |s|
|
32
|
+
opts[:server] = s
|
33
33
|
end
|
34
34
|
|
35
35
|
opt.on('-d','--domain STR',
|
36
|
-
"Specify email domain.\t[Default: #{
|
36
|
+
"Specify email domain.\t[Default: #{IMAP_SERVER.split('.').pop(2).join('.')}]") do |d|
|
37
37
|
opts[:domain] = d.gsub(/.+\@/,'')
|
38
38
|
end
|
39
39
|
|
data/lib/imap_notifier.rb
CHANGED
@@ -12,7 +12,7 @@ SLEEP = 30
|
|
12
12
|
ERRFILE = File.expand_path('~/Desktop/imap_notifier.log')
|
13
13
|
DEBUGFILE = '/tmp/imap_notifier.debug'
|
14
14
|
PIDFILE = '/tmp/imap_notifier.pid'
|
15
|
-
|
15
|
+
IMAP_SERVER = "imap.gmail.com" # could be anything with tweaks
|
16
16
|
|
17
17
|
if `uname`.strip == 'Darwin'
|
18
18
|
if (OSX_VERSION = `sw_vers -productVersion`.strip) >= '10.8'
|
data/lib/imap_notifier/base.rb
CHANGED
@@ -5,6 +5,12 @@ class IMAP_Notifier
|
|
5
5
|
Process.kill("SIGINT", pid)
|
6
6
|
rescue Errno::ESRCH, Errno::ENOENT => e
|
7
7
|
puts "#{e.message} - Exiting..."
|
8
|
+
ensure
|
9
|
+
self.delete_pid
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.delete_pid
|
13
|
+
File.delete(PIDFILE) if File.exists?(PIDFILE)
|
8
14
|
end
|
9
15
|
|
10
16
|
def initialize(opts={})
|
@@ -29,7 +35,7 @@ class IMAP_Notifier
|
|
29
35
|
@imap = nil
|
30
36
|
rescue Exception => err
|
31
37
|
say_goodbye(err.class.to_s) || handle_exception(err)
|
32
|
-
|
38
|
+
stop
|
33
39
|
end while true
|
34
40
|
end
|
35
41
|
|
@@ -56,7 +62,8 @@ class IMAP_Notifier
|
|
56
62
|
|
57
63
|
def stop
|
58
64
|
IMAP_Notifier::Alert.remove
|
59
|
-
|
65
|
+
self.class.delete_file
|
66
|
+
exit
|
60
67
|
end
|
61
68
|
|
62
69
|
private
|
@@ -65,7 +72,7 @@ class IMAP_Notifier
|
|
65
72
|
end
|
66
73
|
|
67
74
|
def _imap
|
68
|
-
imap = Net::IMAP.new(
|
75
|
+
imap = Net::IMAP.new(@imap_server, { :port => 993, :ssl => true } )
|
69
76
|
imap.login(@user, @password)
|
70
77
|
@notifier.alert("#{@user} connected!", :group => @domain)
|
71
78
|
return imap
|
@@ -74,7 +81,6 @@ class IMAP_Notifier
|
|
74
81
|
def say_goodbye(klass)
|
75
82
|
return if !(klass.eql? "Interrupt")
|
76
83
|
@notifier.alert("Goodbye!", :group => @domain)
|
77
|
-
File.delete(ERRFILE) if File.exists?(ERRFILE)
|
78
84
|
end
|
79
85
|
|
80
86
|
def handle_exception(err)
|
data/lib/imap_notifier/config.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
class IMAP_Notifier
|
2
2
|
def config(opts={})
|
3
3
|
read_conf opts
|
4
|
-
@
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
4
|
+
@imap_server = opts[:server] || IMAP_SERVER
|
5
|
+
@domain = opts[:domain] || @imap_server.split('.').pop(2).join('.')
|
6
|
+
@user = "#{opts[:user]}@#{@domain}"
|
7
|
+
@password = opts[:password] || get_password
|
8
|
+
@folders = mbox_conf opts[:folders] || ['INBOX']
|
9
|
+
@debug = opts[:debug] || false
|
10
|
+
@max_mail = opts[:max] || MAX_MAIL
|
10
11
|
end
|
11
12
|
|
12
13
|
private
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- David Campbell
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: highline
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: ruby-growl
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: terminal-notifier
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -104,26 +115,30 @@ files:
|
|
104
115
|
homepage: https://github.com/dacamp/imap_notifier
|
105
116
|
licenses:
|
106
117
|
- MIT
|
107
|
-
metadata: {}
|
108
118
|
post_install_message:
|
109
119
|
rdoc_options: []
|
110
120
|
require_paths:
|
111
121
|
- lib
|
112
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
113
124
|
requirements:
|
114
125
|
- - ! '>='
|
115
126
|
- !ruby/object:Gem::Version
|
116
127
|
version: 1.9.2
|
117
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
118
130
|
requirements:
|
119
131
|
- - ! '>='
|
120
132
|
- !ruby/object:Gem::Version
|
121
133
|
version: '0'
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
hash: -1862814060607132887
|
122
137
|
requirements: []
|
123
138
|
rubyforge_project:
|
124
|
-
rubygems_version:
|
139
|
+
rubygems_version: 1.8.23
|
125
140
|
signing_key:
|
126
|
-
specification_version:
|
141
|
+
specification_version: 3
|
127
142
|
summary: Notification of new, unread email via IMAP using Ruby, Highline, Net/IMAP,
|
128
143
|
and terminal-notifier/ruby-growl. If you're running Max OSX > 10.8, terminal-notifier
|
129
144
|
is required, otherwise ruby-growl and Growl is required.
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
M2M4NjlmOTY0ZTUxNWRlY2JlOTUwNjY1ZDgyNGY5OTQ0YmZlNjE2YQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZWE4OThiYjczOTM0MGY3YTVkN2Y4ZmFkZWQwMDI3YjEwM2M4YjQxZA==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZGUwMmJhNDQ2ODJlNjM0Y2UxYTRlODlmZjY4ZWZiMzNlYmFhYTE5OTg1Njhh
|
10
|
-
MGQxOWQ0YmQzZjAzNmU2YTBiNzM3ODRjMzMwYjI0NmE4OGJlYWIxMzFlNzhl
|
11
|
-
NDVkMzhlODAxNWEyMTA5OGU5ZWM1MGIxYTJjMmU3ZTEzZjc4OTE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmVkNTA3YzlmMDU5Y2IyOGJhMmQ4Y2EzOWY0MjI0N2NhMGY3N2Q3YzE2OTk2
|
14
|
-
NzVhNDViZTU5Y2ViZjdjNjllMDdmZThmMGM4YjYwMTM2YzRlZDlhMmIzZDE3
|
15
|
-
MzEyZGNiZDMzMmNiZjYwN2VkN2Q1OTM4MGU5M2FkZjlmOTNmODY=
|