omah 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/omah.rb +40 -30
  5. metadata +7 -7
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c2c4786fdb01db74afb514151947476dcfd6fae2
4
- data.tar.gz: 106740778102ea07fb8d448ed4bf9ff5a108c5c9
2
+ SHA256:
3
+ metadata.gz: 8d06eb4457018bb8014de125b696636a9482903275d61989f0c638e67324eb7b
4
+ data.tar.gz: ee80906ff711cf99a89785f78ef9d97de4074d187ddebbe008cd76f04a32be80
5
5
  SHA512:
6
- metadata.gz: acf79806c66d85102df253506f11d84752a3dee79d0dd69ca565dce9a06dddeab8aa633aceab33429a3a652fbe57b6e08686ef5fb2727f76c80c9563fc139f92
7
- data.tar.gz: ea31f6a7d57e7f8f4b68f0cbffbcdeaa50840eb4032598b4eca449967634355e808de6d63a79524b3a36fcf5e4dc4606b122667901e178aae5f89054e72f93dd
6
+ metadata.gz: 1c112dbc1d4b9086fc18f74392db282a23b4e5762454bb01d1f1ea9100e3e6b2fcb7dcedacc279d30819f10ab1e48c72130e56057028bbdd2db65c40dfae549f
7
+ data.tar.gz: f54bae7520efefd38c0a1141ce29bef6517515dc16eca4c784367064758a9e5fa8a6a11de9dcf4277e20cb0b62f8a79689b3b01822584e3e0c5e423e086af6d4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -21,30 +21,37 @@ end
21
21
  class Omah
22
22
 
23
23
  include Library
24
+ include RXFHelperModule
24
25
 
25
26
  def initialize(user: 'user', filepath: '.', \
26
27
  options: {xslt: 'listing.xsl', url_base: 'http://localhost/' },
27
- plugins: [], webpath: '/email')
28
+ plugins: [], webpath: '/email', debug: false)
28
29
 
30
+
31
+ puts 'inside Omah::initialize' if @debug
32
+
29
33
  @user = user
30
34
  @xslt = options[:xslt]
31
35
  @css = options[:css]
32
36
  @variables ||= {}
33
37
 
34
- @filepath_user = File.expand_path(File.join(filepath, @user))
38
+ @filepath_user = File.join(filepath, @user)
35
39
  @webpath_user = webpath +'/' + @user
36
40
  @url_base = options[:url_base] || '.'
41
+ @debug = debug
37
42
 
38
- Dir.chdir filepath
43
+ puts 'Omah::initialize filepath: ' + filepath.inspect if @debug
44
+
45
+ FileX.chdir filepath
39
46
 
40
- FileUtils.mkdir_p @filepath_user # attempt to
41
- # mkdir regardless if it already exists
47
+ puts 'Omah::initialize making directory ' + @filepath_user if @debug
48
+ FileX.mkdir_p @filepath_user
42
49
 
43
- Dir.chdir @filepath_user
50
+ FileX.chdir @filepath_user
44
51
 
45
52
  dailyfile = 'dynarexdaily.xml'
46
53
 
47
- x = if File.exists? dailyfile then dailyfile
54
+ x = if FileX.exists? dailyfile then dailyfile
48
55
 
49
56
  else
50
57
 
@@ -54,8 +61,9 @@ class Omah
54
61
 
55
62
  end
56
63
 
64
+ puts 'Omah::initialize before DynarexDaily' if @debug
57
65
  @dd = DynarexDaily.new x, dir_archive: :yearly
58
-
66
+ puts 'Omah::initialize after DynarexDaily' if @debug
59
67
  # is it a new day?
60
68
 
61
69
  if @dd.records.empty? then
@@ -67,7 +75,7 @@ class Omah
67
75
 
68
76
  file_yesterday = date_yesterday + '/index.xml'
69
77
 
70
- if File.exists? file_yesterday then
78
+ if FileX.exists? file_yesterday then
71
79
 
72
80
  dx_yesterday = Dynarex.new file_yesterday
73
81
  dx_yesterday.next_date = File.join(@webpath_user,
@@ -80,16 +88,21 @@ class Omah
80
88
 
81
89
  # intialize plugins
82
90
 
91
+ puts 'Omah::initialize before plugins' if @debug
92
+
83
93
  @plugins = plugins.inject([]) do |r, plugin|
84
94
 
85
95
  name, settings = plugin
96
+
97
+ puts 'Omah::initialize plugin: ' + name.inspect if @debug
98
+
86
99
  return r if settings[:active] == false and !settings[:active]
87
100
 
88
101
  klass_name = 'OmahPlugin' + name.to_s.split(/[-_]/)\
89
102
  .map{|x| x.capitalize}.join
90
103
 
91
104
  r << Kernel.const_get(klass_name).new(settings: settings,
92
- variables: @variables)
105
+ variables: @variables, debug: @debug)
93
106
 
94
107
  end
95
108
 
@@ -99,6 +112,7 @@ class Omah
99
112
 
100
113
  messages.each.with_index do |msg,i|
101
114
 
115
+ puts "i: %d msg: %s" % [i, msg]
102
116
  subject = msg[:subject] || ''
103
117
 
104
118
  title = subject.gsub(/\W+/,'-')[0,30].sub(/^-/,'').sub(/-$/,'')
@@ -117,10 +131,12 @@ class Omah
117
131
 
118
132
  x_filepath = File.join(path, x_file)
119
133
 
120
- FileUtils.mkdir_p path
134
+ puts 'FileX.pwd ' + FileX.pwd if @debug
135
+ puts 'Omah::store before mkdir_p path: ' + path.inspect if @debug
136
+ FileX.mkdir_p path
121
137
 
122
138
  if msg[:raw_source] then
123
- File.write File.join(@filepath_user, x_filepath + '.eml'), \
139
+ FileX.write File.join(@filepath_user, x_filepath + '.eml'), \
124
140
  msg[:raw_source]
125
141
  end
126
142
 
@@ -128,11 +144,11 @@ class Omah
128
144
  Kvx.new(header).save File.join(@filepath_user, x_filepath + '.kvx')
129
145
 
130
146
  txt_filepath = x_filepath + '.txt'
131
- File.write File.join(@filepath_user, txt_filepath), \
147
+ FileX.write File.join(@filepath_user, txt_filepath), \
132
148
  text_sanitiser(msg[:body_text].to_s)
133
149
 
134
150
  html_filepath = x_filepath + '.html'
135
- File.write File.join(@filepath_user, html_filepath), \
151
+ FileX.write File.join(@filepath_user, html_filepath), \
136
152
  html_sanitiser(msg[:body_html].to_s)
137
153
 
138
154
  parts_path = []
@@ -141,7 +157,7 @@ class Omah
141
157
  if msg[:attachments].length > 0 then
142
158
 
143
159
  attachment_path = File.join(path, title + ordinal)
144
- FileUtils.mkdir_p attachment_path
160
+ FileX.mkdir_p attachment_path
145
161
 
146
162
  if msg[:attachments].length < 4 then
147
163
 
@@ -150,7 +166,7 @@ class Omah
150
166
  name, buffer = x
151
167
  parts_path[i] = File.join(attachment_path, name.gsub('/',''))
152
168
  begin
153
- File.write File.join(@filepath_user, parts_path[i]), buffer
169
+ FileX.write File.join(@filepath_user, parts_path[i]), buffer
154
170
  rescue
155
171
  puts ($!)
156
172
  end
@@ -164,14 +180,8 @@ class Omah
164
180
  zipfile = File.join(@filepath_user, attachment_path,
165
181
  title[0,12].downcase + '.zip')
166
182
  parts_path[0] = zipfile
167
-
168
- Zip::File.open(zipfile, Zip::File::CREATE) do |x|
169
-
170
- msg[:attachments].each do |filename, buffer|
171
- x.get_output_stream(filename) {|os| os.write buffer }
172
- end
173
-
174
- end
183
+
184
+ FileX.zip zipfile, msg[:attachments]
175
185
 
176
186
  end
177
187
 
@@ -211,7 +221,7 @@ html_page= %Q(
211
221
  </html>
212
222
  )
213
223
 
214
- File.write File.join(attachment_path, 'index.html'), html_page
224
+ FileX.write File.join(attachment_path, 'index.html'), html_page
215
225
  h[:html_filepath] = File.join(attachment_path, 'index.html')
216
226
  end
217
227
 
@@ -225,10 +235,10 @@ html_page= %Q(
225
235
 
226
236
  if @xslt then
227
237
 
228
- unless File.exists? @xslt then
229
- File.write File.expand_path(@xslt), fetch_file(@xslt)
230
- File.write File.expand_path(@css), fetch_file(@css) if @css and \
231
- not File.exists? @css
238
+ unless FileX.exists? @xslt then
239
+ FileX.write File.expand_path(@xslt), fetch_file(@xslt)
240
+ FileX.write File.expand_path(@css), fetch_file(@css) if @css and \
241
+ not FileX.exists? @css
232
242
  end
233
243
 
234
244
  @dd.xslt = @xslt
@@ -249,7 +259,7 @@ html_page= %Q(
249
259
  x.on_newmail(messages, doc) if x.respond_to? :on_newmail
250
260
  end
251
261
 
252
- File.write File.join(@filepath_user, 'dynarexdaily.xml'), \
262
+ FileX.write File.join(@filepath_user, 'dynarexdaily.xml'), \
253
263
  doc.xml(pretty: true)
254
264
 
255
265
  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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  QYtaxpGWTpAPjszaFSAGnt9wrzAMCFPhpqXanwuDYpQ0rmo/GgWyJNEJuUgvMZBi
31
31
  WfE=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-07-24 00:00:00.000000000 Z
33
+ date: 2018-08-17 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: dynarex-daily
@@ -38,20 +38,20 @@ dependencies:
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.3'
41
+ version: '0.4'
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 0.3.1
44
+ version: 0.4.0
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - "~>"
50
50
  - !ruby/object:Gem::Version
51
- version: '0.3'
51
+ version: '0.4'
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.1
54
+ version: 0.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubyzip
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.6.13
144
+ rubygems_version: 2.7.6
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: 'Offline Mail Helper: Stores email messages in a file directory archive'
metadata.gz.sig CHANGED
Binary file