Class: Ace::Review::Models::Reviewer
- Inherits:
-
Object
- Object
- Ace::Review::Models::Reviewer
- Defined in:
- lib/ace/review/models/reviewer.rb
Overview
Represents a configured reviewer entity with focus areas and filtering capabilities.
Reviewers are configured entities that transform from simple model names to full-featured review participants with focus areas, file filtering, and weighted contributions.
Constant Summary collapse
- DEFAULT_WEIGHT =
Default weight for reviewers (1.0 = full contribution)
1.0
Instance Attribute Summary collapse
-
#critical ⇒ Object
readonly
Returns the value of attribute critical.
-
#file_patterns ⇒ Object
readonly
Returns the value of attribute file_patterns.
-
#focus ⇒ Object
readonly
Returns the value of attribute focus.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#system_prompt_additions ⇒ Object
readonly
Returns the value of attribute system_prompt_additions.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Class Method Summary collapse
-
.from_preset_config(config) ⇒ Array<Reviewer>
Create Reviewers from preset config (new reviewers array format).
-
.normalize_hash_keys(hash) ⇒ Object
Class method for key normalization.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Check equality with another reviewer.
-
#enhance_system_prompt(base_prompt) ⇒ String
Enhance system prompt with reviewer’s additions.
-
#filter_subject(subject) ⇒ Hash
Filter subject content based on reviewer’s file patterns.
-
#has_file_patterns? ⇒ Boolean
Check if this reviewer has file patterns configured.
-
#hash ⇒ Integer
Hash code for use in hash tables.
-
#initialize(config = {}) ⇒ Reviewer
constructor
Initialize a new Reviewer from a configuration hash.
-
#matches_file?(file_path) ⇒ Boolean
Check if a file path matches this reviewer’s patterns.
-
#to_h ⇒ Hash
Convert to hash representation.
Constructor Details
#initialize(config = {}) ⇒ Reviewer
Initialize a new Reviewer from a configuration hash
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ace/review/models/reviewer.rb', line 40 def initialize(config = {}) # Support both symbol and string keys config = normalize_keys(config) @name = config["name"] @model = config["model"] @focus = config["focus"] @system_prompt_additions = config["system_prompt_additions"] @file_patterns = normalize_file_patterns(config["file_patterns"]) @weight = (config["weight"] || DEFAULT_WEIGHT).to_f @critical = config["critical"] || false validate! end |
Instance Attribute Details
#critical ⇒ Object (readonly)
Returns the value of attribute critical.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def critical @critical end |
#file_patterns ⇒ Object (readonly)
Returns the value of attribute file_patterns.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def file_patterns @file_patterns end |
#focus ⇒ Object (readonly)
Returns the value of attribute focus.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def focus @focus end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def name @name end |
#system_prompt_additions ⇒ Object (readonly)
Returns the value of attribute system_prompt_additions.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def system_prompt_additions @system_prompt_additions end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
27 28 29 |
# File 'lib/ace/review/models/reviewer.rb', line 27 def weight @weight end |
Class Method Details
.from_preset_config(config) ⇒ Array<Reviewer>
Create Reviewers from preset config (new reviewers array format)
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ace/review/models/reviewer.rb', line 59 def self.from_preset_config(config) config = normalize_hash_keys(config) # New format: reviewers array if config["reviewers"].is_a?(Array) && config["reviewers"].any? return config["reviewers"].map { |r| new(r) } end [] end |
.normalize_hash_keys(hash) ⇒ Object
Class method for key normalization
163 164 165 166 |
# File 'lib/ace/review/models/reviewer.rb', line 163 def self.normalize_hash_keys(hash) return {} unless hash.is_a?(Hash) hash.transform_keys(&:to_s) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Check equality with another reviewer
129 130 131 132 133 134 135 136 137 |
# File 'lib/ace/review/models/reviewer.rb', line 129 def ==(other) return false unless other.is_a?(Reviewer) name == other.name && model == other.model && focus == other.focus && weight == other.weight && critical == other.critical end |
#enhance_system_prompt(base_prompt) ⇒ String
Enhance system prompt with reviewer’s additions
84 85 86 87 88 89 |
# File 'lib/ace/review/models/reviewer.rb', line 84 def enhance_system_prompt(base_prompt) return base_prompt unless system_prompt_additions return system_prompt_additions if base_prompt.nil? || base_prompt.empty? "#{base_prompt}\n\n#{system_prompt_additions}" end |
#filter_subject(subject) ⇒ Hash
Filter subject content based on reviewer’s file patterns
Delegates to SubjectFilter molecule for actual filtering logic.
76 77 78 |
# File 'lib/ace/review/models/reviewer.rb', line 76 def filter_subject(subject) Molecules::SubjectFilter.filter(subject, file_patterns) end |
#has_file_patterns? ⇒ Boolean
Check if this reviewer has file patterns configured
Delegates to SubjectFilter molecule.
96 97 98 |
# File 'lib/ace/review/models/reviewer.rb', line 96 def has_file_patterns? Molecules::SubjectFilter.has_patterns?(file_patterns) end |
#hash ⇒ Integer
Hash code for use in hash tables
144 145 146 |
# File 'lib/ace/review/models/reviewer.rb', line 144 def hash [name, model, focus, weight, critical].hash end |
#matches_file?(file_path) ⇒ Boolean
Check if a file path matches this reviewer’s patterns
Delegates to SubjectFilter molecule.
106 107 108 |
# File 'lib/ace/review/models/reviewer.rb', line 106 def matches_file?(file_path) Molecules::SubjectFilter.matches_file?(file_path, file_patterns) end |
#to_h ⇒ Hash
Convert to hash representation
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ace/review/models/reviewer.rb', line 113 def to_h { "name" => name, "model" => model, "focus" => focus, "system_prompt_additions" => system_prompt_additions, "file_patterns" => file_patterns, "weight" => weight, "critical" => critical }.compact end |