NeuronCheck 0.1.0 released (new library)

Hi.

I have released a new library -- "NeuronCheck"

It is the library for checking parameters, return value, preconditions and
postconditions with declarative syntax.

== Documents

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

== Introduction

NeuronCheck is a library for following 2 functions with declarative syntax.

  1. Checking method parameters and return value
  2. Checking pre-conditions and post-conditions

It has 2 features. First one is that it can be carried out various types of
checks with a simple description. The other one is that it can be introduced
with little adverse effect on the production environment performance.

In addition, in the form incorporated into other library, you can also use
only the check function part.

NeuronCheck has been made is inspired by Rubype gem and by Contract
Programming of the concept of Eiffel and D language. We aim to
"in the form of an executable document, describes the type information and
pre-conditions, so as to perform the check in accordance with its description"
thing.

== Example code

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>'

== Requirement

Ruby 2.0.0 or later

But, Some shorthand syntaxes is usable only in Ruby 2.1.0 or later. (because
it uses Refinement function)

== Install

% gem install neuroncheck

== Others

- NeuronCheck has just born. I want your comment, request, proposal or
  bug report. Please send E-mail or message from website or github issues
  page :slight_smile:

    Website: <http://ruby.morphball.net/neuroncheck/en/>
    Github project page: <https://github.com/tetradice/neuroncheck>

Happy hacking!

···

--
Dice (rubyist in japan)
Mail: tetradice@gmail.com
Twitter: @tetradice_ruby

I feel a little silly, but, I didn’t get what this gem does, is it a
type check ? as in make sure arg is Int and not String ?

Can't I just use is_a? Class for this ?

Also, from the name and syntax it looks like your GEM is using some

kind of Neuron Network technology, is it ? if so, why ?

Sorry for all the questions but everything that has to do with AI

interest me :slight_smile:

> 
> Hi.
> I have released a new library -- "NeuronCheck"
> It is the library for checking parameters, return value, preconditions and
> postconditions with declarative syntax.
> == Documents
> [http://ruby.morphball.net/neuroncheck/en/doc/](http://ruby.morphball.net/neuroncheck/en/doc/)
> 
> 
> 
> == Introduction
> NeuronCheck is a library for following 2 functions with declarative syntax.
> 1. Checking method parameters and return value
> 2. Checking pre-conditions and post-conditions
> It has 2 features. First one is that it can be carried out various types of
> checks with a simple description. The other one is that it can be introduced
> with little adverse effect on the production environment performance.
> In addition, in the form incorporated into other library, you can also use
> only the check function part.
> NeuronCheck has been made is inspired by Rubype gem and by Contract
> Programming of the concept of Eiffel and D language. We aim to
> "in the form of an executable document, describes the type information and
> pre-conditions, so as to perform the check in accordance with its description"
> thing.
> == Example code
> 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>'
> == Requirement
> Ruby 2.0.0 or later
> But, Some shorthand syntaxes is usable only in Ruby 2.1.0 or later. (because
> it uses Refinement function)
> == Install
> % gem install neuroncheck
> == Others
> - NeuronCheck has just born. I want your comment, request, proposal or
> bug report. Please send E-mail or message from website or github issues
> page :-)
> Website: [<http://ruby.morphball.net/neuroncheck/en/>](http://ruby.morphball.net/neuroncheck/en/)
>     Github project page: [<https://github.com/tetradice/neuroncheck>](https://github.com/tetradice/neuroncheck)
> 
> 
> 
> Happy hacking!
> --
> Dice (rubyist in japan)
> Mail: tetradice@gmail.com
> Twitter: @tetradice_ruby
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> [<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>](http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk)
···

On 03/14/2016 06:38 PM, Dice wrote:

Hi, Bar. thank for your comment.

I feel a little silly, but, I didn't get what this gem does, is it a type check ? as in make sure arg is Int and not String ?
Can't I just use is_a? Class for this ?

Sorry, my explanation might was difficult to understand because I
unfamiliar with English.

Yes, NeuronCheck perform a type check. this is one of main purposes.

Of course, you can use is_a? instead. But, I think that it is
troublesome. It is too verbose to write for each method.

without NeuronCheck:

   def convert(text, keywords, threshold = nil)
     raise ArgumentError, "argument `text` must be String" unless
text.is_a?(String)
     raise ArgumentError, "argument `keywords` must be respondable to
#each" unless keywords.respond_to?(:each)
     raise ArgumentError, "argument `threshold` must be Numeric or
nil" unless threshold.is_a?(Numeric) or threshold.nil?

     ... (main process) ...
   end

with NeuronCheck:

   ndecl {
     args String, respondable(:each), [Numeric, nil]
   }
   def convert(text, keywords, threshold = nil)
     ... (main process) ...
   end

with NeuronCheck shorthand syntax (only Ruby 2.1.0 or later):

   decl String, respondable(:each), [Numeric, nil]
   def convert(text, keywords, threshold = nil)
     ... (main process) ...
   end

In addition, there is an advantage that will other NeuronCheck also resulted.

- Type checkings of NeuronCheck are disabled all at once. (use
NeuronCheck.disable) Therefore, check processing does not
   affect the production environment performance.

- Error message becomes descriptive. (please refer to example code on
first mail)

If you don't think a good this thing and you have some proposal for
improvement, tell me the reason, please.

Also, from the name and syntax it looks like your GEM is using some kind of Neuron Network technology, is it ? if so, why ?

Sorry, NeuronCheck isn't using any Neuron Network technology. Was it
named NeuronCheck is because that the individual
declaration fulfill their role, cooperatively carry out the check.

···

--
Dice
tetradice@gmail.com

2016-03-15 1:45 GMT+09:00 Bar Hofesh <bar.hofesh@safe-t.com>:

I feel a little silly, but, I didn't get what this gem does, is it a type
check ? as in make sure arg is Int and not String ?
Can't I just use is_a? Class for this ?

Also, from the name and syntax it looks like your GEM is using some kind of
Neuron Network technology, is it ? if so, why ?

Sorry for all the questions but everything that has to do with AI interest
me :slight_smile:

On 03/14/2016 06:38 PM, Dice wrote:

Hi.

I have released a new library -- "NeuronCheck"

It is the library for checking parameters, return value, preconditions and
postconditions with declarative syntax.

== Documents

Documents | NeuronCheck

== Introduction

NeuronCheck is a library for following 2 functions with declarative syntax.

  1. Checking method parameters and return value
  2. Checking pre-conditions and post-conditions

It has 2 features. First one is that it can be carried out various types of
checks with a simple description. The other one is that it can be introduced
with little adverse effect on the production environment performance.

In addition, in the form incorporated into other library, you can also use
only the check function part.

NeuronCheck has been made is inspired by Rubype gem and by Contract
Programming of the concept of Eiffel and D language. We aim to
"in the form of an executable document, describes the type information and
pre-conditions, so as to perform the check in accordance with its
description"
thing.

== Example code

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>'

== Requirement

Ruby 2.0.0 or later

But, Some shorthand syntaxes is usable only in Ruby 2.1.0 or later.
(because
it uses Refinement function)

== Install

% gem install neuroncheck

== Others

- NeuronCheck has just born. I want your comment, request, proposal or
  bug report. Please send E-mail or message from website or github issues
  page :slight_smile:

    Website: <http://ruby.morphball.net/neuroncheck/en/&gt;
    Github project page: <https://github.com/tetradice/neuroncheck&gt;

Happy hacking!

--
Dice (rubyist in japan)
Mail: tetradice@gmail.com
Twitter: @tetradice_ruby

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;