class YARD::Verifier

Verifier.new(‘@return && @param && @yield’)
# Equivalent to:
Verifier.new(‘@return’, ‘@param’, ‘@yield’)
@example Specifying multiple expressions
Verifier.new(‘tag(:return).size == 1 || has_tag?(:author)’)
@example Without using object or o
Verifier.new(‘o.docstring == “hello world”’)
# Equivalent to:
Verifier.new(‘object.docstring == “hello world”’)
@example Using object or o to look up object attributes directly
Verifier.new(‘object.tags(:param).empty?’)
# Equivalent to:
Verifier.new(‘@@param.empty?’)
@example Check if there are any @param tags
Verifier.new(‘object.tag(:return).text.empty?’)
# Equivalent to:
Verifier.new(‘@return.text.empty?’)
@example Create a verifier to find any return tag with an empty description
verifier.call(object) # => true (no @private tag)
verifier = Verifier.new(‘!@private’)
@example Create a verifier to check for objects that don’t have @private tags
* object can be omitted as target for method calls (it is implied)
* +@@TAGNAME+ is translated into +object.tags(‘TAGNAME’)+
* +@TAGNAME+ is translated into +object.tag(‘TAGNAME’)+
* object (o for short) exist to access the object being verified
* All syntax is Ruby compatible
The syntax is as follows:
DSL to make tag lookups easier.
Similar to a Proc, but runs a set of Ruby expressions using a small

def add_expressions(*expressions)

Other tags:
    Since: - 0.5.6

Returns:
  • (void) -

Parameters:
  • expressions (Array) -- a list of expressions
def add_expressions(*expressions)
  self.expressions += expressions.flatten
end

def call(object)

Returns:
  • (Boolean) - the result of the expressions

Parameters:
  • object (CodeObjects::Base) -- the object to verify

Other tags:
    Note: - If the object is a {CodeObjects::Proxy} the result will always be true.
def call(object)
  return true if object.is_a?(CodeObjects::Proxy)
  modify_nilclass
  @object = object
  retval = __execute ? true : false
  unmodify_nilclass
  retval
end

def create_method_from_expressions

Returns:
  • (void) -
def create_method_from_expressions
  expr = expressions.map {|e| "(#{parse_expression(e)})" }.join(" && ")
  instance_eval(<<-eof, __FILE__, __LINE__ + 1)
    begin; undef __execute; rescue NameError; end
    def __execute; #{expr}; end
  eof
end

def expressions=(value)

def expressions=(value)
  @expressions = value
  create_method_from_expressions
end

def initialize(*expressions)

Parameters:
  • expressions (Array) -- a list of Ruby expressions to
def initialize(*expressions)
  @expressions = []
  add_expressions(*expressions)
end

def method_missing(sym, *args, &block)

Passes any method calls to the object from the {#call}
def method_missing(sym, *args, &block)
  if object.respond_to?(sym)
    object.send(sym, *args, &block)
  else
    super
  end
end

def modify_nilclass

Returns:
  • (void) -
def modify_nilclass
  NILCLASS_METHODS.each do |meth|
    NilClass.send(:define_method, meth) {|*args| }
  end
end

def parse_expression(expr)

Returns:
  • (String) - the parsed expression
def parse_expression(expr)
  expr = expr.gsub(/@@(?:(\w+)|\{([\w\.]+)\})/, 'object.tags("\1\2")')
  expr = expr.gsub(/@(?:(\w+)|\{([\w\.]+)\})/, 'object.tag("\1\2")')
  expr
end

def run(list)

Returns:
  • (Array) - a list of code objects that match

Parameters:
  • list (Array) -- a list of code objects
def run(list)
  list.reject {|item| call(item).is_a?(FalseClass) }
end

def unmodify_nilclass

Returns:
  • (void) -
def unmodify_nilclass
  NILCLASS_METHODS.each do |meth|
    next unless nil.respond_to?(meth)
    NilClass.send(:remove_method, meth)
  end
end