Module: DepsGrapher::Visualizer::Registry

Defined in:
lib/deps_grapher/visualizer/registry.rb

Class Method Summary collapse

Class Method Details

.available_visualizersObject



15
16
17
# File 'lib/deps_grapher/visualizer/registry.rb', line 15

def available_visualizers
  command_options.map(&:to_s)
end

.default_visualizerObject



11
12
13
# File 'lib/deps_grapher/visualizer/registry.rb', line 11

def default_visualizer
  command_options.find(&:default?).to_s
end

.fetch(key) ⇒ Object



7
8
9
# File 'lib/deps_grapher/visualizer/registry.rb', line 7

def fetch(key)
  registry.fetch(key).first
end

.register(klass, command_option) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
# File 'lib/deps_grapher/visualizer/registry.rb', line 19

def register(klass, command_option)
  raise ArgumentError, "visualizer: `#{klass}` must be a subclass of `DepsGrapher::Visualizer::Base`" unless klass.ancestors.include?(Visualizer::Base)

  registry[command_option.name] = [klass, command_option]
end