Class: Reviewer::Setup::Generator
- Inherits:
-
Object
- Object
- Reviewer::Setup::Generator
- Defined in:
- lib/reviewer/setup/generator.rb
Overview
Produces .reviewer.yml YAML content from a list of detected tool keys. Orchestrates which tools to include; delegates per-tool rendering to ToolBlock.
Instance Attribute Summary collapse
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
-
#tool_keys ⇒ Object
readonly
Returns the value of attribute tool_keys.
Instance Method Summary collapse
-
#generate ⇒ String
Generates YAML configuration string for the detected tools.
-
#initialize(tool_keys, project_dir: Pathname.pwd) ⇒ Generator
constructor
Creates a generator for producing .reviewer.yml configuration.
Constructor Details
#initialize(tool_keys, project_dir: Pathname.pwd) ⇒ Generator
Creates a generator for producing .reviewer.yml configuration
19 20 21 22 |
# File 'lib/reviewer/setup/generator.rb', line 19 def initialize(tool_keys, project_dir: Pathname.pwd) @tool_keys = tool_keys @project_dir = Pathname(project_dir) end |
Instance Attribute Details
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
12 13 14 |
# File 'lib/reviewer/setup/generator.rb', line 12 def project_dir @project_dir end |
#tool_keys ⇒ Object (readonly)
Returns the value of attribute tool_keys.
12 13 14 |
# File 'lib/reviewer/setup/generator.rb', line 12 def tool_keys @tool_keys end |
Instance Method Details
#generate ⇒ String
Generates YAML configuration string for the detected tools
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/reviewer/setup/generator.rb', line 27 def generate return "--- {}\n" if tool_keys.empty? blocks = tool_keys.filter_map do |key| definition = Catalog.config_for(key) next unless definition ToolBlock.new(key, definition, js_runner: js_runner).to_s end "---\n#{blocks.join("\n")}" end |