Class: Yard::Lint::ConfigUpdater
- Inherits:
-
Object
- Object
- Yard::Lint::ConfigUpdater
- Defined in:
- lib/yard/lint/config_updater.rb
Overview
Updates existing .yard-lint.yml configuration files Adds new validators, removes obsolete ones, preserves user settings
Constant Summary collapse
- TEMPLATES_DIR =
Path to templates directory
File.('templates', __dir__)
- CATEGORY_ORDER =
Category order for output
%w[Documentation Tags Warnings Semantic].freeze
- CATEGORY_COMMENTS =
Category comments for output
{ 'Documentation' => '# Documentation validators', 'Tags' => '# Tags validators', 'Warnings' => '# Warnings validators - catches YARD parser errors', 'Semantic' => '# Semantic validators' }.freeze
Class Method Summary collapse
-
.update(path: nil, strict: false) ⇒ Hash
Update an existing config file.
Instance Method Summary collapse
-
#initialize(path: nil, strict: false) ⇒ ConfigUpdater
constructor
A new instance of ConfigUpdater.
-
#update ⇒ Hash
Perform the config update.
Constructor Details
#initialize(path: nil, strict: false) ⇒ ConfigUpdater
Returns a new instance of ConfigUpdater.
34 35 36 37 |
# File 'lib/yard/lint/config_updater.rb', line 34 def initialize(path: nil, strict: false) @path = path || File.join(Dir.pwd, Config::DEFAULT_CONFIG_FILE) @strict = strict end |
Class Method Details
.update(path: nil, strict: false) ⇒ Hash
Update an existing config file
27 28 29 |
# File 'lib/yard/lint/config_updater.rb', line 27 def update(path: nil, strict: false) new(path: path, strict: strict).update end |
Instance Method Details
#update ⇒ Hash
Perform the config update
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/yard/lint/config_updater.rb', line 41 def update validate_file_exists! existing_config = load_existing_config template_config = load_template_config result = merge_configs(existing_config, template_config) write_updated_config(result[:config]) { added: result[:added], removed: result[:removed], preserved: result[:preserved] } end |