-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we can generate the Schema from the PRO JSON.
wow, we barely have to write a line of code now.
- Loading branch information
Showing
7 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Trailblazer | ||
module Workflow | ||
class Generate | ||
class Schema < Trailblazer::Activity::Railway | ||
step :render | ||
|
||
def render(ctx, parsed_structure:, namespace:, json_filename:, **options) | ||
lanes_cfg = parsed_structure[:lane_hints] | ||
|
||
lanes = parsed_structure[:intermediates].collect do |json_id, intermediate| | ||
tasks = intermediate.wiring.find_all { |task_ref, _| task_ref.data[:type] == :task } | ||
|
||
implementation = tasks.collect do |task_ref, _| | ||
%( "#{task_ref.data[:label]}" => Trailblazer::Activity::Railway.Subprocess(#{namespace}::#{task_ref.data[:label]}),) | ||
end.join("\n") | ||
|
||
icon, label, _ = json_id.split(".") # FIXME: abstract. | ||
|
||
# lane_task_2_wiring = intermediate.wiring.find_all { |task_ref, _| task_ref.data[:type] == :task } | ||
%( "#{json_id}" => { | ||
label: "#{label}", | ||
icon: "#{icon}", | ||
implementation: { | ||
#{implementation} | ||
} | ||
},) | ||
end.join("\n") | ||
|
||
snippet = %(module #{namespace} | ||
Schema = Trailblazer::Workflow.Collaboration( | ||
json_file: "#{json_filename}", | ||
lanes: { | ||
#{lanes} | ||
}, # :lanes | ||
state_guards: #{namespace}::StateGuards::Decider, | ||
) | ||
end | ||
) | ||
|
||
ctx[:snippet] = snippet | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters