Project

exec_env

0.0
No commit activity in last 3 years
No release in over 3 years
See README.md
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.4
~> 10.1
>= 0
 Project Readme

ExecEnv

Execute blocks in a manipulatable environment and capture messages that did not get a response and would normally produce a NameError or NoMethodError. For example use cases of this have a look at anaphoric or hash_builder.

If you have another use case for this, please send me an email. I am really interested if there are other use cases for this quite exotic library.

Installation

Add this line to your application's Gemfile:

gem 'exec_env'

And then execute:

$ bundle

Or install it yourself as:

$ gem install exec_env

Usage

scope = [1, 2, 3, 4]

env = ExecEnv::Env.new(locals: { foo: 2 })
env.locals[:bar] = 3
env.scope = scope

result = env.exec do
  exotic :dragon, :banana
  action do
    :nested
  end

  size * foo * bar
end

# Because the block was executed in the scope of the array.
result # => 24 == 2 * 3 * 4

env.messages
# => [
# =>  [:exotic, [:dragon, :banana], nil],
# =>  [:action, [], <Proc ...>]
# => ]

Contributing

  1. Fork it ( http://github.com/CQQL/exec_env/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request