Class: CodeQualia::Config
- Inherits:
-
Object
- Object
- CodeQualia::Config
- Defined in:
- lib/code_qualia/config.rb
Instance Attribute Summary collapse
-
#architectural_weights ⇒ Object
readonly
Returns the value of attribute architectural_weights.
-
#exclude_patterns ⇒ Object
readonly
Returns the value of attribute exclude_patterns.
-
#git_history_days ⇒ Object
readonly
Returns the value of attribute git_history_days.
-
#importance_weights ⇒ Object
readonly
Returns the value of attribute importance_weights.
-
#quality_weights ⇒ Object
readonly
Returns the value of attribute quality_weights.
Class Method Summary collapse
Instance Method Summary collapse
- #architectural_weight_for(file_path) ⇒ Object
- #excluded?(file_path) ⇒ Boolean
-
#initialize(data = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(data = {}) ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 15 |
# File 'lib/code_qualia/config.rb', line 9 def initialize(data = {}) @quality_weights = data['quality_weights'] || default_quality_weights @importance_weights = data['importance_weights'] || default_importance_weights @architectural_weights = (data['architectural_weights'] || default_architectural_weights) @exclude_patterns = data['exclude'] || default_exclude_patterns @git_history_days = data['git_history_days'] || 90 end |
Instance Attribute Details
#architectural_weights ⇒ Object (readonly)
Returns the value of attribute architectural_weights.
7 8 9 |
# File 'lib/code_qualia/config.rb', line 7 def architectural_weights @architectural_weights end |
#exclude_patterns ⇒ Object (readonly)
Returns the value of attribute exclude_patterns.
7 8 9 |
# File 'lib/code_qualia/config.rb', line 7 def exclude_patterns @exclude_patterns end |
#git_history_days ⇒ Object (readonly)
Returns the value of attribute git_history_days.
7 8 9 |
# File 'lib/code_qualia/config.rb', line 7 def git_history_days @git_history_days end |
#importance_weights ⇒ Object (readonly)
Returns the value of attribute importance_weights.
7 8 9 |
# File 'lib/code_qualia/config.rb', line 7 def importance_weights @importance_weights end |
#quality_weights ⇒ Object (readonly)
Returns the value of attribute quality_weights.
7 8 9 |
# File 'lib/code_qualia/config.rb', line 7 def quality_weights @quality_weights end |
Class Method Details
.load(file_path) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/code_qualia/config.rb', line 17 def self.load(file_path) return new unless File.exist?(file_path) data = YAML.load_file(file_path) new(data) rescue StandardError => e raise Error, "Failed to load config file: #{e.message}" end |
Instance Method Details
#architectural_weight_for(file_path) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/code_qualia/config.rb', line 26 def architectural_weight_for(file_path) @architectural_weights.each do |entry| return entry['weight'] if File.fnmatch(entry['path'], file_path, File::FNM_PATHNAME) end 1.0 end |
#excluded?(file_path) ⇒ Boolean
33 34 35 |
# File 'lib/code_qualia/config.rb', line 33 def excluded?(file_path) @exclude_patterns.any? { |pattern| File.fnmatch(pattern, file_path, File::FNM_PATHNAME) } end |