Class: Koality::Options
- Inherits:
-
Object
- Object
- Koality::Options
- Extended by:
- Forwardable
- Defined in:
- lib/koality/options.rb
Constant Summary collapse
- DEFAULTS =
{ :abc_file_pattern => '{app,lib}/**/*.rb', :abc_threshold => 15, :abc_violations_threshold => 0, :abc_enabled => true, :style_file_pattern => '{app,lib,spec}/**/*.{rb,coffee,js}', :style_line_length_threshold => 120, :style_violations_threshold => 0, :style_enabled => true, :doc_file_pattern => '{app,lib}/**/*.rb', :doc_violations_threshold => 0, :doc_enabled => false, :code_coverage_threshold => 90, :code_coverage_file => 'code_coverage', :code_coverage_enabled => true, :rails_bp_accept_patterns => [], :rails_bp_ignore_patterns => [], :rails_bp_errors_threshold => 0, :rails_bp_error_file => 'rails_best_practices_errors', :rails_bp_enabled => true, :custom_thresholds => [], :total_violations_threshold => 0, :abort_on_failure => true, :output_directory => 'quality', :colorize_output => true }
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
-
#add_threshold(file, operator, value) ⇒ Object
Add a threshold check.
- #code_coverage_enabled? ⇒ Boolean
- #colorize_output? ⇒ Boolean
- #ensure_output_directory_exists ⇒ Object
-
#initialize(overrides = {}) ⇒ Options
constructor
A new instance of Options.
- #output_file(name) ⇒ Object
- #rails_bp_enabled? ⇒ Boolean
- #respond_to_missing?(method) ⇒ Boolean
- #runner_thresholds ⇒ Object
- #thresholds ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
92 93 94 95 96 97 98 99 100 |
# File 'lib/koality/options.rb', line 92 def method_missing(method, *args) if opt = writer?(method) opts[opt] = args.first elsif opt = reader?(method) opts[opt] else super end end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
41 42 43 |
# File 'lib/koality/options.rb', line 41 def opts @opts end |
Instance Method Details
#add_threshold(file, operator, value) ⇒ Object
Add a threshold check. If the file exists and it contains a number, compare that number with the given value using the operator.
51 52 53 |
# File 'lib/koality/options.rb', line 51 def add_threshold(file, operator, value) custom_thresholds << [operator, file, value] end |
#code_coverage_enabled? ⇒ Boolean
78 79 80 |
# File 'lib/koality/options.rb', line 78 def code_coverage_enabled? code_coverage_enabled end |
#colorize_output? ⇒ Boolean
82 83 84 |
# File 'lib/koality/options.rb', line 82 def colorize_output? colorize_output end |
#ensure_output_directory_exists ⇒ Object
66 67 68 |
# File 'lib/koality/options.rb', line 66 def ensure_output_directory_exists FileUtils.mkdir_p output_directory end |
#output_file(name) ⇒ Object
70 71 72 |
# File 'lib/koality/options.rb', line 70 def output_file(name) File.join(output_directory, opts[name]) end |
#rails_bp_enabled? ⇒ Boolean
74 75 76 |
# File 'lib/koality/options.rb', line 74 def rails_bp_enabled? defined?(Rails) && rails_bp_enabled end |
#respond_to_missing?(method) ⇒ Boolean
86 87 88 |
# File 'lib/koality/options.rb', line 86 def respond_to_missing?(method) writer?(method) || reader?(method) end |
#runner_thresholds ⇒ Object
59 60 61 62 63 64 |
# File 'lib/koality/options.rb', line 59 def runner_thresholds runners = [] runners << rails_bp_custom_threshold if rails_bp_enabled? runners << code_coverage_custom_threshold if code_coverage_enabled? runners end |
#thresholds ⇒ Object
55 56 57 |
# File 'lib/koality/options.rb', line 55 def thresholds custom_thresholds + runner_thresholds end |