mailhandler 1.0.14 → 1.0.15
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a751f124dd303e1b4e75ff52ae565512bee6a7a
|
4
|
+
data.tar.gz: 14ccbb2fb176a70ab1981a8aea2416f46919bd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb0aca2c27d1a6a5a930ddcaf2791a7c903656ed0ce7577ec1fda0119dac6971fcffc5cb6b0d11d1adcbe62cc47b8615b3c0b61eb9818f742b5d52325fa00182
|
7
|
+
data.tar.gz: 902717c5ff6db0d68db91faacd4970983c750942ba29b4de483e1d16e2a143e743cff357bf5fcf6f04e2473014de138f63a7f1cf69286e76bb599f5bae4ace71
|
@@ -1,8 +1,57 @@
|
|
1
|
-
|
1
|
+
require 'fileutils'
|
2
2
|
|
3
|
-
# Implementations of base filtering, which will allow further filtering the list of files based on email content.
|
4
3
|
module Filter
|
5
4
|
|
5
|
+
# Base filtering class, which is used for reading list of all files based on passed pattern.
|
6
|
+
# Patterns to be used can be checked here: http://ruby-doc.org/core-1.9.3/Dir.html
|
7
|
+
class Base
|
8
|
+
|
9
|
+
def Base.sort(files)
|
10
|
+
|
11
|
+
swapped = true
|
12
|
+
j = 0
|
13
|
+
|
14
|
+
while swapped do
|
15
|
+
|
16
|
+
swapped = false
|
17
|
+
j+=1
|
18
|
+
|
19
|
+
(files.size - j).times do |i|
|
20
|
+
|
21
|
+
if File.new(files[i]).ctime < File.new(files[i + 1]).ctime
|
22
|
+
tmp = files[i]
|
23
|
+
files[i] = files[i + 1]
|
24
|
+
files[i + 1] = tmp
|
25
|
+
swapped = true
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
files
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def get(pattern)
|
38
|
+
|
39
|
+
files = []
|
40
|
+
Dir.glob(pattern).each { |file| files << File.absolute_path(file) }
|
41
|
+
files
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def read_email(content)
|
48
|
+
|
49
|
+
Mail.read_from_string(content)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
6
55
|
class ByFilename < Base
|
7
56
|
|
8
57
|
def get(pattern)
|
data/lib/mailhandler/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailhandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Balos
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/mailhandler/errors.rb
|
63
63
|
- lib/mailhandler/receiver.rb
|
64
64
|
- lib/mailhandler/receiving/base.rb
|
65
|
-
- lib/mailhandler/receiving/file_filter/base.rb
|
66
65
|
- lib/mailhandler/receiving/file_filter/filter.rb
|
67
66
|
- lib/mailhandler/receiving/folder.rb
|
68
67
|
- lib/mailhandler/receiving/imap.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
# Base filtering class, which is used for reading list of all files based on passed pattern.
|
4
|
-
# Patterns to be used can be checked here: http://ruby-doc.org/core-1.9.3/Dir.html
|
5
|
-
module Filter
|
6
|
-
|
7
|
-
class Base
|
8
|
-
|
9
|
-
def Base.sort(files)
|
10
|
-
|
11
|
-
swapped = true
|
12
|
-
j = 0
|
13
|
-
|
14
|
-
while swapped do
|
15
|
-
|
16
|
-
swapped = false
|
17
|
-
j+=1
|
18
|
-
|
19
|
-
(files.size - j).times do |i|
|
20
|
-
|
21
|
-
if File.new(files[i]).ctime < File.new(files[i + 1]).ctime
|
22
|
-
tmp = files[i]
|
23
|
-
files[i] = files[i + 1]
|
24
|
-
files[i + 1] = tmp
|
25
|
-
swapped = true
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
files
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def get(pattern)
|
38
|
-
|
39
|
-
files = []
|
40
|
-
Dir.glob(pattern).each { |file| files << File.absolute_path(file) }
|
41
|
-
files
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
protected
|
46
|
-
|
47
|
-
def read_email(content)
|
48
|
-
|
49
|
-
Mail.read_from_string(content)
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|