Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove erubis dependency #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jjb
Copy link

@jjb jjb commented Oct 12, 2021

erubis hasn't been updated since 2011, and stdlib ERB is probably sufficient, so maybe it would be nice to remove this dependency.

AFAIK the template is not run often at runtime, so performance is not a concern. If it is, the erubi gem might be a good option. erubi would be preferable to erubis, because erubi is widely uses, including by rails.

tests pass with ruby 3, below. not sure if the test is comprehensive, maybe someone with some complicated use cases could stress test this as well.

result_with_hash became available in ruby 2.5, so i added that requirement. if we don't want to introduce that limitation, I also had a working version with this approach:

    context.each do |k, v|
      instance_variable_set(:"@#{k}", v)
    end
    eruby.result(binding)
➔ bundle exec rake
/Users/john/.rbenv/versions/3.0.2/bin/ruby -w -I"lib" -I test /Users/john/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb "test/cli_test.rb" "test/client_generator_test.rb" "test/client_test.rb" "test/command_test.rb" "test/configuration_test.rb" "test/heroics_test.rb" "test/link_test.rb" "test/naming_test.rb" "test/resource_test.rb" "test/schema_test.rb" "test/version_test.rb"
Run options: --seed 34138

# Running tests:

............/Users/john/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/moneta-1.4.2/lib/moneta/transformer.rb:359: warning: too many arguments for format string
.....................................................................................................

Finished tests in 0.024013s, 4705.7844 tests/s, 12076.7917 assertions/s.

113 tests, 290 assertions, 0 failures, 0 errors, 0 skips

result_with_hash became available in ruby 2.5.0
@kreintjes
Copy link

Nice. The less dependencies the better :)

@schneems could you maybe have a look at this? Heroics (through platform-api) is the only thing requiring erubis for a lot of our projects now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants