omah 0.1.2 → 0.1.3
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/lib/omah.rb +30 -3
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: a3b859756e9258a7cc3b640aa684e425282db689
|
4
|
+
data.tar.gz: c514848d77f1e89b59c84a60ac758168567025a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 207d45abab62d5c93274a86c740103bce916bd7e0c1d0e7f76da740c9f1837514cd24e9048de3e98df2f852a57c8ec823f2170084370f72a65bce7ab3f3bbcc7
|
7
|
+
data.tar.gz: 63be707a11a00ce93845d0bad3f743affc879ae85eb63deed7b798fc0557b2a7c7d2cb47d73a99a2d6b56e55348e69fd3ad4ce0d48736baeba9663cf24cd67d6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/omah.rb
CHANGED
@@ -7,7 +7,10 @@ require 'dynarex-daily'
|
|
7
7
|
|
8
8
|
class Omah
|
9
9
|
|
10
|
-
def initialize()
|
10
|
+
def initialize(options={})
|
11
|
+
|
12
|
+
opt = {user: ''}.merge options
|
13
|
+
@user = opt[:user]
|
11
14
|
|
12
15
|
@dd = DynarexDaily.new
|
13
16
|
@dd.schema = 'messages/message(id, from, to, subject, date, body_text, body_html)'
|
@@ -15,8 +18,32 @@ class Omah
|
|
15
18
|
|
16
19
|
def store messages
|
17
20
|
|
18
|
-
|
21
|
+
dynarex = Dynarex.new 'messages/message(id, title, txt_file, html_file)'
|
22
|
+
|
23
|
+
messages.each do |msg|
|
24
|
+
|
25
|
+
#puts 'msg[:subject] : ' + msg.subject.inspect
|
26
|
+
subject = msg[:subject]
|
27
|
+
title = subject.gsub(/\W+/,'-')[0,30].sub(/-$/,'')
|
28
|
+
a = dynarex.find_all_by_title subject
|
29
|
+
ordinal = a.any? ? '.' + a.length.to_s : ''
|
30
|
+
txt_file = title + ordinal + '.txt'
|
31
|
+
html_file = title + ordinal + '.html'
|
32
|
+
|
33
|
+
id = msg[:id]
|
34
|
+
next if dynarex.find_by_id id
|
35
|
+
|
36
|
+
dynarex.create id: id, title: subject, txt_file: txt_file,
|
37
|
+
html_file: html_file
|
38
|
+
@dd.create msg
|
39
|
+
path = File.join @user + '/inbox'
|
40
|
+
FileUtils.mkdir_p path
|
41
|
+
File.write File.join(path, txt_file), msg[:body_text]
|
42
|
+
File.write File.join(path, html_file), msg[:body_html]
|
43
|
+
end
|
44
|
+
|
45
|
+
dynarex.save 'dynarex.xml'
|
19
46
|
@dd.save
|
20
47
|
end
|
21
48
|
|
22
|
-
end
|
49
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|