Sha256: 16f4c3c594d4b303a18dbae8f70dedec8a4463a76cfb93efc5eb3900a678a9bb

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# DslEvaluator

Small module to help with DSL evaluation. Notably, it produces a human-friendly backtrace error showing the original user-provided source code if there's a syntax error.

## Usage

Example usage:

```ruby
DslEvaluator.configure do |config|
  config.backtrace.reject_pattern = "/lib/lono"
  config.logger = Lono.logger
  config.on_exception = :exit
  config.root = Lono.root
end

class Dsl
  include DslEvaluator
  def build
    path = "/path/to/user/provided/dsl/file.rb"
    evaluate_file(path) # from DslEvaluator module
  end
end
```

For other libraries where printing the code and context lines around the code is useful, you can use:

```ruby
path = "replace with path to file"
line_number = "replace with line number. usually can get the exception.message"
DslEvaluator.print_code(path, line_number)
```

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'dsl_evaluator'
```

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install dsl_evaluator

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tongueroo/dsl_evaluator.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dsl_evaluator-0.2.5 README.md