<commit_before>= EOr

http://github.com/benweissmann/eor

By <NAME>, mailto:<EMAIL>

Adds Proc#eor, which takes an arbitrary number of procs and an optional backup value,
and returns the result of the first Proc that doesn't throw an error.

Procs recive as arguments all previous errors.

If all Procs throw errors, eor returns nil.

== Usage

See the spec folder for more in-depth examples.

=== Basics
  
  proc{ 'brevity' }.eor
  # => "brevity"
  
  proc { not_a_method }.eor
  # => nil

=== With Backup Values
  
  proc { not_a_method }.eor proc { 'is' }
  # => "is"

  proc { not_a_method }.eor do
    'the'
  end
  # => "the"
  
  proc { not_a_method }.eor 'soul'
  # => "soul"
  
  proc { not_a_method }.eor proc {10 / 0}
  # => nil

=== With Many Procs

  proc { not_a_method }.eor proc { 10 / 0 }, proc { system }, 'of'
  # => "of"
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { 'wit' }, proc { $foo = true }
  # => "wit"
  
  $foo # foo wasn't set by the previous line, becuase a successful proc was found first.
  # => nil 
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { '--Shakespeare' }, proc { " " }
  # => "--Shakespeare"
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }
  # => nil
  
=== Using the Previous Errors

  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|e| e}
  # => #<NameError: undefined local variable or method `not_a_method' for main:Object>
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|*errs| errs.last}
  # => #<ArgumentError: wrong number of arguments>
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|*errs| errs.inspect}
  # => "[#<NameError: undefined local variable or method `not_a_method' for main:Object>,
         #<ZeroDivisionError: divided by 0>,
         #<ArgumentError: wrong number of arguments>]"

== Contact

Questions, comment, suggestions, and flames can be sent to mailto:<EMAIL>

== Contribute

Have a patch? Email it to mailto:<EMAIL> or fork me and submit a pull request.

== Copyright

Copyright (c) 2010 <NAME>. See LICENSE for details.<commit_msg>Add installation instructions<commit_after>= EOr

http://github.com/benweissmann/eor

By <NAME>, mailto:<EMAIL>

Adds Proc#eor, which takes an arbitrary number of procs and an optional backup value,
and returns the result of the first Proc that doesn't throw an error.

Procs recive as arguments all previous errors.

If all Procs throw errors, eor returns nil.

== Usage

See the spec folder for more in-depth examples.

=== Basics
  
  proc{ 'brevity' }.eor
  # => "brevity"
  
  proc { not_a_method }.eor
  # => nil

=== With Backup Values
  
  proc { not_a_method }.eor proc { 'is' }
  # => "is"

  proc { not_a_method }.eor do
    'the'
  end
  # => "the"
  
  proc { not_a_method }.eor 'soul'
  # => "soul"
  
  proc { not_a_method }.eor proc {10 / 0}
  # => nil

=== With Many Procs

  proc { not_a_method }.eor proc { 10 / 0 }, proc { system }, 'of'
  # => "of"
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { 'wit' }, proc { $foo = true }
  # => "wit"
  
  $foo # foo wasn't set by the previous line, becuase a successful proc was found first.
  # => nil 
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { '--Shakespeare' }, proc { " " }
  # => "--Shakespeare"
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }
  # => nil
  
=== Using the Previous Errors

  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|e| e}
  # => #<NameError: undefined local variable or method `not_a_method' for main:Object>
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|*errs| errs.last}
  # => #<ArgumentError: wrong number of arguments>
  
  proc { not_a_method }.eor proc {10 / 0 }, proc { system }, proc {|*errs| errs.inspect}
  # => "[#<NameError: undefined local variable or method `not_a_method' for main:Object>,
         #<ZeroDivisionError: divided by 0>,
         #<ArgumentError: wrong number of arguments>]"

== Installing and Building

To install via RubyGems (from http://rubygems.org)

  gem install eor
  
To build the gem from these sources:

  rake build

To install the gem from these sources:

  rake install

== Contact

Questions, comment, suggestions, and flames can be sent to mailto:<EMAIL>

== Contribute

Have a patch? Email it to mailto:<EMAIL> or fork me and submit a pull request.

== Copyright

Copyright (c) 2010 <NAME>. See LICENSE for details.
{'fraction_non_alphanumeric': 0.1331527871812232, 'fraction_numerical': 0.013089596027984653, 'mean_word_length': 3.036429872495446, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6556062', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1533, 'n_words': 549}