Class: PreCommit::ListEvaluator

Inherits:
Object
  • Object
show all
Includes:
Pluginator::Extensions::Conversions
Defined in:
lib/pre-commit/list_evaluator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ListEvaluator

Returns a new instance of ListEvaluator.


12
13
14
# File 'lib/pre-commit/list_evaluator.rb', line 12

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


10
11
12
# File 'lib/pre-commit/list_evaluator.rb', line 10

def config
  @config
end

Instance Method Details

#checks_configObject


35
36
37
# File 'lib/pre-commit/list_evaluator.rb', line 35

def checks_config
  get_combined_checks - get_arr_checks_remove
end

#checks_evaluated(type = :evaluated_names) ⇒ Object


39
40
41
42
43
# File 'lib/pre-commit/list_evaluator.rb', line 39

def checks_evaluated(type = :evaluated_names)
  PreCommit::PluginsList.new(get_combined_checks, get_arr_checks_remove) do |name|
    config.pluginator.find_check(name)
  end.send(type)
end

#listObject


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pre-commit/list_evaluator.rb', line 16

def list
  <<-DATA
Available providers: #{config.providers.list.join(" ")}
Available checks   : #{plugin_names.join(" ")}
Default   checks   : #{config.get_arr(:checks).join(" ")}
Enabled   checks   : #{checks_config.join(" ")}
Evaluated checks   : #{checks_evaluated.join(" ")}
Default   warnings : #{config.get_arr(:warnings).join(" ")}
Enabled   warnings : #{warnings_config.join(" ")}
Evaluated warnings : #{warnings_evaluated.join(" ")}
DATA
end

#pluginsObject


29
30
31
32
33
# File 'lib/pre-commit/list_evaluator.rb', line 29

def plugins
  list = config.pluginator['checks'].map{|plugin| [class2string(class2name(plugin)), plugin] }.sort
  separator = list.map{|name, plugin| name.length }.max
  list.map{ |name, plugin| format_plugin(name, separator, plugin) }.flatten
end

#warnings_configObject


45
46
47
# File 'lib/pre-commit/list_evaluator.rb', line 45

def warnings_config
  get_combined_warnings - get_arr_warnings_remove
end

#warnings_evaluated(type = :evaluated_names) ⇒ Object


49
50
51
52
53
# File 'lib/pre-commit/list_evaluator.rb', line 49

def warnings_evaluated(type = :evaluated_names)
  PreCommit::PluginsList.new(get_combined_warnings, get_arr_warnings_remove) do |name|
    config.pluginator.find_check(name)
  end.send(type)
end