Debian Codegraph @

lib/bundler/cli/viz.rb

raw
1 # frozen_string_literal: true
2
3 module Bundler
4 class CLI::Viz
5 attr_reader :options, :gem_name
6 def initialize(options)
7 @options = options
8 end
9
10 def run
11 # make sure we get the right `graphviz`. There is also a `graphviz`
12 # gem we're not built to support
13 gem "ruby-graphviz"
14 require "graphviz"
15
16 options[:without] = options[:without].join(":").tr(" ", ":").split(":")
17 output_file = File.expand_path(options[:file])
18
19 graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format], options[:without])
20 graph.viz
21 rescue LoadError => e
22 Bundler.ui.error e.inspect
23 Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
24 Bundler.ui.warn "`gem install ruby-graphviz`"
25 rescue StandardError => e
26 raise unless e.message.to_s.include?("GraphViz not installed or dot not in PATH")
27 Bundler.ui.error e.message
28 Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`."
29 end
30 end
31 end