Class: Modulr::DependencyGraph
- Inherits:
-
Object
- Object
- Modulr::DependencyGraph
- Defined in:
- lib/modulr/dependency_graph.rb
Instance Method Summary collapse
-
#initialize(js_modules) ⇒ DependencyGraph
constructor
A new instance of DependencyGraph.
- #to_list ⇒ Object
- #to_tree ⇒ Object
- #to_yuml(options = {}) ⇒ Object
Constructor Details
#initialize(js_modules) ⇒ DependencyGraph
4 5 6 7 8 9 10 |
# File 'lib/modulr/dependency_graph.rb', line 4 def initialize(js_modules) if js_modules.is_a?(Array) @js_modules = js_modules else @js_modules = [js_modules] end end |
Instance Method Details
#to_list ⇒ Object
20 21 22 23 24 25 |
# File 'lib/modulr/dependency_graph.rb', line 20 def to_list return @list if @list @list = {} @js_modules.each { |m| build_list(m) } @list end |
#to_tree ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/modulr/dependency_graph.rb', line 12 def to_tree return @tree if @tree @tree = {} @stack = [] build_branch(@js_modules, @tree) @tree end |
#to_yuml(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/modulr/dependency_graph.rb', line 27 def to_yuml( = {}) = { :ext => 'png', :dir => 'lr', :scale => 100, :scruffy => true }.merge() dep = @js_modules.map { |m| "[#{m.id}]" } to_list.map do |k, v| if v v.each do |i| if @list[i] dep << "[#{k}]->[#{i}]" else dep << "[#{k}]-.-Missing>[#{i}{bg:red}]" end end end end opts = [] opts << "scruffy" if [:scruffy] opts << "dir:#{options[:dir]}" opts << "scale:#{options[:scale]}" uri = "http://yuml.me/diagram/" uri << opts.join(';') uri << "/class/" uri << dep.join(',') uri << ".#{options[:ext]}" URI.encode(uri).gsub('[', '%5B').gsub(']', '%5D') end |