{"id":13558114,"url":"https://github.com/zeisler/visualize_ruby","last_synced_at":"2025-04-03T12:31:53.657Z","repository":{"id":56897536,"uuid":"136990647","full_name":"zeisler/visualize_ruby","owner":"zeisler","description":" Transform code into a flowchart and experimentally trace the execution path through it","archived":false,"fork":false,"pushed_at":"2024-10-20T17:01:22.000Z","size":8706,"stargazers_count":250,"open_issues_count":1,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-24T12:55:03.714Z","etag":null,"topics":["diagram","execution-graph","flowcharts","graphs","graphviz","ruby","visualization"],"latest_commit_sha":null,"homepage":"https://visualize.dustinzeisler.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeisler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-11T23:10:31.000Z","updated_at":"2025-01-20T12:46:02.000Z","dependencies_parsed_at":"2024-11-04T08:32:12.616Z","dependency_job_id":"8686f7ba-5f7f-463c-8970-35eab913b163","html_url":"https://github.com/zeisler/visualize_ruby","commit_stats":{"total_commits":57,"total_committers":4,"mean_commits":14.25,"dds":"0.42105263157894735","last_synced_commit":"fddbc864731f13108b54b41566190e60dc505467"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Fvisualize_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Fvisualize_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Fvisualize_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Fvisualize_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeisler","download_url":"https://codeload.github.com/zeisler/visualize_ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247002524,"owners_count":20867470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagram","execution-graph","flowcharts","graphs","graphviz","ruby","visualization"],"created_at":"2024-08-01T12:04:45.259Z","updated_at":"2025-04-03T12:31:48.647Z","avatar_url":"https://github.com/zeisler.png","language":"Ruby","readme":"# VisualizeRuby\n\n![logo](logo.jpg)\n\nWrite a Ruby code and see method interactions on a flow chart. Works with procedural code, bare methods, and Classes.\nThis is experimental project and does not support all types of code. \nIf you'd like it to support more types of code please pull request.\n\n[Demo](https://visualize.dustinzeisler.com)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'visualize_ruby'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install visualize_ruby\n    \n### Install GraphViz\n\n MacOS\n\n    $ brew install graphviz\n    \n Linux\n    \n    $ sudo apt-get install graphviz\n\n## Usage\n\n### Create a graph by statically parsing the code. \n\n```ruby\nrequire \"visualize_ruby\"\n\nruby_code = \u003c\u003c~RUBY\n  if hungry?\n    eat\n  else\n    work\n  end\nRUBY\n\nresults = VisualizeRuby::Builder.new(ruby_code: ruby_code).build\nVisualizeRuby::Graphviz.new(results).to_graph(path: \"example.png\")\n```\n[![graph](./spec/examples/base_method.png)](./spec/examples/base_method.png)\n### Add an execution path to graph\n```ruby\nrequire \"visualize_ruby\"\n\nruby_code = \u003c\u003c~RUBY\n  class Worker\n    def initialize(hungry:)\n      @hungry = hungry\n    end\n\n    def next_action\n      if hungry?\n        :eat\n      else\n        :work\n      end\n    end\n\n    def hungry?\n      @hungry\n    end\n  end\nRUBY\n\ncalling_code = \u003c\u003c~RUBY\n  Worker.new(hungry: true).next_action\nRUBY\n\nVisualizeRuby.new do |vb|\n  vb.ruby_code = ruby_code # String, File, Pathname\n  vb.trace(calling_code)  # String, File, Pathname, Proc - optional\n  vb.output_path = \"runner_trace.png\" # file name with media extension.\nend\n```\n[![graph](./spec/examples/runner_trace.png)](./spec/examples/runner_trace.png)\n\n### Visualize Loops\nAdds a count if the node is called more than once.\n\n```ruby\nrequire \"visualize_ruby\"\n\nruby_code = \u003c\u003c~RUBY\n  class Looping\n    def call\n      (0..5).each do\n        paint_town!\n      end\n    end\n\n    def paint_town!\n      \"hello\"\n    end\n  end\nRUBY\n\nVisualizeRuby.new do |vb|\n  vb.ruby_code = ruby_code # String, File, Pathname\n  vb.trace do\n    Looping.new.call\n  end\n  vb.output_path = \"loop.png\" # file name with media extension.\n  # in_line_local_method_calls = true # default, in line method body when calling methods on self. Looks better when tracing execution.\n  # only_graphs = [\"call\"] # When a graph has many sub-graphs only include listed.\n  # unique_nodes = true # default, Duplicate nodes with the same description are merged to point single node.\nend\n```\n\n[![graph](./spec/examples/highlight_tracer_loop.png)](./spec/examples/highlight_tracer_loop.png)\n\n### Complex unrefactored code example\n[Gilded Rose](https://github.com/amckinnell/Gilded-Rose-Ruby)\n\n[![graph](./spec/examples/highlight_tracer.png)](./spec/examples/gilded_rose.png)\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/zeisler/visualize_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby","ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeisler%2Fvisualize_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeisler%2Fvisualize_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeisler%2Fvisualize_ruby/lists"}