create sequence diagram generator ruby gem

北慕城南 提交于 2019-12-08 10:06:48

问题


So I want to create a gem similar to VCR that starts recording method calls along with the classes those methods are in, maybe even line number, and stop recording and generate say a yml file or something which is effectively a UML sequence diagram metadata description of the run.

Extending that even further, I want to use the mermaid gem to actually spit out a picture UML diagram.

I'm thinking of taking the approach outlined in this reddit post, basically storing a array of hashes to parse into some kind of Plant text downstream. https://www.reddit.com/r/ruby/comments/11ns2l/does_a_uml_sequence_diagram_generation_gem_exist/

http://phrogz.net/ProgrammingRuby/ospace.html#tracingyourprogramsexecution

Anyways, finally, my question is... Is there a better way to approach this? Or should I just kind of follow the idea proposed in the reddit?


回答1:


A simplest solution would be to generate a plant uml file. A Plant file is far simpler than an XMI file and Plant is integrated in a lot's of tool.

It could be an alternative.

plantUML

For example:

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

produces:




回答2:


ZemUML support C-like code.

For example,ZenUML.isAwesome()will generate the following diagram:

If your meta DSL follows the same syntax, it can be directly integrated with ZenUML. The JS library is published as npm module.



来源:https://stackoverflow.com/questions/47517259/create-sequence-diagram-generator-ruby-gem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!