Class: Goodcheck::Commands::Pattern
- Inherits:
-
Object
- Object
- Goodcheck::Commands::Pattern
- Includes:
- ConfigLoading, ExitStatus, HomePath
- Defined in:
- lib/goodcheck/commands/pattern.rb
Constant Summary
Constants included from ExitStatus
ExitStatus::EXIT_ERROR, ExitStatus::EXIT_MATCH, ExitStatus::EXIT_SUCCESS, ExitStatus::EXIT_TEST_FAILED
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#home_path ⇒ Object
readonly
Returns the value of attribute home_path.
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Attributes included from ConfigLoading
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, path:, ids:, home_path:) ⇒ Pattern
constructor
A new instance of Pattern.
- #run ⇒ Object
Methods included from HomePath
Methods included from ConfigLoading
#handle_config_errors, #load_config!
Constructor Details
#initialize(stdout:, stderr:, path:, ids:, home_path:) ⇒ Pattern
Returns a new instance of Pattern.
14 15 16 17 18 19 20 |
# File 'lib/goodcheck/commands/pattern.rb', line 14 def initialize(stdout:, stderr:, path:, ids:, home_path:) @stdout = stdout @stderr = stderr @config_path = path @ids = ids @home_path = home_path end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
6 7 8 |
# File 'lib/goodcheck/commands/pattern.rb', line 6 def config_path @config_path end |
#home_path ⇒ Object (readonly)
Returns the value of attribute home_path.
8 9 10 |
# File 'lib/goodcheck/commands/pattern.rb', line 8 def home_path @home_path end |
#ids ⇒ Object (readonly)
Returns the value of attribute ids.
7 8 9 |
# File 'lib/goodcheck/commands/pattern.rb', line 7 def ids @ids end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/goodcheck/commands/pattern.rb', line 5 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/goodcheck/commands/pattern.rb', line 4 def stdout @stdout end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/goodcheck/commands/pattern.rb', line 22 def run handle_config_errors stderr do load_config!(cache_path: cache_dir_path, force_download: true) config.rules.each do |rule| if ids.empty? || ids.any? {|pat| pat == rule.id || rule.id.start_with?("#{pat}.") } stdout.puts "#{rule.id}:" rule.triggers.each do |trigger| trigger.patterns.each do |pattern| stdout.puts " - #{pattern.regexp.inspect}" end end end end end EXIT_SUCCESS end |