Class: WritersRoom::Workflow
- Inherits:
-
Object
- Object
- WritersRoom::Workflow
- Defined in:
- lib/writers_room/workflow.rb
Overview
Manages workflow progression for a medium type. Validates status transitions and tracks current stage.
Constant Summary collapse
- STATUS_ORDER =
Universal status progression order
%w[outline draft revision polish final].freeze
Instance Attribute Summary collapse
-
#medium ⇒ Object
readonly
Returns the value of attribute medium.
Instance Method Summary collapse
- #current_stage(project_path) ⇒ Object
-
#initialize(medium) ⇒ Workflow
constructor
A new instance of Workflow.
- #next_status(current) ⇒ Object
- #next_steps(project_path) ⇒ Object
- #statuses ⇒ Object
- #valid_status_transition?(from, to) ⇒ Boolean
- #workflows ⇒ Object
Constructor Details
#initialize(medium) ⇒ Workflow
Returns a new instance of Workflow.
12 13 14 |
# File 'lib/writers_room/workflow.rb', line 12 def initialize(medium) @medium = medium end |
Instance Attribute Details
#medium ⇒ Object (readonly)
Returns the value of attribute medium.
7 8 9 |
# File 'lib/writers_room/workflow.rb', line 7 def medium @medium end |
Instance Method Details
#current_stage(project_path) ⇒ Object
40 41 42 43 |
# File 'lib/writers_room/workflow.rb', line 40 def current_stage(project_path) state = ProjectState.new(project_path, medium: @medium) state.workflow_stage end |
#next_status(current) ⇒ Object
34 35 36 37 38 |
# File 'lib/writers_room/workflow.rb', line 34 def next_status(current) idx = statuses.index(current.to_s) return nil unless idx statuses[idx + 1] end |
#next_steps(project_path) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/writers_room/workflow.rb', line 45 def next_steps(project_path) stage = current_stage(project_path) steps = [] case stage when :empty steps << "Define your project concept" steps << "Create initial characters" when :concept_only steps << "Create characters to populate your story" steps << "Define your setting and locations" when :populating steps << "Continue adding story elements" steps << "Begin outlining your structure" steps << "Define character relationships and arcs" when :developing steps << "Review and revise existing elements" steps << "Begin drafting content" steps << "Update your story bible: wr bible regenerate" end steps end |
#statuses ⇒ Object
16 17 18 |
# File 'lib/writers_room/workflow.rb', line 16 def statuses @medium.statuses end |
#valid_status_transition?(from, to) ⇒ Boolean
24 25 26 27 28 29 30 31 32 |
# File 'lib/writers_room/workflow.rb', line 24 def valid_status_transition?(from, to) from_idx = statuses.index(from.to_s) to_idx = statuses.index(to.to_s) return false unless from_idx && to_idx # Can move forward, or back one step (revision) to_idx >= from_idx || (from_idx - to_idx) == 1 end |
#workflows ⇒ Object
20 21 22 |
# File 'lib/writers_room/workflow.rb', line 20 def workflows @medium.workflows end |