Module: Hashira::CLI::Needs

Defined in:
lib/hashira/cli/needs.rb

Constant Summary collapse

DIAGRAMS =
%i[dot mermaid].freeze

Class Method Summary collapse

Class Method Details

.check(options) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/hashira/cli/needs.rb', line 10

def check(options)
  mode = options.mode
  skip = options.skip
  drawing(mode, skip)
  gate(options.fail_on, skip)
  shaping(mode) if options.compact
end

.drawing(mode, skip) ⇒ Object

Raises:



22
23
24
25
# File 'lib/hashira/cli/needs.rb', line 22

def drawing(mode, skip)
  return unless DIAGRAMS.include?(mode) && skip.include?(:coupling)
  raise(Hashira::Error, "--format #{mode} draws the coupling graph, but --skip coupling drops it")
end

.gate(fail_on, skip) ⇒ Object

Raises:



27
28
29
30
31
# File 'lib/hashira/cli/needs.rb', line 27

def gate(fail_on, skip)
  blind = fail_on.find { skip.include?(owner(it)) }
  return unless blind
  raise(Hashira::Error, "--fail-on #{blind} needs the #{owner(blind)} analyzer, but --skip drops it")
end

.owner(kind) ⇒ Object



33
# File 'lib/hashira/cli/needs.rb', line 33

def owner(kind) = Hashira::CLI::FailOn.owner(kind)

.shaping(mode) ⇒ Object

Raises:



18
19
20
# File 'lib/hashira/cli/needs.rb', line 18

def shaping(mode)
  raise(Hashira::Error, "--compact shapes JSON, but this run emits #{mode}") unless mode == :json
end