libis-workflow-mongoid 2.0.4 → 2.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3640448e952c1db33b7a9fb19e25d4b3969a20c5
4
- data.tar.gz: 1129400163285ea1d4343bc0900bf67d5e0f8a44
3
+ metadata.gz: 017f82dc01ac32a1e83b84d9fc5df11ffaf0615c
4
+ data.tar.gz: d92861630b1adebd7230af71e6d51b0285107308
5
5
  SHA512:
6
- metadata.gz: 409cb938c747fcafd98c598a77a1c6e1b0d466138d2d32bb6d6d2f57c66695c0305e6d70f0bc55f557cfb4cec787799f9e47a30a786051beb666844223b3c208
7
- data.tar.gz: 12a4cec01e0db131e0a0a3e38e81aaa77905ea37b46db8d3abfe06c4d404d28164cd535d1529d97124849d4a96db07f1177165e543a017f6152999b2ac1b621e
6
+ metadata.gz: 82f885ebe58ec52be066d8aefd8859612569e5ba6556d905852c80062fe0c9b51265563763b845caa2a4bded2924c9ce708c5dca71bcfcd94b60b0ef3478e107
7
+ data.tar.gz: 97bf3b6bc08f98149cbe887e855c2fcc9d776aa1b951fc85910cdaabff6b2dc2294368735a540e761069f23d4bfd2663813f8a1a4f96afa53aab2c857acf9483
@@ -1,14 +1,11 @@
1
- # encoding: utf-8
2
1
  require 'mongoid'
3
2
  require 'mongoid/document'
4
3
  require 'yaml'
5
4
  require 'libis/tools/extend/hash'
6
5
  require 'map_with_indifferent_access'
7
6
 
8
- # require 'mongoid_indifferent_access'
9
7
  require_relative 'sequence'
10
8
 
11
-
12
9
  module Libis
13
10
  module Workflow
14
11
  module Mongoid
@@ -17,14 +14,17 @@ module Libis
17
14
 
18
15
  def self.included(klass)
19
16
  klass.extend(ClassMethods)
17
+
20
18
  klass.class_eval do
19
+
21
20
  include ::Mongoid::Document
22
21
  include ::Mongoid::Timestamps::Created::Short
23
- # include ::Mongoid::Extensions::Hash::IndifferentAccess
24
22
  include ::Libis::Workflow::Mongoid::Sequence
23
+
25
24
  field :_id, type: Integer, overwrite: true
26
25
  sequence :_id
27
26
  index c_at: 1
27
+
28
28
  end
29
29
  end
30
30
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'singleton'
3
2
  require 'mongoid'
4
3
 
@@ -6,27 +6,33 @@ module Libis
6
6
  module Workflow
7
7
  module Mongoid
8
8
  module Dynamic
9
+
10
+ module ClassMethods
11
+ def has_key?(key)
12
+ self.attributes.has_key?(key.to_s) || self.attributes.has_key?(key.to_sym)
13
+ end
14
+
15
+ def each(&block)
16
+ self.attributes.reject { |k,_| k == '_id' }.each(&block)
17
+ end
18
+ end
19
+
9
20
  def self.included(klass)
21
+ klass.extend(ClassMethods)
22
+
10
23
  klass.class_eval do
24
+
11
25
  include ::Mongoid::Document
12
26
  include ::Mongoid::Attributes::Dynamic
13
27
  include ::Libis::Workflow::Mongoid::Sequence
28
+
14
29
  field :_id, type: Integer, overwrite: true
15
30
  sequence :_id
16
31
  index _id: 1
17
32
 
18
- def has_key?(key)
19
- self.attributes.has_key?(key.to_s) || self.attributes.has_key?(key.to_sym)
20
- end
21
-
22
- def each(&block)
23
- self.attributes.reject { |k,_| k == '_id' }.each(&block)
24
- end
25
-
26
33
  end
27
34
  end
28
35
 
29
-
30
36
  end
31
37
  end
32
38
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'libis-workflow'
3
2
  require 'libis/workflow/mongoid/base'
4
3
 
@@ -1,20 +1,14 @@
1
- # encoding: utf-8
2
1
  require 'fileutils'
3
2
 
4
3
  require 'libis/workflow/base/run'
5
- require 'libis/workflow/mongoid/work_item_base'
6
4
 
7
5
  module Libis
8
6
  module Workflow
9
7
  module Mongoid
10
8
 
11
- class Run
9
+ class Run < Libis::Workflow::Mongoid::WorkItem
12
10
 
13
11
  include ::Libis::Workflow::Base::Run
14
- include ::Libis::Workflow::Mongoid::WorkItemBase
15
- # extend ActiveSupport::Concern
16
-
17
- store_in collection: 'workflow_runs'
18
12
 
19
13
  field :start_date, type: Time, default: -> { Time.now }
20
14
  field :log_to_file, type: Boolean, default: false
@@ -36,8 +30,6 @@ module Libis
36
30
 
37
31
  def run(action = :run)
38
32
  self.tasks = []
39
- self.items = []
40
- # noinspection RubySuperCallWithoutSuperclassInspection
41
33
  super action
42
34
  end
43
35
 
@@ -1,9 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  module Libis
4
2
  module Workflow
5
3
  module Mongoid
6
- VERSION = '2.0.4' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
4
+ VERSION = '2.0.5' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
7
5
  end
8
6
  end
9
7
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'libis-workflow'
3
2
 
4
3
  module Libis
@@ -8,7 +7,79 @@ module Libis
8
7
  class WorkItem
9
8
 
10
9
  include Libis::Workflow::Base::WorkItem
11
- include Libis::Workflow::Mongoid::WorkItemBase
10
+ include Libis::Workflow::Mongoid::Base
11
+
12
+ store_in collection: 'workflow_items'
13
+
14
+ field :_options, type: Hash, default: -> { Hash.new }
15
+ field :_properties, type: Hash, default: -> { Hash.new }
16
+ field :_summary, type: Hash, default: -> { Hash.new }
17
+
18
+ has_many :logs, as: :logger, class_name: Libis::Workflow::Mongoid::LogEntry.to_s,
19
+ dependent: :destroy, autosave: true, order: :_id.asc do
20
+ def log_history
21
+ where(:status.exists => false)
22
+ end
23
+
24
+ def status_log
25
+ where(:status.exists => true)
26
+ end
27
+ end
28
+
29
+ has_many :items, as: :parent, class_name: Libis::Workflow::Mongoid::WorkItem.to_s,
30
+ dependent: :destroy, autosave: true, order: :c_at.asc
31
+
32
+ belongs_to :parent, polymorphic: true
33
+
34
+ set_callback(:destroy, :before) do |document|
35
+ # noinspection RubyResolve
36
+ document.logs.each { |log| log.destroy! }
37
+ end
38
+
39
+ indifferent_hash :_options, :options
40
+ indifferent_hash :_properties, :properties
41
+ indifferent_hash :_summary, :summary
42
+
43
+ def to_hash
44
+ result = super
45
+ result[:options] = result.delete(:_options)
46
+ result[:properties] = result.delete(:_properties)
47
+ result[:summary] = result.delete(:_summary)
48
+ result
49
+ end
50
+
51
+ def log_history
52
+ # noinspection RubyResolve
53
+ self.logs.log_history.all || []
54
+ end
55
+
56
+ def status_log
57
+ # noinspection RubyResolve
58
+ self.logs.status_log.all || []
59
+ end
60
+
61
+ def add_item(item)
62
+ if item.parent
63
+ item.parent = nil
64
+ end
65
+ super
66
+ end
67
+
68
+ def get_items
69
+ self.items.to_a
70
+ end
71
+
72
+ protected
73
+
74
+ def add_log_entry(msg)
75
+ # noinspection RubyResolve
76
+ self.logs.build(msg)
77
+ end
78
+
79
+ def add_status_log(info)
80
+ # noinspection RubyResolve
81
+ self.logs.build(info)
82
+ end
12
83
 
13
84
  end
14
85
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'libis/workflow/worker'
4
2
  require 'sidekiq'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'libis-workflow'
4
2
 
5
3
  require_relative 'mongoid/version'
@@ -12,7 +10,6 @@ module Libis
12
10
  autoload :Config, 'libis/workflow/mongoid/config'
13
11
  autoload :LogEntry, 'libis/workflow/mongoid/log_entry'
14
12
  autoload :Job, 'libis/workflow/mongoid/job'
15
- autoload :WorkItemBase, 'libis/workflow/mongoid/work_item_base'
16
13
  autoload :WorkItem, 'libis/workflow/mongoid/work_item'
17
14
  autoload :Run, 'libis/workflow/mongoid/run'
18
15
  autoload :Worker, 'libis/workflow/mongoid/worker'
@@ -1,2 +1 @@
1
- # encoding: utf-8
2
1
  require 'libis/workflow/mongoid'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-workflow-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
@@ -120,7 +120,6 @@ files:
120
120
  - lib/libis/workflow/mongoid/sequence.rb
121
121
  - lib/libis/workflow/mongoid/version.rb
122
122
  - lib/libis/workflow/mongoid/work_item.rb
123
- - lib/libis/workflow/mongoid/work_item_base.rb
124
123
  - lib/libis/workflow/mongoid/worker.rb
125
124
  - lib/libis/workflow/mongoid/workflow.rb
126
125
  - lib/map_with_indifferent_access.rb
@@ -1,94 +0,0 @@
1
- require 'map_with_indifferent_access'
2
- require 'libis-workflow'
3
-
4
- module Libis
5
- module Workflow
6
- module Mongoid
7
-
8
- module WorkItemBase
9
-
10
- def self.included(klass)
11
- klass.class_eval do
12
- include Libis::Workflow::Base::WorkItem
13
- include Libis::Workflow::Mongoid::Base
14
-
15
- store_in collection: 'workflow_items'
16
-
17
- field :_options, type: Hash, default: -> { Hash.new }
18
- field :_properties, type: Hash, default: -> { Hash.new }
19
- field :_summary, type: Hash, default: -> { Hash.new }
20
-
21
- has_many :logs, as: :logger, class_name: Libis::Workflow::Mongoid::LogEntry.to_s,
22
- dependent: :destroy, autosave: true, order: :_id.asc do
23
- def log_history
24
- where(:status.exists => false)
25
- end
26
-
27
- def status_log
28
- where(:status.exists => true)
29
- end
30
- end
31
-
32
- has_many :items, as: :parent, class_name: Libis::Workflow::Mongoid::WorkItem.to_s,
33
- dependent: :destroy, autosave: true, order: :c_at.asc
34
-
35
- belongs_to :parent, polymorphic: true
36
-
37
- set_callback(:destroy, :before) do |document|
38
- # noinspection RubyResolve
39
- document.logs.each { |log| log.destroy! }
40
- end
41
-
42
- indifferent_hash :_options, :options
43
- indifferent_hash :_properties, :properties
44
- indifferent_hash :_summary, :summary
45
-
46
- end
47
- end
48
-
49
- def to_hash
50
- result = super
51
- result[:options] = result.delete(:_options)
52
- result[:properties] = result.delete(:_properties)
53
- result[:summary] = result.delete(:_summary)
54
- result
55
- end
56
-
57
- def log_history
58
- # noinspection RubyResolve
59
- self.logs.log_history.all || []
60
- end
61
-
62
- def status_log
63
- # noinspection RubyResolve
64
- self.logs.status_log.all || []
65
- end
66
-
67
- def add_item(item)
68
- if item.parent
69
- item.parent = nil
70
- end
71
- super
72
- end
73
-
74
- def get_items
75
- self.items.to_a
76
- end
77
-
78
- protected
79
-
80
- def add_log_entry(msg)
81
- # noinspection RubyResolve
82
- self.logs.build(msg)
83
- end
84
-
85
- def add_status_log(info)
86
- # noinspection RubyResolve
87
- self.logs.build(info)
88
- end
89
-
90
- end
91
-
92
- end
93
- end
94
- end