Commit 3765297e authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

task to generate graph of tags

parent f27faf60
......@@ -58,6 +58,8 @@ group :development do
# Github Page: https://github.com/voormedia/rails-erd
gem 'rails-erd'
gem 'ruby-graphviz'
# Manage the database application (use: localhost:3000/rails/db)
# Github Page: https://github.com/igorkasyanchuk/rails_db
#gem 'rails_db'
......
require 'graphviz'
namespace :graph do
desc 'Generate tags relation graph'
task generate_tags: :environment do
g = GraphViz.new(:G, :type => :graph )
LearningObject.all.each do |lo|
lo_node = g.add_nodes("lo:" + lo.id.to_s, label: lo.id.to_s)
lo.tags.each do |t|
pattern = /(\'|\"|\.|\*|\/|\-|\\)/
name = t.name.gsub(pattern,'')
t_node = g.add_nodes("tag:" + t.id.to_s, label: name)
g.add_edges(lo_node, t_node)
end
end
g.output( dot: "tags.dot" )
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment