Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dsl_evaluator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsl_evaluator

  • 0.3.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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:

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

Print Code Helper

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

The print_code method understands "polymorphic" arguments.

  1. If the caller line info is part of a standard ruby backtrace line. Example of this is in ufo helpers/ecr.rb
call_line = ufo_config_call_line
DslEvaluator.print_code(call_line)
  1. If the caller line info is custom. Example of this is in ufo erb/yaml.rb
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:

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.

FAQs

Package last updated on 22 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc