Class | YARD::Verifier
In: | lib/yard/verifier.rb
Parent: | Object

Similar to a Proc, but runs a set of Ruby expressions using a small DSL to make tag lookups easier.

The syntax is as follows:

- All syntax is Ruby compatible
- `object` (`o` for short) exist to access the object being verified
- +@TAGNAME+ is translated into +object.tag(‘TAGNAME’)+
- +@@TAGNAME+ is translated into +object.tags(‘TAGNAME’)+
- `object` can be omitted as target for method calls (it is implied)

@example Create a verifier to check for objects that don‘t have @private tags

      verifier = Verifier.new('!@private')
      verifier.call(object) # => true (no @private tag)

@example Create a verifier to find any return tag with an empty description

      Verifier.new('@return.text.empty?')
      # Equivalent to:
      Verifier.new('object.tag(:return).text.empty?')

@example Check if there are any @param tags

      Verifier.new('@@param.empty?')
      # Equivalent to:
      Verifier.new('object.tags(:param).empty?')

@example Using `object` or `o` to look up object attributes directly

      Verifier.new('object.docstring == "hello world"')
      # Equivalent to:
      Verifier.new('o.docstring == "hello world"')

@example Without using `object` or `o`

      Verifier.new('tag(:return).size == 1 || has_tag?(:author)')

@example Specifying multiple expressions

      Verifier.new('@return', '@param', '@yield')
      # Equivalent to:
      Verifier.new('@return && @param && @yield')

### Methods

add_expressions call expressions= method_missing new run

### Constants

NILCLASS_METHODS | = | [:type, :method_missing] |  | @private

### External Aliases

object | -> | o

### Attributes

expressions | [R] | @return [Array<String>] a list of all expressions the verifier checks for @since 0.5.6
object | [R] | @return [CodeObjects::Base] the current object being tested

### Public Class methods

new(*expressions)

Creates a verifier from a set of expressions

@param [Array<String>] expressions a list of Ruby expressions to

      parse.

### Public Instance methods

add_expressions(*expressions)

Adds a set of expressions and recompiles the verifier

@param [Array<String>] expressions a list of expressions @return [void] @since 0.5.6

call(object)

Tests the expressions on the object.

@note If the object is a {CodeObjects::Proxy} the result will always be true. @param [CodeObjects::Base] object the object to verify @return [Boolean] the result of the expressions

expressions=(value)
method_missing(sym, *args, &block)

Passes any method calls to the object from the {call}

run(list)

Runs a list of objects against the verifier and returns the subset of verified objects.

@param [Array<CodeObjects::Base>] list a list of code objects @return [Array<CodeObjects::Base>] a list of code objects that match

      the verifier.

[Validate]