Module: Hashira::CLI::Needs
- Defined in:
- lib/hashira/cli/needs.rb
Constant Summary collapse
- DIAGRAMS =
%i[dot mermaid].freeze
Class Method Summary collapse
- .check(options) ⇒ Object
- .compacting(mode) ⇒ Object
- .drawing(mode, skip) ⇒ Object
- .focusing(mode) ⇒ Object
- .gate(fail_on, skip) ⇒ Object
- .owner(kind) ⇒ Object
- .shaping(options, mode) ⇒ Object
Class Method Details
.check(options) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/hashira/cli/needs.rb', line 10 def check() mode = .mode skip = .skip drawing(mode, skip) gate(.fail_on, skip) shaping(, mode) end |
.compacting(mode) ⇒ Object
29 30 31 |
# File 'lib/hashira/cli/needs.rb', line 29 def compacting(mode) raise(Hashira::Error, "--compact shapes JSON, but this run emits #{mode}") unless mode == :json end |
.drawing(mode, skip) ⇒ Object
33 34 35 36 |
# File 'lib/hashira/cli/needs.rb', line 33 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 |
.focusing(mode) ⇒ Object
23 24 25 26 27 |
# File 'lib/hashira/cli/needs.rb', line 23 def focusing(mode) raise(Hashira::Error, "--only narrows the findings, but --update-baseline records them all") if mode == :update return unless DIAGRAMS.include?(mode) raise(Hashira::Error, "--format #{mode} draws the coupling graph, which --only cannot narrow") end |
.gate(fail_on, skip) ⇒ Object
38 39 40 41 42 |
# File 'lib/hashira/cli/needs.rb', line 38 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
44 |
# File 'lib/hashira/cli/needs.rb', line 44 def owner(kind) = Hashira::CLI::FailOn.owner(kind) |
.shaping(options, mode) ⇒ Object
18 19 20 21 |
# File 'lib/hashira/cli/needs.rb', line 18 def shaping(, mode) compacting(mode) if .compact focusing(mode) unless .only.empty? end |