omah 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/omah.rb +79 -6
- metadata +46 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e448d8dcd3df2527bacbd8332ec92270e1522e6
|
4
|
+
data.tar.gz: 0640adfff4ad6c98581224875062fea2a326c853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34fde5200edf29f2b18e739aa567904f9bea453df5c5b6ce482e4cf11c17c1615b1fee9e7c45e3a6b89efa23371d2809ddeba29aa2129bf5c2aa3f6b562399fe
|
7
|
+
data.tar.gz: d8de9312a5ebb997a8115b75671dd85a4ee952efcd018133297c6335fe4297eca72ef1bca0d0d306d77b4cbe6b6ecf9a747c15d12e7e4250ab06586bfa027832
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/omah.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# file: omah.rb
|
4
4
|
# title: Offline Mail Helper
|
5
5
|
|
6
|
+
require 'zip'
|
7
|
+
require 'nokorexi'
|
6
8
|
require 'dynarex-daily'
|
7
9
|
|
8
10
|
class Omah
|
@@ -18,7 +20,8 @@ class Omah
|
|
18
20
|
|
19
21
|
x = if File.exists? dailyfile then dailyfile
|
20
22
|
else
|
21
|
-
'messages[date]/message(id, tags, from, to, subject, date,
|
23
|
+
'messages[date]/message(id, tags, from, to, subject, date, ' \
|
24
|
+
+ 'txt_filepath, html_filepath, attachment1, attachment2, attachment3)'
|
22
25
|
end
|
23
26
|
|
24
27
|
@dd = DynarexDaily.new x, {dir_archive: :yearly}
|
@@ -31,7 +34,8 @@ class Omah
|
|
31
34
|
|
32
35
|
subject = msg[:subject]
|
33
36
|
title = subject.gsub(/\W+/,'-')[0,30].sub(/-$/,'')
|
34
|
-
|
37
|
+
|
38
|
+
a = @dd.all.select {|x| x.subject == subject}
|
35
39
|
|
36
40
|
ordinal = a.any? ? '.' + a.length.to_s : ''
|
37
41
|
txt_file = title + ordinal + '.txt'
|
@@ -44,12 +48,55 @@ class Omah
|
|
44
48
|
txt_filepath = File.join(path, txt_file)
|
45
49
|
html_filepath = File.join(path, html_file)
|
46
50
|
|
47
|
-
@dd.create msg.merge(txt_filepath: txt_filepath, \
|
48
|
-
html_filepath: html_filepath)
|
49
51
|
|
50
52
|
FileUtils.mkdir_p path
|
51
|
-
|
52
|
-
File.write
|
53
|
+
|
54
|
+
File.write txt_filepath, text_sanitiser(msg[:body_text].to_s)
|
55
|
+
File.write html_filepath, html_sanitiser(msg[:body_html].to_s)
|
56
|
+
|
57
|
+
parts_path = []
|
58
|
+
|
59
|
+
# save the attachments
|
60
|
+
if msg[:attachments].length > 0 then
|
61
|
+
|
62
|
+
attachment_path = File.join(path, title + ordinal)
|
63
|
+
FileUtils.mkdir_p attachment_path
|
64
|
+
|
65
|
+
if msg[:attachments].length < 4 then
|
66
|
+
|
67
|
+
msg[:attachments].each.with_index do |x, i|
|
68
|
+
|
69
|
+
name, buffer = x
|
70
|
+
parts_path[i] = File.join(attachment_path, name)
|
71
|
+
File.write parts_path[i], buffer
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
else
|
76
|
+
|
77
|
+
# make a zip file and add the attachments to it
|
78
|
+
|
79
|
+
zipfile = File.join(attachment_path, title[0,12].downcase + '.zip')
|
80
|
+
parts_path[0] = zipfile
|
81
|
+
|
82
|
+
Zip::File.open(zipfile, Zip::File::CREATE) do |x|
|
83
|
+
|
84
|
+
msg[:attachments].each do |filename, buffer|
|
85
|
+
x.get_output_stream(filename) {|os| os.write buffer }
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
msg.delete :attachments
|
95
|
+
|
96
|
+
@dd.create msg.merge(txt_filepath: txt_filepath, \
|
97
|
+
html_filepath: html_filepath, attachment1: parts_path[0], \
|
98
|
+
attachment2: parts_path[1], attachment3: parts_path[2])
|
99
|
+
|
53
100
|
|
54
101
|
end
|
55
102
|
|
@@ -65,5 +112,31 @@ class Omah
|
|
65
112
|
Date::MONTHNAMES[t.month].downcase[0..2], t.day.to_s]
|
66
113
|
|
67
114
|
end
|
115
|
+
|
116
|
+
|
117
|
+
def html_sanitiser(s)
|
118
|
+
|
119
|
+
begin
|
120
|
+
Rexle.new s
|
121
|
+
s2 = s
|
122
|
+
rescue
|
123
|
+
doc = Nokorexi.new(s).to_doc
|
124
|
+
s2 = doc.xml
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
def text_sanitiser(s)
|
130
|
+
|
131
|
+
begin
|
132
|
+
Rexle.new "<root>#{s}</root>"
|
133
|
+
s2 = s
|
134
|
+
rescue
|
135
|
+
doc = Nokorexi.new(s).to_doc
|
136
|
+
s2 = doc.xml
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
68
141
|
|
69
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
3LosTxP//qasvjSWNDjmKeTI4/c/fvSDtS5mLXCsxnJ/1Jp4zlO0rZWz0/BgcPFj
|
32
32
|
GUN8SqUlRq5unw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-05-
|
34
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex-daily
|
@@ -39,20 +39,60 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.2'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.2.2
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
52
|
+
version: '0.2'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.2.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubyzip
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.1'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.1.7
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.1'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.7
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: nokorexi
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.3'
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.3.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0.3'
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.3.1
|
56
96
|
description:
|
57
97
|
email: james@r0bertson.co.uk
|
58
98
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|