bcbiff 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +4 -3
  2. data/bcbiff.gemspec +1 -1
  3. data/lib/bcbiff.rb +25 -24
  4. metadata +3 -3
data/README.md CHANGED
@@ -73,9 +73,6 @@ your system and run bcbiff once a minute or so.
73
73
 
74
74
  Bcbiff will run with Ruby 1.8.7+ and 1.9.2+.
75
75
 
76
- See `Gemfile` for dependency. Run `bundle install` to install what's
77
- missing.
78
-
79
76
  Bcbiff calls the `sendmail` command to send a mail. Sendmail (or any
80
77
  compatible software such as qmail or Postfix) must be properly
81
78
  configured.
@@ -86,6 +83,10 @@ if bcbiff(1) fails to locate the one on your system, follow the
86
83
  instruction displayed, and let me know if it's pretty much common on
87
84
  the platform.
88
85
 
86
+ ## INSTALLATION
87
+
88
+ `gem install bcbiff`
89
+
89
90
  ## SEE ALSO
90
91
 
91
92
  * [Boxcar](http://boxcar.io/)
data/bcbiff.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bcbiff"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Akinori MUSHA"]
data/lib/bcbiff.rb CHANGED
@@ -34,7 +34,7 @@ require 'yaml'
34
34
  require 'mail'
35
35
  require 'shellwords'
36
36
 
37
- BCBIFF_VERSION = '0.2.0'
37
+ BCBIFF_VERSION = '0.2.1'
38
38
 
39
39
  CERTS_PATHS = [
40
40
  '/etc/ssl/cert.pem', # FreeBSD
@@ -129,34 +129,35 @@ def check_mails(options)
129
129
  File.open(msgids_file, File::RDWR | File::CREAT, 0600) {|f|
130
130
  f.flock(File::LOCK_EX | File::LOCK_NB) or break
131
131
 
132
+ msgids = YAML.load(f) || []
133
+
132
134
  imap = Net::IMAP.new(options[:host], options[:port], options[:ssl], certs_path, true)
133
135
  imap.login(options[:username], options[:password])
134
136
  folders = options[:folders] || ['Inbox']
135
- unseen = folders.inject([]) { |unseen, folder|
136
- imap.select(folder)
137
- unseen.concat(imap.search('UNSEEN'))
138
- }
139
- return if unseen.empty?
140
-
141
- msgids = YAML.load(f) || []
142
137
 
143
- imap.fetch(unseen, item = 'RFC822.HEADER').each { |data|
144
- mail = Mail.read_from_string(data.attr[item])
145
- msgid = mail.message_id
146
- next if msgids.include?(msgid)
147
- msgids << msgid
148
-
149
- (header = mail.header).fields.each { |field|
150
- case name = field.name
151
- when /\A(From|Subject|Date)\z/i
152
- # preserve
153
- else
154
- header[name] = nil
155
- end
156
- }
138
+ folders.each { |folder|
139
+ imap.select(folder)
140
+ unseen = imap.search('UNSEEN')
141
+ next if unseen.empty?
142
+
143
+ imap.fetch(unseen, item = 'RFC822.HEADER').each { |data|
144
+ mail = Mail.read_from_string(data.attr[item])
145
+ msgid = mail.message_id
146
+ next if msgids.include?(msgid)
147
+ msgids << msgid
148
+
149
+ (header = mail.header).fields.each { |field|
150
+ case name = field.name
151
+ when /\A(From|Subject|Date)\z/i
152
+ # preserve
153
+ else
154
+ header[name] = nil
155
+ end
156
+ }
157
157
 
158
- open("| sendmail #{mailto.shellescape}", 'w') { |sendmail|
159
- sendmail.print mail.encoded
158
+ open("| sendmail #{mailto.shellescape}", 'w') { |sendmail|
159
+ sendmail.print mail.encoded
160
+ }
160
161
  }
161
162
  }
162
163
  msgids.slice!(0...-IDCACHE_SIZE) if msgids.size > IDCACHE_SIZE
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcbiff
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akinori MUSHA