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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 391ba1d9277adf8abe7005f5d7ae0f680cf3a7bd
4
- data.tar.gz: 6b7b62e644acbc5c2427e1a0373ccdb1a23bda45
3
+ metadata.gz: a3b859756e9258a7cc3b640aa684e425282db689
4
+ data.tar.gz: c514848d77f1e89b59c84a60ac758168567025a1
5
5
  SHA512:
6
- metadata.gz: 6f8321a63a6591e08b5b06f8cc7b45411277739956e7b0ee7b2028ab9e44c514443d9e9a26eb6658ee6f32131c8eebfe653622709263801896110fc4a90172e0
7
- data.tar.gz: b6674a1ebcee5a6ac616b40031c43382872f6782041bf94107e248f604213d31082f27bd69fd1f6b52de6177f9d208ed6662c0480a0603ae96636a8069af43a6
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
- messages.each {|message| @dd.create message }
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file