Class: Cask::Cmd::Style Private

Inherits:
AbstractCommand show all
Defined in:
Library/Homebrew/cask/cmd/style.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Implementation of the brew cask style command.

Constant Summary

Constants inherited from AbstractCommand

AbstractCommand::OPTIONS

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

abstract?, banner_args, banner_headline, command_name, help, #initialize, max_named, min_named, run, short_description, visible?

Methods included from Homebrew::Search

#query_regexp, #search_casks, #search_descriptions, #search_formulae, #search_taps

Constructor Details

This class inherits a constructor from Cask::Cmd::AbstractCommand

Class Method Details

.descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


13
14
15
# File 'Library/Homebrew/cask/cmd/style.rb', line 13

def self.description
  "Checks style of the given <cask> using RuboCop."
end

.parserObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


17
18
19
20
21
22
# File 'Library/Homebrew/cask/cmd/style.rb', line 17

def self.parser
  super do
    switch "--fix",
           description: "Fix style violations automatically using RuboCop's auto-correct feature."
  end
end

Instance Method Details

#cask_pathsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


34
35
36
37
38
39
40
41
42
# File 'Library/Homebrew/cask/cmd/style.rb', line 34

def cask_paths
  @cask_paths ||= if args.named.empty?
    Tap.map(&:cask_dir).select(&:directory?)
  elsif args.named.any? { |file| File.exist?(file) }
    args.named.map { |path| Pathname(path).expand_path }
  else
    casks.map(&:sourcefile_path)
  end
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:


24
25
26
27
28
29
30
31
32
# File 'Library/Homebrew/cask/cmd/style.rb', line 24

def run
  success = Homebrew::Style.check_style_and_print(
    cask_paths,
    fix:     args.fix?,
    debug:   args.debug?,
    verbose: args.verbose?,
  )
  raise CaskError, "Style check failed." unless success
end