Class: Yard::Lint::Validators::Base
- Inherits:
-
Object
- Object
- Yard::Lint::Validators::Base
- Defined in:
- lib/yard/lint/validators/base.rb
Overview
Base YARD validator class
Direct Known Subclasses
Documentation::UndocumentedBooleanMethods::Validator, Documentation::UndocumentedMethodArguments::Validator, Documentation::UndocumentedObjects::Validator, Semantic::AbstractMethods::Validator, Tags::ApiTags::Validator, Tags::InvalidTypes::Validator, Tags::OptionTags::Validator, Tags::Order::Validator, Warnings::DuplicatedParameterName::Validator, Warnings::InvalidDirectiveFormat::Validator, Warnings::InvalidTagFormat::Validator, Warnings::UnknownDirective::Validator, Warnings::UnknownParameterName::Validator, Warnings::UnknownTag::Validator
Constant Summary collapse
- DEFAULT_OPTIONS =
Default YARD command options that we need to use
[ '--charset utf-8', '--markup markdown', '--no-progress' ].freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#selection ⇒ Object
readonly
Returns the value of attribute selection.
Class Method Summary collapse
-
.clear_yard_database! ⇒ void
Clear the YARD database (primarily for testing).
-
.command_cache ⇒ CommandCache
Lazy-initialized command cache shared across all validator instances This allows different validators to reuse results from identical YARD commands.
-
.reset_command_cache! ⇒ void
Reset the command cache (primarily for testing).
Instance Method Summary collapse
-
#call ⇒ Hash
Performs the validation and returns raw results.
-
#initialize(config, selection) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(config, selection) ⇒ Base
Returns a new instance of Base.
56 57 58 59 |
# File 'lib/yard/lint/validators/base.rb', line 56 def initialize(config, selection) @config = config @selection = selection end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/yard/lint/validators/base.rb', line 27 def config @config end |
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
27 28 29 |
# File 'lib/yard/lint/validators/base.rb', line 27 def selection @selection end |
Class Method Details
.clear_yard_database! ⇒ void
This method returns an undefined value.
Clear the YARD database (primarily for testing)
47 48 49 50 51 |
# File 'lib/yard/lint/validators/base.rb', line 47 def clear_yard_database! return unless defined?(YARDOC_TEMP_DIR) FileUtils.rm_rf(Dir.glob(File.join(YARDOC_TEMP_DIR, '*'))) end |
.command_cache ⇒ CommandCache
Lazy-initialized command cache shared across all validator instances This allows different validators to reuse results from identical YARD commands
33 34 35 36 37 |
# File 'lib/yard/lint/validators/base.rb', line 33 def command_cache # Use Base's cache, not subclass's cache Base.instance_variable_get(:@shared_command_cache) || Base.instance_variable_set(:@shared_command_cache, CommandCache.new) end |
.reset_command_cache! ⇒ void
This method returns an undefined value.
Reset the command cache (primarily for testing)
41 42 43 |
# File 'lib/yard/lint/validators/base.rb', line 41 def reset_command_cache! Base.instance_variable_set(:@shared_command_cache, nil) end |
Instance Method Details
#call ⇒ Hash
Performs the validation and returns raw results
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/yard/lint/validators/base.rb', line 63 def call # There might be a case when there were no files because someone ignored all # then we need to return empty result return raw if selection.nil? || selection.empty? # Anything that goes to shell needs to be escaped escaped_file_names = escape(selection).join(' ') yard_cmd(YARDOC_TEMP_DIR, escaped_file_names) end |