emanlib 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd662dbc1918087da06994da20c822e4e3697a07db7f5681602c26c46839ed07
4
- data.tar.gz: d1e82edbb74f7d2f60dbe906f5715cddc94a28639266107d713744517de52007
3
+ metadata.gz: ee96e53bdb664ace9bf896327991a0be3f16c216c3a9760ed521ef9a226ee3ad
4
+ data.tar.gz: 4a13f22c6e332f1d997b3ce3118f7a02b63508fc5e9a9e69d2ea89bd27487908
5
5
  SHA512:
6
- metadata.gz: 3b5a86384a130d687ef886a075b55d1d3ea892ccf656356df78cfee9c9949dbcdaa36691b92733506956b687c5af66baba8fcf6455e3176af3eaac7bdb80c181
7
- data.tar.gz: 67b7d61d4cf0ad053c3c8e9121c734fe5c03b8a899c17f2b5b08d5c181142f70a494008820fe365f772dbcebb468ea99d14d3d2e2e3d9ea7198ad9b8c9f59482
6
+ metadata.gz: af9f21316eefedbe9f2c465c1ea67ae9a9697e018da5e3b9dc35f6542fcba7a49f858940f64d13571e621caaa60cf614e6bb4746aca5a44c49fdc3eab6e2f45a
7
+ data.tar.gz: eabb3c4f8e251fa7ea41dd2ba97b52b7745257bfb27d68f8c8dd176dcae0bde4542df0af1ae810a0af66ecc800a107079d7f2581649be6e6ea433871c8e9e54b
data/lib/emanlib.rb CHANGED
@@ -4,5 +4,5 @@ require_relative "patch/lambda"
4
4
  require_relative "patch/let"
5
5
 
6
6
  module EmanLib
7
- VERSION = "0.1.2"
7
+ VERSION = "1.0.0"
8
8
  end
data/lib/patch/enum.rb CHANGED
@@ -1,4 +1,4 @@
1
- module EmanLib
1
+ module Kernel
2
2
  # The Enum module provides a factory method `[]` to dynamically create
3
3
  # simple, lightweight enum-like classes. These classes allow defining a set of
4
4
  # named constants with associated numeric values.
data/lib/patch/foobar.rb CHANGED
@@ -338,3 +338,28 @@ end
338
338
  class Hash
339
339
  alias flip invert
340
340
  end
341
+
342
+ module Kernel
343
+ # Executes the given block and "parries" any caught StandardError,
344
+ # re-raising it as the specified klass with an optional custom message.
345
+ #
346
+ # @param klass [Class<StandardError>] The error class to re-raise if an error occurs.
347
+ # @param message [String, nil] An optional custom error message.
348
+ # If nil, the original error's message is used.
349
+ # @raise [klass] Raises the specified klass with the appropriate message.
350
+ def parry(klass, message = nil)
351
+ begin
352
+ yield
353
+ rescue StandardError => e
354
+ final_message = message || e.message
355
+
356
+ if e.is_a?(klass) && message.nil?
357
+ raise e
358
+ else
359
+ new_error = klass.new(final_message)
360
+ new_error.set_backtrace(e.backtrace)
361
+ raise new_error
362
+ end
363
+ end
364
+ end
365
+ end
data/lib/patch/lambda.rb CHANGED
@@ -19,7 +19,7 @@ class Array
19
19
  end
20
20
  end
21
21
 
22
- module EmanLib
22
+ module Kernel
23
23
 
24
24
  # A Lambda object (`_`) is building block for anonymous functions.
25
25
  # For instance, (`_ + _`) represents f(x,y) = x + y
@@ -157,7 +157,9 @@ module EmanLib
157
157
  # [1, 2, 3].map(&_.succ) => [2, 3, 4]
158
158
  # [[1, 2], [3, 4]].map(&(_ + _).lift) => [3, 7]
159
159
  _ = Lambda.new
160
+ end
160
161
 
162
+ module EmanLib
161
163
  # Support for using a `_` as the second operand with operators.
162
164
  # WARN: This method WILL MODIFY the standard library classes.
163
165
  # In particular, the operators: `- * / % ** & | ^ << >> <=> == === != > < >= <=`
data/lib/patch/let.rb CHANGED
@@ -81,7 +81,7 @@ class String
81
81
  end
82
82
  end
83
83
 
84
- module EmanLib
84
+ module Kernel
85
85
  # A convenient shorthand for `Maplet.new.define!(...)`.
86
86
  #
87
87
  # @param args [Array<Hash, Array>] A list of Hashes or "hashy" Arrays.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emanlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - emanrdesu