imap_notifier 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imap_notifier (0.2.4)
4
+ imap_notifier (0.2.5)
5
5
  highline
6
6
  ruby-growl
7
7
  terminal-notifier
data/README.md CHANGED
@@ -7,7 +7,7 @@ If you're running Max OSX > 10.8, [terminal-notifier](https://github.com/alloy/t
7
7
 
8
8
  Setup
9
9
  --------
10
- Configure your .imap_notifier config file in your homedir or specific the flags via the command line. Your config file must have permissions of 600, thus allowing you to put in your password if you so choose. The config file is in YAML format and should be read in as a hash.
10
+ Configure your .imap_notifier config file in your homedir or specific the flags via the command line. Your config file must have permissions of 600, thus allowing you to put in your password if you so choose. The config file is in YAML format and should be read in as a hash.
11
11
 
12
12
 
13
13
  Example ~/.imap_notifier file
@@ -23,6 +23,12 @@ Example ~/.imap_notifier file
23
23
  password: "1H@t3BuG$!"
24
24
  max: 10
25
25
 
26
+
27
+ For Keychain Access support, specify the keychain item name and account in .imap_notifier. The item must be designated an 'Internet password' in Keychain Access.
28
+
29
+ key_name: 'keychain.name.com'
30
+ key_account: 'han.solo@keychain-account.com'
31
+
26
32
  Usage
27
33
  ---------
28
34
 
@@ -66,11 +66,6 @@ class IMAP_Notifier
66
66
  exit
67
67
  end
68
68
 
69
- private
70
- def get_password(prompt="Enter Password: ")
71
- ask(prompt) { |q| q.echo = false }
72
- end
73
-
74
69
  def _imap
75
70
  imap = Net::IMAP.new(@imap_server, { :port => 993, :ssl => true } )
76
71
  imap.login(@user, @password)
@@ -4,7 +4,13 @@ class IMAP_Notifier
4
4
  @imap_server = opts[:server] || IMAP_SERVER
5
5
  @domain = opts[:domain] || @imap_server.split('.').pop(2).join('.')
6
6
  @user = "#{opts[:user]}@#{@domain}"
7
- @password = opts[:password] || get_password
7
+ $key_name = opts[:key_name] || false
8
+ $key_account = opts[:key_account] || false
9
+ if $key_name && $key_account
10
+ @password = keychain_access || get_password
11
+ else
12
+ @password = opts[:password] || get_password
13
+ end
8
14
  @folders = mbox_conf opts[:folders] || ['INBOX']
9
15
  @debug = opts[:debug] || false
10
16
  @max_mail = opts[:max] || MAX_MAIL
@@ -15,6 +21,25 @@ class IMAP_Notifier
15
21
  Hash[ary.map{ |f| [f,Array.new] }]
16
22
  end
17
23
 
24
+ private
25
+ def keychain_access
26
+ key = get_keychain
27
+ if key == ""
28
+ return nil
29
+ end
30
+ return key.chomp
31
+ end
32
+
33
+ private
34
+ def get_keychain
35
+ key = %x{security find-internet-password -w -a #{$key_account} -s #{$key_name}}
36
+ end
37
+
38
+ private
39
+ def get_password(prompt="Enter Password: ")
40
+ ask(prompt) { |q| q.echo = false }
41
+ end
42
+
18
43
  def read_conf opts
19
44
  file = File.expand_path("~/.imap_notifier")
20
45
  return if ! File.exists? file
@@ -32,3 +57,4 @@ class IMAP_Notifier
32
57
  exit 1
33
58
  end
34
59
  end
60
+
@@ -1,3 +1,3 @@
1
1
  class IMAP_Notifier
2
- VERSION='0.2.4'
2
+ VERSION='0.2.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-04 00:00:00.000000000 Z
12
+ date: 2014-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -1862814060607132887
136
+ hash: 726022834722288523
137
137
  requirements: []
138
138
  rubyforge_project:
139
139
  rubygems_version: 1.8.23