libis-workflow-mongoid 2.0.16 → 2.0.17

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: fc886c4a1a8abb4255e9b9028be2e1095e93c36a
4
- data.tar.gz: ba0d915839897f34e79ae25568046a37d9544be8
3
+ metadata.gz: 36e37f56b5fe461493670fed2f6f1fe9824cb789
4
+ data.tar.gz: f4a05cf3858093988bc123dbd60ee43793af53d9
5
5
  SHA512:
6
- metadata.gz: f3bf1c91c046cac7dd6bb1682cdcc4fdf5bbe7246a3189d4bf5a392cfe6fa9277d460a52efaa48ee38c0ed9eac864a6b98962a2ad6da79d8d0ee99b866404621
7
- data.tar.gz: f8fdb0b0592b8541f5bd562a6881eb800301202cfb89f54257663c2f8d57ea4e07d645eb8ef8acbaa4ac290100c782b815c8d4d5007f17b5fa75c7c9413e26f6
6
+ metadata.gz: c05c2a5633b832ff85164da27122a06b9e3cec6805873ba3e597207fa0e7b312b86139f96cdba89031c34cb8752c2513ecdf5804e83a490c76fa37411fec0767
7
+ data.tar.gz: 4e8abf24693b4623f0a459925fe8491cc2681b338e69a857e369e5921a5a85cb21064b9b1c0365b24ad7a3b63052fde9e277ea1393914d9c15ba5e8cc122d675
@@ -22,13 +22,27 @@ module Libis
22
22
  index({job_id: 1, job_type: 1, start_date: 1}, {sparse:1, name: 'by_job'})
23
23
 
24
24
  set_callback(:destroy, :before) do |document|
25
- wd = document.work_dir
26
- FileUtils.rmtree wd if wd && !wd.blank? && Dir.exist?(wd)
27
- # noinspection RubyResolve
28
- log_file = document.log_filename
25
+ document.rm_workdir
26
+ document.rm_log
27
+ end
28
+
29
+ def rm_log
30
+ log_file = self.log_filename
29
31
  FileUtils.rm(log_file) if log_file && !log_file.blank? && File.exist?(log_file)
30
32
  end
31
33
 
34
+ def rm_workdir
35
+ workdir = self.work_dir
36
+ FileUtils.rmtree workdir if workdir && !workdir.blank? && Dir.exist?(workdir)
37
+ end
38
+
39
+ def work_dir
40
+ # noinspection RubyResolve
41
+ dir = File.join(Libis::Workflow::Config.workdir, self.id)
42
+ FileUtils.mkpath dir unless Dir.exist?(dir)
43
+ dir
44
+ end
45
+
32
46
  def run(action = :run)
33
47
  self.tasks = []
34
48
  super action
@@ -42,7 +56,7 @@ module Libis
42
56
  logger = ::Logging::Repository.instance[self.name]
43
57
  return logger if logger
44
58
  unless ::Logging::Appenders[self.name]
45
- self.log_filename ||= File.join(::Libis::Workflow::Mongoid::Config[:log_dir], "#{self.name}.log")
59
+ self.log_filename ||= File.join(::Libis::Workflow::Mongoid::Config[:log_dir], "#{self.name}-#{self.id}.log")
46
60
  ::Logging::Appenders::File.new(
47
61
  self.name,
48
62
  filename: self.log_filename,
@@ -1,7 +1,7 @@
1
1
  module Libis
2
2
  module Workflow
3
3
  module Mongoid
4
- VERSION = '2.0.16' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
4
+ VERSION = '2.0.17' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-workflow-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.16
4
+ version: 2.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libis-workflow