Class: Yardstick::Config
- Inherits:
-
Object
- Object
- Yardstick::Config
- Defined in:
- lib/yardstick/config.rb
Overview
Handles Yardstick configuration
Constant Summary collapse
- InvalidRule =
Class.new(StandardError)
- NAMESPACE_PREFIX =
'Yardstick::Rules::'.freeze
Instance Attribute Summary collapse
-
#output ⇒ Yardstick::ReportOutput
private
The path to the file where the measurements will be written.
-
#path ⇒ String
private
List of paths to measure.
-
#require_exact_threshold ⇒ undefined
writeonly
Specify if the threshold should match the coverage.
-
#threshold ⇒ Integer
private
Threshold value.
-
#verbose ⇒ undefined
writeonly
Specify if the coverage summary should be displayed.
Class Method Summary collapse
-
.coerce(hash) {|config| ... } ⇒ Config
private
Coerces hash into a config object.
-
.normalize_hash(hash) ⇒ Hash
private
Converts string keys into symbol keys.
Instance Method Summary collapse
-
#for_rule(rule_class) ⇒ RuleConfig
private
Return config for given rule.
-
#initialize(options = {}) {|config| ... } ⇒ Yardstick::Config
constructor
private
Initializes new config.
-
#require_exact_threshold? ⇒ Boolean
private
Return if the threshold should match the coverage.
-
#verbose? ⇒ Boolean
private
Specify if the coverage summary should be displayed.
Constructor Details
#initialize(options = {}) {|config| ... } ⇒ Yardstick::Config
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.
Initializes new config
101 102 103 104 105 |
# File 'lib/yardstick/config.rb', line 101 def initialize( = {}, &block) self.defaults = yield(self) if block_given? end |
Instance Attribute Details
#output ⇒ Yardstick::ReportOutput
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.
The path to the file where the measurements will be written
58 59 60 |
# File 'lib/yardstick/config.rb', line 58 def output @output end |
#path ⇒ String
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.
List of paths to measure
44 45 46 |
# File 'lib/yardstick/config.rb', line 44 def path @path end |
#require_exact_threshold=(value) ⇒ undefined (writeonly)
Specify if the threshold should match the coverage
30 31 32 |
# File 'lib/yardstick/config.rb', line 30 def require_exact_threshold=(value) @require_exact_threshold = value end |
#threshold ⇒ Integer
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.
Threshold value
23 24 25 |
# File 'lib/yardstick/config.rb', line 23 def threshold @threshold end |
#verbose=(value) ⇒ undefined (writeonly)
Specify if the coverage summary should be displayed
51 52 53 |
# File 'lib/yardstick/config.rb', line 51 def verbose=(value) @verbose = value end |
Class Method Details
.coerce(hash) {|config| ... } ⇒ Config
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.
Coerces hash into a config object
70 71 72 |
# File 'lib/yardstick/config.rb', line 70 def self.coerce(hash, &block) new(normalize_hash(hash), &block) end |
.normalize_hash(hash) ⇒ Hash
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.
Converts string keys into symbol keys
82 83 84 85 86 87 88 |
# File 'lib/yardstick/config.rb', line 82 def self.normalize_hash(hash) hash.reduce({}) do |normalized_hash, (key, value)| normalized_value = value.is_a?(Hash) ? normalize_hash(value) : value normalized_hash[key.to_sym] = normalized_value normalized_hash end end |
Instance Method Details
#for_rule(rule_class) ⇒ RuleConfig
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.
Return config for given rule
114 115 116 117 118 119 120 121 122 |
# File 'lib/yardstick/config.rb', line 114 def for_rule(rule_class) key = rule_class.to_s[NAMESPACE_PREFIX.length..-1] if key RuleConfig.new(@rules.fetch(key.to_sym, {})) else fail InvalidRule, "every rule must begin with #{NAMESPACE_PREFIX}" end end |
#require_exact_threshold? ⇒ Boolean
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.
Return if the threshold should match the coverage
138 139 140 |
# File 'lib/yardstick/config.rb', line 138 def require_exact_threshold? @require_exact_threshold end |
#verbose? ⇒ Boolean
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.
Specify if the coverage summary should be displayed
129 130 131 |
# File 'lib/yardstick/config.rb', line 129 def verbose? @verbose end |