ooze-parser 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/LICENSE +21 -0
  4. data/lib/ooz/base/evolution.rb +9 -0
  5. data/lib/ooz/base/field/checklist/item.rb +12 -0
  6. data/lib/ooz/base/field/checklist.rb +22 -0
  7. data/lib/ooz/base/field/cross_reference.rb +10 -0
  8. data/lib/ooz/base/field/date.rb +11 -0
  9. data/lib/ooz/base/field/file/file.rb +11 -0
  10. data/lib/ooz/base/field/file.rb +21 -0
  11. data/lib/ooz/base/field/gauge/stop.rb +12 -0
  12. data/lib/ooz/base/field/gauge.rb +22 -0
  13. data/lib/ooz/base/field/image_gallery/image.rb +14 -0
  14. data/lib/ooz/base/field/image_gallery.rb +22 -0
  15. data/lib/ooz/base/field/number.rb +9 -0
  16. data/lib/ooz/base/field/people.rb +11 -0
  17. data/lib/ooz/base/field/plain_text.rb +9 -0
  18. data/lib/ooz/base/field/rich_text.rb +9 -0
  19. data/lib/ooz/base/field/select/option.rb +12 -0
  20. data/lib/ooz/base/field/select.rb +22 -0
  21. data/lib/ooz/base/field/tag_field.rb +9 -0
  22. data/lib/ooz/base/field/undefined.rb +8 -0
  23. data/lib/ooz/base/field.rb +24 -0
  24. data/lib/ooz/base/field_factory.rb +9 -0
  25. data/lib/ooz/base/force/binding.rb +10 -0
  26. data/lib/ooz/base/force.rb +20 -0
  27. data/lib/ooz/base/model.rb +37 -0
  28. data/lib/ooz/base/model_factory.rb +49 -0
  29. data/lib/ooz/base/ooze.rb +30 -0
  30. data/lib/ooz/base/section.rb +10 -0
  31. data/lib/ooz/base/stage/task/action/escalate.rb +12 -0
  32. data/lib/ooz/base/stage/task/action/reminder.rb +12 -0
  33. data/lib/ooz/base/stage/task/action/tag.rb +13 -0
  34. data/lib/ooz/base/stage/task/action.rb +27 -0
  35. data/lib/ooz/base/stage/task/action_factory.rb +12 -0
  36. data/lib/ooz/base/stage/task/completion.rb +10 -0
  37. data/lib/ooz/base/stage/task/priority.rb +11 -0
  38. data/lib/ooz/base/stage/task/review.rb +11 -0
  39. data/lib/ooz/base/stage/task/scheduled_callback.rb +14 -0
  40. data/lib/ooz/base/stage/task/strategy/direct.rb +13 -0
  41. data/lib/ooz/base/stage/task/strategy/editable.rb +13 -0
  42. data/lib/ooz/base/stage/task/strategy/prior.rb +13 -0
  43. data/lib/ooz/base/stage/task/strategy/prior_supervisor.rb +13 -0
  44. data/lib/ooz/base/stage/task/strategy/scheduler.rb +14 -0
  45. data/lib/ooz/base/stage/task/strategy/supervisor.rb +12 -0
  46. data/lib/ooz/base/stage/task/strategy.rb +21 -0
  47. data/lib/ooz/base/stage/task/strategy_factory.rb +12 -0
  48. data/lib/ooz/base/stage/task.rb +33 -0
  49. data/lib/ooz/base/stage.rb +28 -0
  50. data/lib/ooz/base.rb +14 -0
  51. data/lib/ooz/common/base_class.rb +63 -0
  52. data/lib/ooz/common/base_factory.rb +9 -0
  53. data/lib/ooz/common/base_model.rb +59 -0
  54. data/lib/ooz/common/hash_diff.rb +36 -0
  55. data/lib/ooz/common.rb +9 -0
  56. data/lib/ooz/model/evolution.rb +12 -0
  57. data/lib/ooz/model/field/checklist/item.rb +13 -0
  58. data/lib/ooz/model/field/checklist.rb +21 -0
  59. data/lib/ooz/model/field/cross_reference.rb +9 -0
  60. data/lib/ooz/model/field/date.rb +9 -0
  61. data/lib/ooz/model/field/file/file.rb +13 -0
  62. data/lib/ooz/model/field/file.rb +21 -0
  63. data/lib/ooz/model/field/gauge/stop.rb +13 -0
  64. data/lib/ooz/model/field/gauge.rb +21 -0
  65. data/lib/ooz/model/field/image_gallery/image.rb +13 -0
  66. data/lib/ooz/model/field/image_gallery.rb +21 -0
  67. data/lib/ooz/model/field/number.rb +9 -0
  68. data/lib/ooz/model/field/people.rb +9 -0
  69. data/lib/ooz/model/field/plain_text.rb +9 -0
  70. data/lib/ooz/model/field/rich_text.rb +9 -0
  71. data/lib/ooz/model/field/select/option.rb +13 -0
  72. data/lib/ooz/model/field/select.rb +21 -0
  73. data/lib/ooz/model/field/tag_field.rb +9 -0
  74. data/lib/ooz/model/field/undefined.rb +9 -0
  75. data/lib/ooz/model/field.rb +42 -0
  76. data/lib/ooz/model/field_factory.rb +7 -0
  77. data/lib/ooz/model/force/binding.rb +16 -0
  78. data/lib/ooz/model/force.rb +16 -0
  79. data/lib/ooz/model/ooze.rb +72 -0
  80. data/lib/ooz/model/section.rb +31 -0
  81. data/lib/ooz/model/stage.rb +18 -0
  82. data/lib/ooz/model.rb +12 -0
  83. data/lib/ooz/version.rb +3 -0
  84. data/lib/ooze-parser.rb +8 -0
  85. data/ooze-parser.gemspec +26 -0
  86. metadata +148 -0
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy
6
+ class Editable < Strategy
7
+ passthrough :number, to: :doc
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy
6
+ class Prior < Strategy
7
+ passthrough :prior_task_type, :stage_id, to: :doc
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy
6
+ class PriorSupervisor < Strategy
7
+ passthrough :prior_task_type, :stage_id, to: :doc
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy
6
+ class Scheduler < Strategy
7
+ passthrough :policy_group_id, to: :doc
8
+ passthrough :number, :prefiltered, :include_base, to: :doc
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy
6
+ class Supervisor < Strategy
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class Strategy < Base::Model
6
+ overridable_const :priority_class, Base::Stage::Task::Priority
7
+ passthrough :_id, :_type, :order, :patch_ver, to: :doc
8
+ passthrough_cls :priorities, to: :doc, klass: priority_class
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+
16
+ require_relative "strategy/scheduler"
17
+ require_relative "strategy/prior"
18
+ require_relative "strategy/prior_supervisor"
19
+ require_relative "strategy/supervisor"
20
+ require_relative "strategy/editable"
21
+ require_relative "strategy/direct"
@@ -0,0 +1,12 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task
5
+ class StrategyFactory < ModelFactory
6
+ def_parent_class Base::Stage::Task::Strategy
7
+ def_white_classes "Scheduler", "Prior", "PriorSupervisor", "Supervisor", "Editable", "Direct"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage
4
+ class Task < Base::Model
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "task/priority"
11
+ require_relative "task/strategy"
12
+ require_relative "task/strategy_factory"
13
+ require_relative "task/action"
14
+ require_relative "task/action_factory"
15
+ require_relative "task/scheduled_callback"
16
+ require_relative "task/completion"
17
+ require_relative "task/review"
18
+
19
+ module Ooz
20
+ module Base
21
+ class Stage
22
+ class Task
23
+ overridable_const :strategy_class, Base::Stage::Task::StrategyFactory
24
+ overridable_const :scheduled_callback_class, Base::Stage::Task::ScheduledCallback
25
+ passthrough :_id, :_type, :patch_ver, to: :doc
26
+ passthrough :due_enabled, :due_ctr, :due_unit, to: :doc
27
+ passthrough_arr :strategies, to: :doc, klass: :strategy_class
28
+ passthrough_cls :default_strategy, to: :doc, klass: :strategy_class
29
+ passthrough_arr :scheduled_callbacks, to: :doc, klass: :scheduled_callback_class
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module Ooz
2
+ module Base
3
+ class Stage < Base::Model
4
+ end
5
+ end
6
+ end
7
+
8
+ require_relative "stage/task"
9
+
10
+ module Ooz
11
+ module Base
12
+ class Stage
13
+ overridable_const :task_completion_class, Base::Stage::Task::Completion
14
+ overridable_const :task_review_class, Base::Stage::Task::Review
15
+
16
+ passthrough :_id, :name, :ordering, :state, :patch_ver, to: :doc
17
+ passthrough :created_at, :updated_at, to: :doc
18
+ passthrough :creator_enabled, :creator_editable, to: :doc
19
+ passthrough :tags, :compiled_tags, to: :doc
20
+ passthrough :flow_node_ids, to: :doc
21
+ passthrough :disable_direct_permissions, :lock_after_completion, to: :doc
22
+ passthrough :task_priority, to: :doc
23
+
24
+ passthrough_cls :completion_task_config, to: :doc, klass: :task_completion_class
25
+ passthrough_cls :review_task_config, to: :doc, klass: :task_review_class
26
+ end
27
+ end
28
+ end
data/lib/ooz/base.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Ooz
2
+ module Base
3
+ end
4
+ end
5
+
6
+ require_relative 'base/model'
7
+ require_relative 'base/model_factory'
8
+ require_relative 'base/field'
9
+ require_relative 'base/field_factory'
10
+ require_relative 'base/section'
11
+ require_relative 'base/stage'
12
+ require_relative 'base/evolution'
13
+ require_relative 'base/force'
14
+ require_relative 'base/ooze'
@@ -0,0 +1,63 @@
1
+ module Ooz
2
+ module Common
3
+ class BaseClass
4
+ class << self
5
+
6
+ def overridable_const (method, value)
7
+ method = method.to_s
8
+ define_singleton_method method do
9
+ value
10
+ end
11
+ define_method method do
12
+ self.class.send(method)
13
+ end
14
+ end
15
+
16
+ def passthrough(*methods, to:)
17
+ methods.each do |method|
18
+ method = method.to_s
19
+ define_method method do
20
+ send(to)[method]
21
+ end
22
+ define_method "#{method}=" do |value|
23
+ send(to)[method] = value
24
+ end
25
+ end
26
+ end
27
+
28
+ def passthrough_cls(method, to:, klass:)
29
+ method = method.to_s
30
+ var = "@#{method}"
31
+
32
+ define_method method do
33
+ return instance_variable_get(var) if instance_variable_defined?(var)
34
+ send(to)[method] = send(to)[method] || {}
35
+
36
+ klass = klass.is_a?(Class)? klass : self.send(klass)
37
+ obj = klass.new(send(to)[method], root: self)
38
+ instance_variable_set(var, obj)
39
+ obj
40
+ end
41
+ end
42
+
43
+ def passthrough_arr(method, to:, klass:)
44
+ method = method.to_s
45
+ var = "@#{method}"
46
+
47
+ define_method method do
48
+ return instance_variable_get(var) if instance_variable_defined?(var)
49
+ send(to)[method] = send(to)[method] || []
50
+
51
+ klass = klass.is_a?(Class)? klass : self.send(klass)
52
+ arr = send(to)[method].map do |e|
53
+ klass.new(e, root: self)
54
+ end
55
+ instance_variable_set(var, arr)
56
+ arr
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Common
3
+ class BaseFactory < BaseClass
4
+ class << self
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,59 @@
1
+ module Ooz
2
+ module Common
3
+ class BaseModel < BaseClass
4
+ attr_reader :doc
5
+ def initialize(doc = {})
6
+ @doc = doc
7
+ @original_doc = JSON.parse(doc.to_json)
8
+ @last_change = {}
9
+ end
10
+
11
+ def self.build(doc = {})
12
+ new(doc).tap do |instance|
13
+ instance.instance_variable_set("@original_doc", {})
14
+ end
15
+ end
16
+
17
+ def print
18
+ puts JSON.pretty_generate(as_json)
19
+ self
20
+ end
21
+
22
+ def as_json
23
+ doc
24
+ end
25
+
26
+ def to_json(*args)
27
+ doc.to_json(*args)
28
+ end
29
+
30
+ def consolidate!
31
+ @original_doc = JSON.parse(@doc.to_json)
32
+ end
33
+
34
+ def undo!
35
+ @doc = JSON.parse(@original_doc.to_json)
36
+ end
37
+
38
+ def as_update
39
+ new_doc = as_json
40
+ Common::HashDiff.diff(new_doc, @original_doc)
41
+ end
42
+
43
+ def changed?
44
+ !as_update.empty?
45
+ end
46
+
47
+ def new_change?
48
+ !Common::HashDiff.diff(as_update, @last_change).empty?
49
+ end
50
+
51
+ def update_last_change!
52
+ last_chg = @last_change
53
+ @last_change = as_update
54
+ last_chg
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,36 @@
1
+ module Ooz
2
+ module Common
3
+ module HashDiff
4
+ ID_KEYS = %w[_id]
5
+
6
+ def self.diff(a, b)
7
+ return a if a.class != b.class
8
+ case a
9
+ when Hash
10
+ {}.tap do |diffed|
11
+ a.each do |key, a_value|
12
+ b_value = b[key]
13
+ next if a_value == b_value && !ID_KEYS.include?(key)
14
+ diffed[key] = diff(a_value, b_value)
15
+ diffed.delete(key) if diffed[key] == {}
16
+ end
17
+ # All keys are IDs, so it's actually blank
18
+ if (diffed.keys - ID_KEYS).empty?
19
+ return {}
20
+ end
21
+ end
22
+ when Array
23
+ return a unless a.length == b.length
24
+ a.map.with_index do |a_value, idx|
25
+ b_value = b[idx]
26
+ diff(a_value, b_value)
27
+ end.reject do |el|
28
+ el == {}
29
+ end
30
+ else
31
+ a
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/ooz/common.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Common
3
+ end
4
+ end
5
+
6
+ require_relative 'common/base_class'
7
+ require_relative 'common/base_factory'
8
+ require_relative 'common/hash_diff'
9
+ require_relative 'common/base_model'
@@ -0,0 +1,12 @@
1
+ module Ooz
2
+ module Model
3
+ class Evolution < Base::Evolution
4
+ overridable_const :stage_class, Model::Stage
5
+
6
+ def initialize(*args)
7
+ super(*args)
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Checklist
5
+ class Item < Base::Field::Checklist::Item
6
+ def field
7
+ root
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Checklist < Base::Field::Checklist
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "checklist/item"
11
+
12
+ module Ooz
13
+ module Model
14
+ class Field
15
+ class Checklist
16
+ overridable_const :checklist_item_class, Model::Field::Checklist::Item
17
+ include Methods
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class CrossReference < Base::Field::CrossReference
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Date < Base::Field::Date
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class File
5
+ class File < Base::Field::File::File
6
+ def field
7
+ root
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class File < Base::Field::File
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "file/file"
11
+
12
+ module Ooz
13
+ module Model
14
+ class Field
15
+ class File
16
+ overridable_const :file_class, Model::Field::File::File
17
+ include Methods
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Gauge
5
+ class Stop < Base::Field::Gauge::Stop
6
+ def field
7
+ root
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Gauge < Base::Field::Gauge
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "gauge/stop"
11
+
12
+ module Ooz
13
+ module Model
14
+ class Field
15
+ class Gauge
16
+ overridable_const :gauge_stop_class, Model::Field::Gauge::Stop
17
+ include Methods
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class ImageGallery
5
+ class Image < Base::Field::ImageGallery::Image
6
+ def field
7
+ root
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class ImageGallery < Base::Field::ImageGallery
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "image_gallery/image"
11
+
12
+ module Ooz
13
+ module Model
14
+ class Field
15
+ class ImageGallery
16
+ overridable_const :gauge_stop_class, Model::Field::Gauge::Stop
17
+ include Methods
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Number < Base::Field::Number
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class People < Base::Field::People
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class PlainText < Base::Field::PlainText
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class RichText < Base::Field::RichText
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Ooz
2
+ module Base
3
+ class Field
4
+ class Select
5
+ class Option < Base::Model
6
+ def field
7
+ root
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Select < Base::Field::Select
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative "select/option"
11
+
12
+ module Ooz
13
+ module Model
14
+ class Field
15
+ class Select
16
+ overridable_const :select_option, Model::Field::Select::Option
17
+ include Methods
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class TagField < Base::Field::TagField
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Ooz
2
+ module Model
3
+ class Field
4
+ class Undefined < Base::Field::Undefined
5
+ include Methods
6
+ end
7
+ end
8
+ end
9
+ end