Class: Yard::Lint::ConfigGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/lint/config_generator.rb

Overview

Generates default .yard-lint.yml configuration file

Constant Summary collapse

TEMPLATES_DIR =

Path to templates directory

File.expand_path('templates', __dir__)

Class Method Summary collapse

Class Method Details

.generate(force: false, strict: false) ⇒ Boolean

Generate .yard-lint.yml file in current directory

Parameters:

  • force (Boolean) (defaults to: false)

    overwrite existing file if true

  • strict (Boolean) (defaults to: false)

    generate strict configuration (all errors, 100% coverage)

Returns:

  • (Boolean)

    true if file was created, false if already exists



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/yard/lint/config_generator.rb', line 14

def self.generate(force: false, strict: false)
  config_path = File.join(Dir.pwd, Config::DEFAULT_CONFIG_FILE)

  if File.exist?(config_path) && !force
    false
  else
    template_name = strict ? 'strict_config.yml' : 'default_config.yml'
    template_path = File.join(TEMPLATES_DIR, template_name)
    content = File.read(template_path)
    File.write(config_path, content)
    true
  end
end