Skip to content

remove erubis dependency - #103

Closed
jjb wants to merge 1 commit into
interagent:mainfrom
jjb:remove-erubis-dependency
Closed

remove erubis dependency#103
jjb wants to merge 1 commit into
interagent:mainfrom
jjb:remove-erubis-dependency

Conversation

@jjb

@jjbjjb commented Oct 12, 2021

Copy link
Copy Markdown

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.eachdo |k,v|
instance_variable_set(:"@#{k}",v)enderuby.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
@jjb
jjbforce-pushed the remove-erubis-dependency branch from adddd75 to 7bbfe8eCompareOctober 12, 2021 22:06
@kreintjes

Copy link
Copy Markdown

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.

beanieboi pushed a commit that referenced this pull request Apr 22, 2026
@beanieboi

Copy link
Copy Markdown
Member

thank you for this :)
4ef086e

@schneems

Copy link
Copy Markdown
Collaborator

This change had cosmetic side effects. Apparently, ERB trims trailing whitespace but ERB does not

image

schneems added a commit to heroku/platform-api that referenced this pull request Jun 3, 2026
schneems added a commit to heroku/platform-api that referenced this pull request Jun 4, 2026
* Replace MultiJson.load with JSON.parse
heroics 0.1.4 dropped its multi_json dependency in favor of Ruby's
built-in json library. Since platform-api never declared multi_json as
a direct dependency, upgrading heroics causes:
NameError: uninitialized constant PlatformAPI::MultiJson
Replace the single MultiJson.load call with JSON.parse, which is
available from the standard library and requires no new dependencies.
Fixes#150
* Add CHANGELOG entry for MultiJson fix
* whitespace
Due to interagent/heroics#103
* Trim trailing whitespace
* v3.9.1
* Apply suggestions from code review
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Signed-off-by: Richard Schneeman <richard.schneeman+no-recruiters@gmail.com>
---------
Signed-off-by: Richard Schneeman <richard.schneeman+no-recruiters@gmail.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Sign up for freeto 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.

4 participants

@jjb@kreintjes@beanieboi@schneems