0.0
No commit activity in last 3 years
No release in over 3 years
Library for checking parameters, return value, preconditions and postconditions with declarative syntax
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
~> 3.0
 Project Readme

NeuronCheck

Library for checking parameters, return value, preconditions and postconditions with declarative syntax.

Requirement

Ruby 2.0.0 or later

Example

require 'neuroncheck'

class Converter
  # Activate NeuronCheck on Converter class
  extend NeuronCheck

  # NeuronCheck check declaration block
  ndecl {
    # Arguments declaration (this method receives 3 arguments - 1st is String, 2nd is any object has #each method, and 3rd is Numeric or nil)
    args String, respondable(:each), [Numeric, nil]

    # Return value declaration (this method returns self)
    returns :self

    # Precondition check
    precond do
      assert{threshold >= 0}
    end
  }

  # Actual method definition
  def convert(text, keywords, threshold = nil)
    # (main process)
  end
end

conv = Converter.new
conv.convert(100, ['Blog', 'Learning'], 0.5)

# => main.rb:28:in `<main>': 1st argument `text' of `Converter#convert' must be String, but was 100 (NeuronCheckError)
#            got: 100
#      signature: Converter#convert(text:String, keywords:respondable(:each), threshold:[Numeric, nil]) -> self
#    declared at: main.rb:10:in `block in <class:Converter>'

Documents and more information

http://ruby.morphball.net/neuroncheck/en/