Class: Danger::DangerSpecPostfix

Inherits:
Plugin
  • Object
show all
Defined in:
lib/spec_postfix/plugin.rb

Instance Method Summary collapse

Instance Method Details

#lint(include_path:, match:, message:, exclude_path: nil) ⇒ void

This method returns an undefined value.

Lints files (or directories) naming. Generates a ‘string` with warning.

Parameters:

  • files (Array<String>)

    A globbed string which should return the files that you want to lint, defaults to nil. if nil, modified and added files from the diff will be used.

  • include_path (Regexp)

    Scope of check

  • match (Regexp)

    Pattern to match

  • message (String)

    Warn message

  • exclude_path (Regexp) (defaults to: nil)

    Not required. In case you want to have some directories or files exceptions.



17
18
19
20
21
# File 'lib/spec_postfix/plugin.rb', line 17

def lint(include_path:, match:, message:, exclude_path: nil)
  wrong_files = changed_files.select { |f| f.match?(include_path) }.reject { |f| f.match?(match) }
  wrong_files = wrong_files.reject { |f| f.match?(exclude_path) } if exclude_path
  wrong_files.each { |f| warn("#{message}: #{f}") }
end