tasker-engine 1.0.1 → 1.0.2
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 +4 -4
- data/README.md +2 -5
- data/app/models/tasker/task.rb +0 -10
- data/config/routes.rb +3 -3
- data/docs/AUTH.md +1 -40
- data/docs/DEVELOPER_GUIDE.md +2 -3
- data/docs/OVERVIEW.md +0 -4
- data/docs/Tasker/Analysis/RuntimeGraphAnalyzer.html +1 -1
- data/docs/Tasker/Analysis/TemplateGraphAnalyzer.html +1 -1
- data/docs/Tasker/Analysis.html +1 -1
- data/docs/Tasker/AnalyticsController.html +1 -1
- data/docs/Tasker/AnalyticsService/BottleneckAnalytics.html +1 -1
- data/docs/Tasker/AnalyticsService/PerformanceAnalytics.html +1 -1
- data/docs/Tasker/AnalyticsService.html +1 -1
- data/docs/Tasker/AnnotationType.html +1 -1
- data/docs/Tasker/AnnotationTypeSerializer.html +1 -1
- data/docs/Tasker/ApplicationController.html +2 -2
- data/docs/Tasker/ApplicationJob.html +1 -1
- data/docs/Tasker/ApplicationRecord.html +1 -1
- data/docs/Tasker/Authentication/AuthenticationError.html +1 -1
- data/docs/Tasker/Authentication/ConfigurationError.html +1 -1
- data/docs/Tasker/Authentication/Coordinator.html +1 -1
- data/docs/Tasker/Authentication/Interface.html +1 -1
- data/docs/Tasker/Authentication/InterfaceError.html +1 -1
- data/docs/Tasker/Authentication/NoneAuthenticator.html +1 -1
- data/docs/Tasker/Authentication.html +1 -1
- data/docs/Tasker/Authorization/AuthorizationError.html +1 -1
- data/docs/Tasker/Authorization/BaseCoordinator.html +1 -1
- data/docs/Tasker/Authorization/ConfigurationError.html +1 -1
- data/docs/Tasker/Authorization/ResourceConstants/ACTIONS.html +10 -10
- data/docs/Tasker/Authorization/ResourceConstants/RESOURCES.html +8 -13
- data/docs/Tasker/Authorization/ResourceConstants.html +1 -1
- data/docs/Tasker/Authorization/ResourceRegistry.html +33 -40
- data/docs/Tasker/Authorization/UnauthorizedError.html +1 -1
- data/docs/Tasker/Authorization.html +1 -1
- data/docs/Tasker/CacheCapabilities.html +1 -1
- data/docs/Tasker/CacheStrategy.html +1 -1
- data/docs/Tasker/Concerns/Authenticatable.html +1 -1
- data/docs/Tasker/Concerns/Authorizable/AdminStatusChecker.html +1 -1
- data/docs/Tasker/Concerns/Authorizable.html +1 -1
- data/docs/Tasker/Concerns/ControllerAuthorizable.html +1 -1
- data/docs/Tasker/Concerns/EventPublisher.html +1 -1
- data/docs/Tasker/Concerns/IdempotentStateTransitions.html +1 -1
- data/docs/Tasker/Concerns/StateMachineBase/ClassMethods.html +1 -1
- data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase/ClassMethods.html +1 -1
- data/docs/Tasker/Concerns/StateMachineBase/StateMachineBase.html +1 -1
- data/docs/Tasker/Concerns/StateMachineBase.html +1 -1
- data/docs/Tasker/Concerns/StructuredLogging.html +1 -1
- data/docs/Tasker/Concerns.html +1 -1
- data/docs/Tasker/Configuration/ConfigurationProxy.html +1 -1
- data/docs/Tasker/Configuration/TelemetryConfigurationProxy.html +1 -1
- data/docs/Tasker/Configuration.html +1 -1
- data/docs/Tasker/ConfigurationError.html +1 -1
- data/docs/Tasker/ConfiguredTask.html +1 -1
- data/docs/Tasker/Constants/EventDefinitions.html +1 -1
- data/docs/Tasker/Constants/ObservabilityEvents/Step.html +1 -1
- data/docs/Tasker/Constants/ObservabilityEvents/Task.html +1 -1
- data/docs/Tasker/Constants/ObservabilityEvents.html +1 -1
- data/docs/Tasker/Constants/RegistryEvents.html +1 -1
- data/docs/Tasker/Constants/StepEvents.html +1 -1
- data/docs/Tasker/Constants/TaskEvents.html +1 -1
- data/docs/Tasker/Constants/TaskExecution/ExecutionStatus.html +1 -1
- data/docs/Tasker/Constants/TaskExecution/HealthStatus.html +1 -1
- data/docs/Tasker/Constants/TaskExecution/RecommendedAction.html +1 -1
- data/docs/Tasker/Constants/TaskExecution.html +1 -1
- data/docs/Tasker/Constants/TaskFinalization/ErrorMessages.html +1 -1
- data/docs/Tasker/Constants/TaskFinalization/PendingReasons.html +1 -1
- data/docs/Tasker/Constants/TaskFinalization/ReenqueueReasons.html +1 -1
- data/docs/Tasker/Constants/TaskFinalization.html +1 -1
- data/docs/Tasker/Constants/TaskStatuses.html +1 -1
- data/docs/Tasker/Constants/TestEvents.html +1 -1
- data/docs/Tasker/Constants/WorkflowEvents.html +1 -1
- data/docs/Tasker/Constants/WorkflowStepStatuses.html +1 -1
- data/docs/Tasker/Constants.html +1 -1
- data/docs/Tasker/DependentSystem.html +1 -1
- data/docs/Tasker/DependentSystemObjectMap.html +1 -1
- data/docs/Tasker/DetectorRegistry.html +1 -1
- data/docs/Tasker/Engine.html +1 -1
- data/docs/Tasker/Error.html +1 -1
- data/docs/Tasker/Events/Catalog/CatalogPrinter.html +1 -1
- data/docs/Tasker/Events/Catalog/CustomEventRegistrar.html +1 -1
- data/docs/Tasker/Events/Catalog/ExamplePayloadGenerator.html +1 -1
- data/docs/Tasker/Events/Catalog.html +1 -1
- data/docs/Tasker/Events/CustomRegistry.html +1 -1
- data/docs/Tasker/Events/DefinitionLoader.html +1 -1
- data/docs/Tasker/Events/EventPayloadBuilder/ErrorInfoExtractor.html +1 -1
- data/docs/Tasker/Events/EventPayloadBuilder/StepPayloadBuilder.html +1 -1
- data/docs/Tasker/Events/EventPayloadBuilder.html +1 -1
- data/docs/Tasker/Events/Publisher.html +1 -1
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer/ErrorTypeClassifier.html +1 -1
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/ErrorCategorizer.html +1 -1
- data/docs/Tasker/Events/Subscribers/BaseSubscriber/MetricTagsExtractor.html +1 -1
- data/docs/Tasker/Events/Subscribers/BaseSubscriber.html +1 -1
- data/docs/Tasker/Events/Subscribers/MetricsSubscriber.html +1 -1
- data/docs/Tasker/Events/Subscribers/TelemetrySubscriber.html +1 -1
- data/docs/Tasker/Events/Subscribers.html +1 -1
- data/docs/Tasker/Events/SubscriptionLoader.html +1 -1
- data/docs/Tasker/Events.html +1 -1
- data/docs/Tasker/EventsGenerator.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics/AnalyticsMetrics.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedAnalyticsMetrics.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedDependencyLevels.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSlowestSteps/SlowestStep.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSlowestSteps.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSlowestTasks/SlowestTask.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSlowestTasks.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedStepReadinessStatus.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts/HealthMetrics.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedSystemHealthCounts.html +1 -1
- data/docs/Tasker/Functions/FunctionBasedTaskExecutionContext.html +1 -1
- data/docs/Tasker/Functions/FunctionWrapper.html +1 -1
- data/docs/Tasker/Functions.html +1 -1
- data/docs/Tasker/Generators/AuthenticatorGenerator/UsageInstructionsFormatter.html +1 -1
- data/docs/Tasker/Generators/AuthenticatorGenerator.html +1 -1
- data/docs/Tasker/Generators/AuthorizationCoordinatorGenerator.html +1 -1
- data/docs/Tasker/Generators/SubscriberGenerator.html +1 -1
- data/docs/Tasker/Generators/TaskHandlerGenerator.html +1 -1
- data/docs/Tasker/Generators.html +1 -1
- data/docs/Tasker/GraphQLTypes/AnnotationType.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseArgument.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseConnection.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseEdge.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseEnum.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseField.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseInputObject.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseInterface.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseObject.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseScalar.html +1 -1
- data/docs/Tasker/GraphQLTypes/BaseUnion.html +1 -1
- data/docs/Tasker/GraphQLTypes/DependentSystemObjectMapType.html +1 -1
- data/docs/Tasker/GraphQLTypes/DependentSystemType.html +1 -1
- data/docs/Tasker/GraphQLTypes/MutationType.html +1 -1
- data/docs/Tasker/GraphQLTypes/NamedStepType.html +1 -1
- data/docs/Tasker/GraphQLTypes/NamedTaskType.html +1 -1
- data/docs/Tasker/GraphQLTypes/NamedTasksNamedStepType.html +1 -1
- data/docs/Tasker/GraphQLTypes/NodeType.html +1 -1
- data/docs/Tasker/GraphQLTypes/QueryType.html +1 -1
- data/docs/Tasker/GraphQLTypes/TaskAnnotationType.html +1 -1
- data/docs/Tasker/GraphQLTypes/TaskInterface.html +1 -1
- data/docs/Tasker/GraphQLTypes/TaskType.html +1 -1
- data/docs/Tasker/GraphQLTypes/WorkflowStepType.html +1 -1
- data/docs/Tasker/GraphQLTypes.html +1 -1
- data/docs/Tasker/GraphqlController.html +1 -1
- data/docs/Tasker/HandlerFactory.html +1 -1
- data/docs/Tasker/HandlerSerializer.html +1 -1
- data/docs/Tasker/HandlersController.html +1 -1
- data/docs/Tasker/HashIdentityStrategy.html +1 -1
- data/docs/Tasker/Health/ReadinessChecker.html +1 -1
- data/docs/Tasker/Health/StatusChecker.html +1 -1
- data/docs/Tasker/Health.html +1 -1
- data/docs/Tasker/HealthController.html +1 -1
- data/docs/Tasker/IdentityStrategy.html +1 -1
- data/docs/Tasker/InvalidTaskHandlerConfig.html +1 -1
- data/docs/Tasker/Logging/CorrelationIdGenerator.html +1 -1
- data/docs/Tasker/Logging.html +1 -1
- data/docs/Tasker/MetricsController.html +1 -1
- data/docs/Tasker/MetricsExportJob.html +1 -1
- data/docs/Tasker/Mutations/BaseMutation.html +1 -1
- data/docs/Tasker/Mutations/CancelStep.html +1 -1
- data/docs/Tasker/Mutations/CancelTask.html +1 -1
- data/docs/Tasker/Mutations/CreateTask.html +1 -1
- data/docs/Tasker/Mutations/UpdateStep.html +1 -1
- data/docs/Tasker/Mutations/UpdateTask.html +1 -1
- data/docs/Tasker/Mutations.html +1 -1
- data/docs/Tasker/NamedStep.html +1 -1
- data/docs/Tasker/NamedTask.html +1 -1
- data/docs/Tasker/NamedTasksNamedStep.html +1 -1
- data/docs/Tasker/Orchestration/BackoffCalculator.html +1 -1
- data/docs/Tasker/Orchestration/ConnectionBuilder/ConfigValidator.html +1 -1
- data/docs/Tasker/Orchestration/ConnectionBuilder.html +1 -1
- data/docs/Tasker/Orchestration/ConnectionPoolIntelligence.html +1 -1
- data/docs/Tasker/Orchestration/Coordinator.html +1 -1
- data/docs/Tasker/Orchestration/FutureStateAnalyzer.html +1 -1
- data/docs/Tasker/Orchestration/PluginIntegration.html +1 -1
- data/docs/Tasker/Orchestration/ResponseProcessor.html +1 -1
- data/docs/Tasker/Orchestration/RetryHeaderParser.html +1 -1
- data/docs/Tasker/Orchestration/StepExecutor.html +1 -1
- data/docs/Tasker/Orchestration/StepSequenceFactory.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/BlockageChecker.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/ContextManager.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/DelayCalculator.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationDecisionMaker.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/FinalizationProcessor.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/ReasonDeterminer.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/ReenqueueManager.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer/UnclearStateHandler.html +1 -1
- data/docs/Tasker/Orchestration/TaskFinalizer.html +1 -1
- data/docs/Tasker/Orchestration/TaskInitializer.html +1 -1
- data/docs/Tasker/Orchestration/TaskReenqueuer.html +1 -1
- data/docs/Tasker/Orchestration/ViableStepDiscovery.html +1 -1
- data/docs/Tasker/Orchestration/WorkflowCoordinator.html +1 -1
- data/docs/Tasker/Orchestration.html +1 -1
- data/docs/Tasker/PageSort/PageSortParamsBuilder.html +1 -1
- data/docs/Tasker/PageSort.html +1 -1
- data/docs/Tasker/PermanentError.html +1 -1
- data/docs/Tasker/ProceduralError.html +1 -1
- data/docs/Tasker/Queries/AllAnnotationTypes.html +1 -1
- data/docs/Tasker/Queries/AllTasks.html +1 -1
- data/docs/Tasker/Queries/BaseQuery.html +1 -1
- data/docs/Tasker/Queries/Helpers.html +1 -1
- data/docs/Tasker/Queries/OneStep.html +1 -1
- data/docs/Tasker/Queries/OneTask.html +1 -1
- data/docs/Tasker/Queries/TasksByAnnotation.html +1 -1
- data/docs/Tasker/Queries/TasksByStatus.html +1 -1
- data/docs/Tasker/Queries.html +1 -1
- data/docs/Tasker/Railtie.html +1 -1
- data/docs/Tasker/Registry/BaseRegistry.html +1 -1
- data/docs/Tasker/Registry/EventPublisher.html +1 -1
- data/docs/Tasker/Registry/InterfaceValidator.html +1 -1
- data/docs/Tasker/Registry/RegistrationError.html +1 -1
- data/docs/Tasker/Registry/RegistryError.html +1 -1
- data/docs/Tasker/Registry/StatisticsCollector.html +1 -1
- data/docs/Tasker/Registry/SubscriberRegistry.html +1 -1
- data/docs/Tasker/Registry/ValidationError.html +1 -1
- data/docs/Tasker/Registry.html +1 -1
- data/docs/Tasker/RetryableError.html +1 -1
- data/docs/Tasker/StateMachine/Compatibility.html +1 -1
- data/docs/Tasker/StateMachine/InvalidStateTransition.html +1 -1
- data/docs/Tasker/StateMachine/StepStateMachine.html +1 -1
- data/docs/Tasker/StateMachine/TaskStateMachine.html +1 -1
- data/docs/Tasker/StateMachine.html +1 -1
- data/docs/Tasker/StepDagRelationship.html +1 -1
- data/docs/Tasker/StepHandler/Api/Config.html +1 -1
- data/docs/Tasker/StepHandler/Api.html +1 -1
- data/docs/Tasker/StepHandler/AutomaticEventPublishing.html +1 -1
- data/docs/Tasker/StepHandler/Base.html +1 -1
- data/docs/Tasker/StepHandler.html +1 -1
- data/docs/Tasker/StepReadinessStatus.html +1 -1
- data/docs/Tasker/Task.html +76 -183
- data/docs/Tasker/TaskAnnotation.html +1 -1
- data/docs/Tasker/TaskAnnotationSerializer.html +1 -1
- data/docs/Tasker/TaskBuilder/StepNameValidator.html +1 -1
- data/docs/Tasker/TaskBuilder/StepTemplateDefiner.html +1 -1
- data/docs/Tasker/TaskBuilder.html +1 -1
- data/docs/Tasker/TaskExecutionContext.html +1 -1
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/ClassBasedEventRegistrar.html +1 -1
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner/YamlEventRegistrar.html +1 -1
- data/docs/Tasker/TaskHandler/ClassMethods/StepTemplateDefiner.html +1 -1
- data/docs/Tasker/TaskHandler/ClassMethods.html +1 -1
- data/docs/Tasker/TaskHandler/InstanceMethods.html +1 -1
- data/docs/Tasker/TaskHandler/StepGroup.html +1 -1
- data/docs/Tasker/TaskHandler.html +1 -1
- data/docs/Tasker/TaskNamespace.html +1 -1
- data/docs/Tasker/TaskRunnerJob.html +1 -1
- data/docs/Tasker/TaskSerializer.html +1 -1
- data/docs/Tasker/TaskTransition.html +1 -1
- data/docs/Tasker/TaskerRailsSchema/InvalidObjectTypeError.html +1 -1
- data/docs/Tasker/TaskerRailsSchema/TypeResolutionError.html +1 -1
- data/docs/Tasker/TaskerRailsSchema/UnknownInterfaceError.html +1 -1
- data/docs/Tasker/TaskerRailsSchema.html +1 -1
- data/docs/Tasker/TasksController.html +1 -1
- data/docs/Tasker/Telemetry/EventMapping.html +1 -1
- data/docs/Tasker/Telemetry/EventRouter.html +1 -1
- data/docs/Tasker/Telemetry/Events/ExportEvents.html +1 -1
- data/docs/Tasker/Telemetry/Events.html +1 -1
- data/docs/Tasker/Telemetry/ExportCoordinator.html +1 -1
- data/docs/Tasker/Telemetry/IntelligentCacheManager.html +1 -1
- data/docs/Tasker/Telemetry/LogBackend.html +1 -1
- data/docs/Tasker/Telemetry/MetricTypes/Counter.html +1 -1
- data/docs/Tasker/Telemetry/MetricTypes/Gauge.html +1 -1
- data/docs/Tasker/Telemetry/MetricTypes/Histogram.html +1 -1
- data/docs/Tasker/Telemetry/MetricTypes.html +1 -1
- data/docs/Tasker/Telemetry/MetricsBackend.html +1 -1
- data/docs/Tasker/Telemetry/MetricsExportService.html +1 -1
- data/docs/Tasker/Telemetry/PluginRegistry.html +1 -1
- data/docs/Tasker/Telemetry/Plugins/BaseExporter.html +1 -1
- data/docs/Tasker/Telemetry/Plugins/CsvExporter.html +1 -1
- data/docs/Tasker/Telemetry/Plugins/JsonExporter.html +1 -1
- data/docs/Tasker/Telemetry/Plugins.html +1 -1
- data/docs/Tasker/Telemetry/PrometheusExporter.html +1 -1
- data/docs/Tasker/Telemetry/TraceBackend.html +1 -1
- data/docs/Tasker/Telemetry.html +1 -1
- data/docs/Tasker/Types/AuthConfig.html +1 -1
- data/docs/Tasker/Types/BackoffConfig.html +1 -1
- data/docs/Tasker/Types/BaseConfig.html +1 -1
- data/docs/Tasker/Types/CacheConfig.html +1 -1
- data/docs/Tasker/Types/DatabaseConfig.html +1 -1
- data/docs/Tasker/Types/DependencyGraph.html +1 -1
- data/docs/Tasker/Types/DependencyGraphConfig.html +1 -1
- data/docs/Tasker/Types/EngineConfig.html +1 -1
- data/docs/Tasker/Types/ExecutionConfig.html +1 -1
- data/docs/Tasker/Types/GraphEdge.html +1 -1
- data/docs/Tasker/Types/GraphMetadata.html +1 -1
- data/docs/Tasker/Types/GraphNode.html +1 -1
- data/docs/Tasker/Types/HealthConfig.html +1 -1
- data/docs/Tasker/Types/StepSequence.html +1 -1
- data/docs/Tasker/Types/StepTemplate.html +1 -1
- data/docs/Tasker/Types/TaskRequest.html +1 -1
- data/docs/Tasker/Types/TelemetryConfig.html +1 -1
- data/docs/Tasker/Types.html +1 -1
- data/docs/Tasker/WorkflowStep/StepFinder.html +1 -1
- data/docs/Tasker/WorkflowStep.html +1 -1
- data/docs/Tasker/WorkflowStepEdge.html +1 -1
- data/docs/Tasker/WorkflowStepSerializer.html +1 -1
- data/docs/Tasker/WorkflowStepTransition/TransitionDescriptionFormatter.html +1 -1
- data/docs/Tasker/WorkflowStepTransition.html +1 -1
- data/docs/Tasker/WorkflowStepsController.html +1 -1
- data/docs/Tasker.html +5 -5
- data/docs/_index.html +21 -77
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +3 -7
- data/docs/index.html +3 -7
- data/docs/method_list.html +1105 -1433
- data/docs/top-level-namespace.html +1 -1
- data/lib/generators/tasker/templates/authorization_coordinator.rb.erb +0 -13
- data/lib/generators/tasker/templates/authorization_coordinator_spec.rb.erb +1 -7
- data/lib/tasker/authorization/resource_constants.rb +1 -2
- data/lib/tasker/authorization/resource_registry.rb +0 -7
- data/lib/tasker/version.rb +1 -1
- metadata +2 -9
- data/app/controllers/tasker/task_diagrams_controller.rb +0 -30
- data/app/models/tasker/diagram/edge.rb +0 -106
- data/app/models/tasker/diagram/flowchart.rb +0 -137
- data/app/models/tasker/diagram/node.rb +0 -99
- data/app/models/tasker/task_diagram.rb +0 -332
- data/app/views/tasker/task/_diagram.html.erb +0 -32
- data/docs/TASK_DIAGRAM.md +0 -252
@@ -1,332 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'erb'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
module Tasker
|
7
|
-
class TaskDiagram
|
8
|
-
# Colors for different step statuses
|
9
|
-
STATUS_COLORS = {
|
10
|
-
Tasker::Constants::WorkflowStepStatuses::PENDING => 'lightblue',
|
11
|
-
Tasker::Constants::WorkflowStepStatuses::IN_PROGRESS => 'lightgreen',
|
12
|
-
Tasker::Constants::WorkflowStepStatuses::COMPLETE => 'green',
|
13
|
-
Tasker::Constants::WorkflowStepStatuses::ERROR => 'red',
|
14
|
-
Tasker::Constants::WorkflowStepStatuses::CANCELLED => 'gray'
|
15
|
-
}.freeze
|
16
|
-
|
17
|
-
# Create a new task diagram
|
18
|
-
#
|
19
|
-
# @param task [Tasker::Task] The task to create a diagram for
|
20
|
-
# @param base_url [String, nil] Optional base URL for REST endpoints
|
21
|
-
# @return [TaskDiagram] A new task diagram instance
|
22
|
-
def initialize(task, base_url = nil)
|
23
|
-
@task = task
|
24
|
-
@base_url = base_url
|
25
|
-
end
|
26
|
-
|
27
|
-
# Generate a Mermaid diagram string for the task
|
28
|
-
#
|
29
|
-
# @return [String] Mermaid flowchart diagram string
|
30
|
-
delegate :to_mermaid, to: :flowchart
|
31
|
-
|
32
|
-
# Generate a complete HTML document with embedded Mermaid diagram
|
33
|
-
#
|
34
|
-
# @return [String] HTML document with Mermaid diagram
|
35
|
-
def to_html
|
36
|
-
# Generate the mermaid diagram
|
37
|
-
@diagram = flowchart.to_mermaid
|
38
|
-
|
39
|
-
# Create binding with relevant variables
|
40
|
-
task = @task # Make task available to the template
|
41
|
-
diagram = @diagram # Make diagram available to the template
|
42
|
-
|
43
|
-
# Create a binding with the variables
|
44
|
-
b = binding
|
45
|
-
|
46
|
-
# Get the template path relative to this file
|
47
|
-
template_path = views_path.join('_diagram.html.erb')
|
48
|
-
|
49
|
-
# Load and render the template with ERB
|
50
|
-
begin
|
51
|
-
template = File.read(template_path)
|
52
|
-
ERB.new(template).result(b)
|
53
|
-
rescue Errno::ENOENT
|
54
|
-
raise TaskDiagramError, "Template file not found: #{template_path}"
|
55
|
-
rescue Errno::EACCES
|
56
|
-
raise TaskDiagramError, "Permission denied while accessing template file: #{template_path}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_json(pretty: false)
|
61
|
-
flowchart.to_json(pretty: pretty)
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def flowchart
|
67
|
-
return @flowchart if @flowchart
|
68
|
-
|
69
|
-
# Preload workflow steps with scenic view relationships for efficiency
|
70
|
-
workflow_steps = @task.workflow_steps.includes(:named_step, :step_dag_relationship)
|
71
|
-
|
72
|
-
# Create a new flowchart
|
73
|
-
@flowchart = Tasker::Diagram::Flowchart.new(
|
74
|
-
direction: 'TD',
|
75
|
-
title: "Task #{@task.task_id}: #{@task.name}"
|
76
|
-
)
|
77
|
-
|
78
|
-
# Add task info node
|
79
|
-
@flowchart.add_node(build_task_node)
|
80
|
-
|
81
|
-
# Build nodes for all workflow steps
|
82
|
-
workflow_steps.each do |step|
|
83
|
-
@flowchart.add_node(build_step_node(step))
|
84
|
-
end
|
85
|
-
|
86
|
-
# Build all edges efficiently using scenic view data
|
87
|
-
build_all_step_edges(workflow_steps).each do |edge|
|
88
|
-
@flowchart.add_edge(edge)
|
89
|
-
end
|
90
|
-
|
91
|
-
@flowchart
|
92
|
-
end
|
93
|
-
|
94
|
-
# Get the path to the view templates directory
|
95
|
-
#
|
96
|
-
# @return [Pathname] Path to view templates
|
97
|
-
def views_path
|
98
|
-
# Get the absolute path of the current file
|
99
|
-
current_file = Pathname.new(__FILE__)
|
100
|
-
|
101
|
-
# Navigate to the views directory relative to this file
|
102
|
-
# This file is in app/models/tasker/task_diagram.rb
|
103
|
-
# Views are in app/views/tasker/task/
|
104
|
-
current_file.dirname.parent.parent.parent.join('app', 'views', 'tasker', 'task')
|
105
|
-
end
|
106
|
-
|
107
|
-
# Build the task information node
|
108
|
-
#
|
109
|
-
# @return [Tasker::Diagram::Node] The task node
|
110
|
-
def build_task_node
|
111
|
-
Tasker::Diagram::Node.new(
|
112
|
-
id: "task_#{@task.task_id}",
|
113
|
-
label: "Task: #{@task.name}\nID: #{@task.task_id}\nStatus: #{@task.status}"
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Build a node for a workflow step
|
118
|
-
#
|
119
|
-
# @param step [Tasker::WorkflowStep] The workflow step
|
120
|
-
# @return [Tasker::Diagram::Node] The step node
|
121
|
-
def build_step_node(step)
|
122
|
-
node_id = "step_#{step.workflow_step_id}"
|
123
|
-
color = STATUS_COLORS[step.status] || 'lightgray'
|
124
|
-
|
125
|
-
# Create label with step details
|
126
|
-
label = build_step_label(step)
|
127
|
-
|
128
|
-
# Create clickable URL if base_url is provided
|
129
|
-
url = @base_url ? "#{@base_url}/tasks/#{@task.task_id}/workflow_steps/#{step.workflow_step_id}" : nil
|
130
|
-
|
131
|
-
# Create node with styling
|
132
|
-
Tasker::Diagram::Node.new(
|
133
|
-
id: node_id,
|
134
|
-
label: label.join("\n"),
|
135
|
-
shape: 'box',
|
136
|
-
style: "fill:#{color};",
|
137
|
-
url: url
|
138
|
-
)
|
139
|
-
end
|
140
|
-
|
141
|
-
# Build the label lines for a step node
|
142
|
-
#
|
143
|
-
# @param step [Tasker::WorkflowStep] The workflow step
|
144
|
-
# @return [Array<String>] Array of label lines
|
145
|
-
def build_step_label(step)
|
146
|
-
label = [
|
147
|
-
"Step: #{step.name}",
|
148
|
-
"Status: #{step.status}",
|
149
|
-
"Attempts: #{step.attempts || 0}"
|
150
|
-
]
|
151
|
-
|
152
|
-
# Add error info if applicable
|
153
|
-
if step.status == Tasker::Constants::WorkflowStepStatuses::ERROR && step.results&.key?('error')
|
154
|
-
error_msg = step.results['error'].to_s
|
155
|
-
# Truncate long error messages
|
156
|
-
error_msg = "#{error_msg[0..27]}..." if error_msg.length > 30
|
157
|
-
label << "Error: #{error_msg}"
|
158
|
-
end
|
159
|
-
|
160
|
-
label
|
161
|
-
end
|
162
|
-
|
163
|
-
# Build an edge between two nodes
|
164
|
-
#
|
165
|
-
# @param source_id [String] The source node ID
|
166
|
-
# @param target_id [String] The target node ID
|
167
|
-
# @param label [String] The edge label
|
168
|
-
# @return [Tasker::Diagram::Edge] The edge
|
169
|
-
def build_edge(source_id, target_id, label = '')
|
170
|
-
Tasker::Diagram::Edge.new(
|
171
|
-
source_id: source_id,
|
172
|
-
target_id: target_id,
|
173
|
-
label: label
|
174
|
-
)
|
175
|
-
end
|
176
|
-
|
177
|
-
# Build all edges efficiently using scenic view data - eliminates N+1 queries
|
178
|
-
#
|
179
|
-
# @param workflow_steps [Array<Tasker::WorkflowStep>] All workflow steps for the task
|
180
|
-
# @return [Array<Tasker::Diagram::Edge>] All edges for the diagram
|
181
|
-
def build_all_step_edges(workflow_steps)
|
182
|
-
edges = []
|
183
|
-
|
184
|
-
# Add edges from task to root steps using dedicated builder
|
185
|
-
edges.concat(TaskToRootStepEdgeBuilder.build(@task, workflow_steps))
|
186
|
-
|
187
|
-
# Add edges between steps using dedicated builder
|
188
|
-
edges.concat(StepToStepEdgeBuilder.build(workflow_steps))
|
189
|
-
|
190
|
-
edges
|
191
|
-
end
|
192
|
-
|
193
|
-
# Service class to build edges from task to root steps
|
194
|
-
# Reduces complexity by organizing edge building logic
|
195
|
-
class TaskToRootStepEdgeBuilder
|
196
|
-
class << self
|
197
|
-
# Build edges from task node to root steps
|
198
|
-
#
|
199
|
-
# @param task [Tasker::Task] The task
|
200
|
-
# @param workflow_steps [Array<Tasker::WorkflowStep>] All workflow steps
|
201
|
-
# @return [Array<Tasker::Diagram::Edge>] Task to root step edges
|
202
|
-
def build(task, workflow_steps)
|
203
|
-
edges = []
|
204
|
-
|
205
|
-
workflow_steps.each do |step|
|
206
|
-
next unless step.step_dag_relationship&.is_root_step
|
207
|
-
|
208
|
-
edges << build_edge(
|
209
|
-
"task_#{task.task_id}",
|
210
|
-
"step_#{step.workflow_step_id}"
|
211
|
-
)
|
212
|
-
end
|
213
|
-
|
214
|
-
edges
|
215
|
-
end
|
216
|
-
|
217
|
-
private
|
218
|
-
|
219
|
-
# Build an edge between two nodes
|
220
|
-
#
|
221
|
-
# @param source_id [String] The source node ID
|
222
|
-
# @param target_id [String] The target node ID
|
223
|
-
# @param label [String] The edge label
|
224
|
-
# @return [Tasker::Diagram::Edge] The edge
|
225
|
-
def build_edge(source_id, target_id, label = '')
|
226
|
-
Tasker::Diagram::Edge.new(
|
227
|
-
source_id: source_id,
|
228
|
-
target_id: target_id,
|
229
|
-
label: label
|
230
|
-
)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
# Service class to build edges between workflow steps
|
236
|
-
# Reduces complexity by organizing edge building logic
|
237
|
-
class StepToStepEdgeBuilder
|
238
|
-
class << self
|
239
|
-
# Build edges between workflow steps
|
240
|
-
#
|
241
|
-
# @param workflow_steps [Array<Tasker::WorkflowStep>] All workflow steps
|
242
|
-
# @return [Array<Tasker::Diagram::Edge>] Step to step edges
|
243
|
-
def build(workflow_steps)
|
244
|
-
edge_data = collect_edge_data(workflow_steps)
|
245
|
-
return [] if edge_data.empty?
|
246
|
-
|
247
|
-
edge_records = batch_load_edge_records(edge_data)
|
248
|
-
build_edges_from_data(edge_data, edge_records)
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
|
253
|
-
# Collect all edge relationships for efficient batch lookup
|
254
|
-
#
|
255
|
-
# @param workflow_steps [Array<Tasker::WorkflowStep>] All workflow steps
|
256
|
-
# @return [Array<Hash>] Edge data with from_step_id and to_step_id
|
257
|
-
def collect_edge_data(workflow_steps)
|
258
|
-
edge_data = []
|
259
|
-
|
260
|
-
workflow_steps.each do |step|
|
261
|
-
next unless step.step_dag_relationship
|
262
|
-
|
263
|
-
child_ids = step.step_dag_relationship.child_step_ids_array
|
264
|
-
child_ids.each do |child_id|
|
265
|
-
edge_data << {
|
266
|
-
from_step_id: step.workflow_step_id,
|
267
|
-
to_step_id: child_id
|
268
|
-
}
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
edge_data
|
273
|
-
end
|
274
|
-
|
275
|
-
# Batch load all WorkflowStepEdge records for edge labels
|
276
|
-
#
|
277
|
-
# @param edge_data [Array<Hash>] Edge data to load records for
|
278
|
-
# @return [Hash] Hash mapping edge keys to edge records
|
279
|
-
def batch_load_edge_records(edge_data)
|
280
|
-
edge_records = {}
|
281
|
-
|
282
|
-
conditions = edge_data.map do |data|
|
283
|
-
"(from_step_id = #{data[:from_step_id]} AND to_step_id = #{data[:to_step_id]})"
|
284
|
-
end
|
285
|
-
|
286
|
-
Tasker::WorkflowStepEdge.where(conditions.join(' OR ')).find_each do |edge_record|
|
287
|
-
key = "#{edge_record.from_step_id}_#{edge_record.to_step_id}"
|
288
|
-
edge_records[key] = edge_record
|
289
|
-
end
|
290
|
-
|
291
|
-
edge_records
|
292
|
-
end
|
293
|
-
|
294
|
-
# Build edges using pre-calculated data and records
|
295
|
-
#
|
296
|
-
# @param edge_data [Array<Hash>] Edge data with IDs
|
297
|
-
# @param edge_records [Hash] Loaded edge records for labels
|
298
|
-
# @return [Array<Tasker::Diagram::Edge>] Built edges
|
299
|
-
def build_edges_from_data(edge_data, edge_records)
|
300
|
-
edges = []
|
301
|
-
|
302
|
-
edge_data.each do |data|
|
303
|
-
source_id = "step_#{data[:from_step_id]}"
|
304
|
-
target_id = "step_#{data[:to_step_id]}"
|
305
|
-
|
306
|
-
# Find edge label from batch-loaded records
|
307
|
-
key = "#{data[:from_step_id]}_#{data[:to_step_id]}"
|
308
|
-
edge_label = edge_records[key]&.name || ''
|
309
|
-
|
310
|
-
edges << build_edge(source_id, target_id, edge_label)
|
311
|
-
end
|
312
|
-
|
313
|
-
edges
|
314
|
-
end
|
315
|
-
|
316
|
-
# Build an edge between two nodes
|
317
|
-
#
|
318
|
-
# @param source_id [String] The source node ID
|
319
|
-
# @param target_id [String] The target node ID
|
320
|
-
# @param label [String] The edge label
|
321
|
-
# @return [Tasker::Diagram::Edge] The edge
|
322
|
-
def build_edge(source_id, target_id, label = '')
|
323
|
-
Tasker::Diagram::Edge.new(
|
324
|
-
source_id: source_id,
|
325
|
-
target_id: target_id,
|
326
|
-
label: label
|
327
|
-
)
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>Task <%= task.task_id %> Workflow Diagram</title>
|
6
|
-
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
7
|
-
<script>
|
8
|
-
mermaid.initialize({
|
9
|
-
startOnLoad: true,
|
10
|
-
theme: 'default'
|
11
|
-
});
|
12
|
-
</script>
|
13
|
-
<style>
|
14
|
-
body { font-family: Arial, sans-serif; margin: 20px; }
|
15
|
-
.mermaid { margin: 20px 0; }
|
16
|
-
.header { margin-bottom: 20px; }
|
17
|
-
</style>
|
18
|
-
</head>
|
19
|
-
<body>
|
20
|
-
<div class="header">
|
21
|
-
<h1>Task Workflow Diagram</h1>
|
22
|
-
<p>Task ID: <%= task.task_id %></p>
|
23
|
-
<p>Task Name: <%= task.name %></p>
|
24
|
-
<p>Status: <%= task.status %></p>
|
25
|
-
<p>Created: <%= task.created_at %></p>
|
26
|
-
</div>
|
27
|
-
|
28
|
-
<div class="tasker-diagram mermaid">
|
29
|
-
<%= diagram %>
|
30
|
-
</div>
|
31
|
-
</body>
|
32
|
-
</html>
|
data/docs/TASK_DIAGRAM.md
DELETED
@@ -1,252 +0,0 @@
|
|
1
|
-
# Tasker Task Diagrams
|
2
|
-
|
3
|
-
The `Tasker::TaskDiagram` class provides a way to visualize task workflows using Mermaid diagrams. This makes it easy to understand the current state of a task's workflow and the relationships between its steps.
|
4
|
-
|
5
|
-
## Features
|
6
|
-
|
7
|
-
Tasker::TaskDiagram includes:
|
8
|
-
|
9
|
-
- A native diagram implementation (no external gems required)
|
10
|
-
- Automatic color-coding of workflow steps based on their status
|
11
|
-
- Direct generation of Mermaid syntax for flowcharts
|
12
|
-
- Support for embedding diagrams in web pages
|
13
|
-
- Complete HTML document generation with the diagram embedded
|
14
|
-
|
15
|
-
## Basic Usage
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
# Create a diagram for a task
|
19
|
-
task = Tasker::Task.find(task_id)
|
20
|
-
diagram = Tasker::TaskDiagram.new(task)
|
21
|
-
|
22
|
-
# Generate Mermaid syntax
|
23
|
-
mermaid_string = diagram.to_mermaid
|
24
|
-
|
25
|
-
# Generate a complete HTML document with the embedded diagram
|
26
|
-
html_document = diagram.to_html
|
27
|
-
|
28
|
-
# Convert diagram to JSON format
|
29
|
-
json_data = diagram.to_json
|
30
|
-
```
|
31
|
-
|
32
|
-
## Adding Links to REST Endpoints
|
33
|
-
|
34
|
-
You can add clickable links to each workflow step by providing a base URL when creating the diagram:
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
# Create a diagram with links to REST endpoints
|
38
|
-
base_url = "https://example.com/api"
|
39
|
-
diagram = Tasker::TaskDiagram.new(task, base_url)
|
40
|
-
|
41
|
-
# Each step in the diagram will link to {base_url}/workflow_steps/{workflow_step_id}
|
42
|
-
```
|
43
|
-
|
44
|
-
## Diagram Rendering Options
|
45
|
-
|
46
|
-
The TaskDiagram class provides two main methods for visualization:
|
47
|
-
|
48
|
-
### to_mermaid
|
49
|
-
|
50
|
-
This method returns a string containing the Mermaid diagram syntax, which can be embedded in Markdown files, documentation, or any Mermaid-compatible viewer.
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
diagram = Tasker::TaskDiagram.new(task)
|
54
|
-
mermaid_string = diagram.to_mermaid
|
55
|
-
|
56
|
-
# Example output:
|
57
|
-
# graph TD
|
58
|
-
# subgraph "Task 123: MyTask"
|
59
|
-
# task_123["Task: MyTask<br/>ID: 123<br/>Status: COMPLETE"]
|
60
|
-
# step_456["Step: step1<br/>Status: COMPLETE<br/>Attempts: 1"]
|
61
|
-
# task_123 --> step_456
|
62
|
-
# ...
|
63
|
-
# end
|
64
|
-
```
|
65
|
-
|
66
|
-
### to_html
|
67
|
-
|
68
|
-
This method returns a complete HTML document with the Mermaid diagram embedded and ready to view in a web browser. The HTML includes:
|
69
|
-
|
70
|
-
- The Mermaid JavaScript library for rendering
|
71
|
-
- Basic styling for the diagram
|
72
|
-
- Task information in a header section
|
73
|
-
- The rendered diagram
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
diagram = Tasker::TaskDiagram.new(task)
|
77
|
-
html = diagram.to_html
|
78
|
-
|
79
|
-
# Save to a file for viewing
|
80
|
-
File.write("task_#{task.task_id}_diagram.html", html)
|
81
|
-
```
|
82
|
-
|
83
|
-
### to_json
|
84
|
-
|
85
|
-
This method returns the diagram data as a JSON string with nodes, edges, and diagram properties. This is useful for APIs and for custom rendering.
|
86
|
-
|
87
|
-
```ruby
|
88
|
-
diagram = Tasker::TaskDiagram.new(task)
|
89
|
-
json = diagram.to_json
|
90
|
-
|
91
|
-
# Example output:
|
92
|
-
# {
|
93
|
-
# "nodes": [
|
94
|
-
# {"id": "task_123", "label": "Task: MyTask\nID: 123\nStatus: COMPLETE", ...},
|
95
|
-
# {"id": "step_456", "label": "Step: step1\nStatus: COMPLETE\nAttempts: 1", ...}
|
96
|
-
# ],
|
97
|
-
# "edges": [
|
98
|
-
# {"source_id": "task_123", "target_id": "step_456", ...}
|
99
|
-
# ],
|
100
|
-
# "direction": "TD",
|
101
|
-
# "title": "Task 123: MyTask"
|
102
|
-
# }
|
103
|
-
```
|
104
|
-
|
105
|
-
## Templates
|
106
|
-
|
107
|
-
The HTML rendering uses an ERB template located in the app/views/tasker/task directory:
|
108
|
-
|
109
|
-
- `_diagram.html.erb`: Complete HTML document template for standalone viewing
|
110
|
-
|
111
|
-
You can customize this template to match your application's styling and requirements.
|
112
|
-
|
113
|
-
## Visual Features
|
114
|
-
|
115
|
-
The diagram includes the following visual features:
|
116
|
-
|
117
|
-
- Color-coded steps based on their status:
|
118
|
-
- PENDING: Light blue
|
119
|
-
- IN_PROGRESS: Light green
|
120
|
-
- COMPLETE: Green
|
121
|
-
- ERROR: Red
|
122
|
-
- CANCELLED: Gray
|
123
|
-
|
124
|
-
- Task information at the top, including:
|
125
|
-
- Task name
|
126
|
-
- Task ID
|
127
|
-
- Current status
|
128
|
-
|
129
|
-
- Step information, including:
|
130
|
-
- Step name
|
131
|
-
- Status
|
132
|
-
- Number of attempts
|
133
|
-
- Error information (for steps in ERROR status)
|
134
|
-
|
135
|
-
- Directed edges showing the workflow dependencies between steps
|
136
|
-
|
137
|
-
## Native Diagram Implementation
|
138
|
-
|
139
|
-
The TaskDiagram uses a custom, native diagram implementation with the following components:
|
140
|
-
|
141
|
-
### Tasker::Diagram::Node
|
142
|
-
|
143
|
-
Represents a node in the diagram with properties like:
|
144
|
-
- `id`: Unique identifier
|
145
|
-
- `label`: Display text (supports HTML line breaks with `<br/>`)
|
146
|
-
- `shape`: Node shape (box, circle, etc.)
|
147
|
-
- `style`: CSS styling for the node
|
148
|
-
- `url`: Optional URL for clickable nodes
|
149
|
-
|
150
|
-
### Tasker::Diagram::Edge
|
151
|
-
|
152
|
-
Represents a connection between nodes with properties like:
|
153
|
-
- `source_id`: ID of the source node
|
154
|
-
- `target_id`: ID of the target node
|
155
|
-
- `label`: Text displayed on the edge (shown within pipes `|` in the syntax)
|
156
|
-
- `type`: Edge style (solid, dashed, etc.)
|
157
|
-
- `direction`: Arrow direction (forward, back, both, none)
|
158
|
-
|
159
|
-
### Tasker::Diagram::Flowchart
|
160
|
-
|
161
|
-
Represents a complete flowchart containing nodes and edges with properties like:
|
162
|
-
- `nodes`: Collection of nodes
|
163
|
-
- `edges`: Collection of edges
|
164
|
-
- `direction`: Layout direction (TD, LR, etc.)
|
165
|
-
- `title`: Optional title for the diagram (shown as a subgraph title)
|
166
|
-
|
167
|
-
All these components support JSON serialization and generation of Mermaid syntax.
|
168
|
-
|
169
|
-
## Examples
|
170
|
-
|
171
|
-
### Controller Integration
|
172
|
-
|
173
|
-
You can easily integrate the task diagram into a controller action:
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
class TasksController < ApplicationController
|
177
|
-
def diagram
|
178
|
-
@task = Tasker::Task.find(params[:id])
|
179
|
-
diagram = Tasker::TaskDiagram.new(@task, request.base_url)
|
180
|
-
|
181
|
-
respond_to do |format|
|
182
|
-
format.html { render html: diagram.to_html.html_safe }
|
183
|
-
format.text { render plain: diagram.to_mermaid }
|
184
|
-
format.json { render json: diagram.to_json }
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
```
|
189
|
-
|
190
|
-
### Use in API Responses
|
191
|
-
|
192
|
-
```ruby
|
193
|
-
def show
|
194
|
-
task = Tasker::Task.find(params[:id])
|
195
|
-
diagram = Tasker::TaskDiagram.new(task, request.base_url)
|
196
|
-
|
197
|
-
render json: {
|
198
|
-
task: task.as_json,
|
199
|
-
diagram: JSON.parse(diagram.to_json),
|
200
|
-
mermaid_syntax: diagram.to_mermaid
|
201
|
-
}
|
202
|
-
end
|
203
|
-
```
|
204
|
-
|
205
|
-
### Use in Rails Views
|
206
|
-
|
207
|
-
```erb
|
208
|
-
<!-- Using a div with Mermaid class -->
|
209
|
-
<div class="mermaid">
|
210
|
-
<%= Tasker::TaskDiagram.new(@task).to_mermaid %>
|
211
|
-
</div>
|
212
|
-
|
213
|
-
<!-- Include the Mermaid JS library in your layout -->
|
214
|
-
<% content_for :head do %>
|
215
|
-
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
216
|
-
<script>
|
217
|
-
document.addEventListener('DOMContentLoaded', function() {
|
218
|
-
mermaid.initialize({ startOnLoad: true });
|
219
|
-
});
|
220
|
-
</script>
|
221
|
-
<% end %>
|
222
|
-
```
|
223
|
-
|
224
|
-
### Mermaid Syntax Updates
|
225
|
-
|
226
|
-
The current Mermaid syntax follows these conventions:
|
227
|
-
|
228
|
-
1. Nodes use HTML line breaks with `<br/>` tags instead of newlines
|
229
|
-
```
|
230
|
-
nodeId["Multi-line<br/>content here"]
|
231
|
-
```
|
232
|
-
|
233
|
-
2. Edge labels use pipe syntax for clarity
|
234
|
-
```
|
235
|
-
A -->|"connects to"| B
|
236
|
-
```
|
237
|
-
|
238
|
-
3. Titles are implemented as subgraphs rather than title directives
|
239
|
-
```
|
240
|
-
subgraph "Task 123: Process Order"
|
241
|
-
// nodes and edges here
|
242
|
-
end
|
243
|
-
```
|
244
|
-
|
245
|
-
### Customizing the Template
|
246
|
-
|
247
|
-
You can modify the template to match your application's styling or add additional information:
|
248
|
-
|
249
|
-
```ruby
|
250
|
-
# Customize the template in:
|
251
|
-
# app/views/tasker/task/_diagram.html.erb # Full HTML document
|
252
|
-
```
|