imap_guard 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d95cc42f451c9e8d2230c9ed670c5b5cb5f42d20
4
- data.tar.gz: 22a08ac744d604430aa795cf156f8b0ea899a9fc
3
+ metadata.gz: b9bad59e96b10c29a2a065cd6b5d866f10e8d7c8
4
+ data.tar.gz: d110224b73afef6abc0cc7805aefc906ee222b35
5
5
  SHA512:
6
- metadata.gz: 9a7fe8edceec8be75626f91f69b8228bd1e2f4205d4fe52f742cf5bea0b828f79851e3ce9b843c1941eaefe63092541204c61f8c225bcbdcf54dfc3e7d29c1b7
7
- data.tar.gz: 47a6ba91f840a30ad8164a84593f3fdbd91fdf5c46bd798a74f1af8926152b66e0c2af02ddfcebfc3f2166fe04dd6f843fe04cf6213266daba6822f4e79e7fc2
6
+ metadata.gz: ef2d1979d3459bf83732861e5d6972af03cf698dd3178b8d9b7326eed9b0c44c4b17b3dab7c038a14425c5eb980c7f3255f6d412729af4c89810e66d597a42f9
7
+ data.tar.gz: f23003553803bf31aaf648d840f221a627387c147e326e399f8ecf02a320059325ef6a412161a00c35a96efea91fc65f1e2e2097309c18097045f8b932b02a0d
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2
@@ -5,14 +5,11 @@ after_script:
5
5
  rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
- - 2.1.0
8
+ - 2.1
9
+ - 2.2
9
10
  - ruby-head
10
11
  - rbx
11
12
  matrix:
12
13
  allow_failures:
13
14
  - rvm: ruby-head
14
15
  - rvm: rbx
15
- notifications:
16
- email:
17
- on_success: always
18
- on_failure: always
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Cédric Félizard
1
+ Copyright (c) 2013-2015 Cédric Félizard
2
2
 
3
3
  MIT License
4
4
 
@@ -1,11 +1,10 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'imap_guard/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "imap_guard"
8
- spec.version = ImapGuard::VERSION
7
+ spec.version = "1.0.0"
9
8
  spec.authors = ["Cédric Félizard"]
10
9
  spec.email = ["cedric@felizard.fr"]
11
10
  spec.description = %q{A guard for your IMAP server}
@@ -18,10 +17,10 @@ Gem::Specification.new do |spec|
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
21
- spec.add_dependency 'mail', '~> 2.5.3'
22
- spec.add_dependency 'term-ansicolor', '~> 1.2.2'
20
+ spec.add_dependency 'mail', '>= 2.5.3'
21
+ spec.add_dependency 'term-ansicolor', '>= 1.2.2'
23
22
 
24
- spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'bundler', '>= 1.3'
25
24
  spec.add_development_dependency 'rake'
26
25
  spec.add_development_dependency 'simplecov'
27
26
  spec.add_development_dependency 'rspec'
@@ -1,4 +1,3 @@
1
- require "imap_guard/version"
2
1
  require "imap_guard/guard"
3
2
  require "imap_guard/query"
4
3
 
@@ -80,6 +80,23 @@ module ImapGuard
80
80
  process query, operation, &filter
81
81
  end
82
82
 
83
+ # Runs operation on messages matching the query
84
+ # @param query IMAP query
85
+ # @param opration Lambda to call on each message
86
+ # @return [void]
87
+ def each query
88
+ operation = lambda { |message_id| yield message_id }
89
+ process query, operation
90
+ end
91
+
92
+ # Fetches a message from its UID
93
+ # @return [Mail]
94
+ # @note We use "BODY.PEEK[]" to avoid setting the \Seen flag.
95
+ def fetch_mail message_id
96
+ msg = @imap.fetch(message_id, 'BODY.PEEK[]').first.attr['BODY[]']
97
+ Mail.read_from_string msg
98
+ end
99
+
83
100
  # @return [Array<String>] Sorted list of all mailboxes
84
101
  def list
85
102
  @imap.list("", "*").map(&:name).sort
@@ -127,23 +144,13 @@ module ImapGuard
127
144
  end
128
145
  end
129
146
 
130
- if result
131
- puts operation.call(message_id)
132
- else
133
- puts "ignored".green
134
- end
147
+ puts result ? operation.call(message_id) : "ignored".green
135
148
  end
136
149
 
137
150
  ensure
138
151
  expunge
139
152
  end
140
153
 
141
- # @note We use "BODY.PEEK[]" to avoid setting the \Seen flag.
142
- def fetch_mail message_id
143
- msg = @imap.fetch(message_id, 'BODY.PEEK[]').first.attr['BODY[]']
144
- Mail.read_from_string msg
145
- end
146
-
147
154
  def search query
148
155
  unless [Array, String].any? { |type| query.is_a? type }
149
156
  raise TypeError, "Query must be either a string holding the entire search string, or a single-dimension array of search keywords and arguments."
@@ -8,6 +8,12 @@ module ImapGuard
8
8
  self << 'SEEN'
9
9
  end
10
10
 
11
+ # Messages that do not have the +\Seen+ flag set.
12
+ # @return [self]
13
+ def unseen
14
+ self << 'UNSEEN'
15
+ end
16
+
11
17
  # Messages that do not have the +\Answered+ flag set.
12
18
  # @return [self]
13
19
  def unanswered
@@ -81,6 +87,13 @@ module ImapGuard
81
87
  self << 'TO' << string
82
88
  end
83
89
 
90
+ # Messages that contain the specified string in the envelope
91
+ # structure's CC field.
92
+ # @return [self]
93
+ def cc string
94
+ self << 'CC' << string
95
+ end
96
+
84
97
  # Messages whose internal date (disregarding time and timezone)
85
98
  # is earlier than the specified date.
86
99
  # @param date Depending of its type:
@@ -19,9 +19,9 @@ module ImapGuard
19
19
  }
20
20
  end
21
21
 
22
- let(:imap) {
22
+ let(:imap) do
23
23
  double('Net::IMAP', search: [7, 28], expunge: nil, select: nil, list: [])
24
- }
24
+ end
25
25
 
26
26
  def guard_instance custom_settings = {}
27
27
  guard = Guard.new(settings.merge(custom_settings))
@@ -171,6 +171,14 @@ module ImapGuard
171
171
  end
172
172
  end
173
173
 
174
+ describe "#each" do
175
+ it "iterates over messages without errors" do
176
+ guard_instance.each 'ALL' do |message_id|
177
+ # noop
178
+ end
179
+ end
180
+ end
181
+
174
182
  describe "#expunge" do
175
183
  it "expunges the folder" do
176
184
  imap.should_receive(:expunge)
@@ -13,6 +13,13 @@ module ImapGuard
13
13
  end
14
14
  end
15
15
 
16
+ describe "#unseen" do
17
+ it "adds 'UNSEEN'" do
18
+ subject.unseen
19
+ subject.last.should eq 'UNSEEN'
20
+ end
21
+ end
22
+
16
23
  describe "#unanswered" do
17
24
  it "adds 'UNANSWERED'" do
18
25
  subject.unanswered
@@ -83,6 +90,13 @@ module ImapGuard
83
90
  end
84
91
  end
85
92
 
93
+ describe "#cc" do
94
+ it "adds the search value" do
95
+ subject.cc("root@example.net")
96
+ subject.last.should eq "root@example.net"
97
+ end
98
+ end
99
+
86
100
  describe "#not" do
87
101
  context "without a search key" do
88
102
  it "adds 'NOT'" do
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cédric Félizard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.5.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.5.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: term-ansicolor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
@@ -185,7 +185,6 @@ files:
185
185
  - lib/imap_guard.rb
186
186
  - lib/imap_guard/guard.rb
187
187
  - lib/imap_guard/query.rb
188
- - lib/imap_guard/version.rb
189
188
  - spec/imap_guard/guard_spec.rb
190
189
  - spec/imap_guard/query_spec.rb
191
190
  - spec/spec_helper.rb
@@ -209,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
208
  version: '0'
210
209
  requirements: []
211
210
  rubyforge_project:
212
- rubygems_version: 2.2.0
211
+ rubygems_version: 2.4.6
213
212
  signing_key:
214
213
  specification_version: 4
215
214
  summary: A guard for your IMAP server
@@ -1,4 +0,0 @@
1
- module ImapGuard
2
- # [String] ImapGuard version
3
- VERSION = "0.0.4"
4
- end