Class: Smith::Workflow::Graph::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/smith/workflow/graph/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Report

Returns a new instance of Report.



9
10
11
12
13
14
15
16
17
# File 'lib/smith/workflow/graph/report.rb', line 9

def initialize(**attributes)
  @status = attributes.fetch(:status)
  @workflow_class = attributes.fetch(:workflow_class)
  @initial_state = attributes.fetch(:initial_state)
  @states = attributes.fetch(:states)
  @transitions = attributes.fetch(:transitions)
  @diagnostics = attributes.fetch(:diagnostics)
  @metrics = attributes.fetch(:metrics)
end

Instance Attribute Details

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def diagnostics
  @diagnostics
end

#initial_stateObject (readonly)

Returns the value of attribute initial_state.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def initial_state
  @initial_state
end

#metricsObject (readonly)

Returns the value of attribute metrics.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def metrics
  @metrics
end

#statesObject (readonly)

Returns the value of attribute states.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def states
  @states
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def status
  @status
end

#transitionsObject (readonly)

Returns the value of attribute transitions.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def transitions
  @transitions
end

#workflow_classObject (readonly)

Returns the value of attribute workflow_class.



7
8
9
# File 'lib/smith/workflow/graph/report.rb', line 7

def workflow_class
  @workflow_class
end

Instance Method Details

#errorsObject



23
24
25
# File 'lib/smith/workflow/graph/report.rb', line 23

def errors
  diagnostics.select { |diagnostic| diagnostic.severity == :error }
end

#suggestionsObject



31
32
33
# File 'lib/smith/workflow/graph/report.rb', line 31

def suggestions
  diagnostics.map(&:suggestion).compact.uniq
end

#to_hObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/smith/workflow/graph/report.rb', line 35

def to_h
  {
    status: status,
    workflow_class: workflow_class,
    initial_state: initial_state,
    states: states,
    transitions: transitions.map(&:to_h),
    diagnostics: diagnostics.map(&:to_h),
    suggestions: suggestions,
    metrics: metrics
  }
end

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/smith/workflow/graph/report.rb', line 19

def valid?
  errors.empty?
end

#warningsObject



27
28
29
# File 'lib/smith/workflow/graph/report.rb', line 27

def warnings
  diagnostics.select { |diagnostic| diagnostic.severity == :warning }
end