From adddd75d0e91ee222404a4ecc4b3d3ddfa82ec21 Mon Sep 17 00:00:00 2001 From: John Bachir Date: Tue, 12 Oct 2021 23:09:29 +0200 Subject: [PATCH] remove erubis dependency --- heroics.gemspec | 1 - lib/heroics.rb | 2 +- lib/heroics/client_generator.rb | 7 +++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/heroics.gemspec b/heroics.gemspec index 0549177..617b0e1 100644 --- a/heroics.gemspec +++ b/heroics.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'yard' spec.add_development_dependency 'pry' - spec.add_dependency 'erubis', '~> 2.0' spec.add_dependency 'excon' spec.add_dependency 'multi_json', '>= 1.9.2' spec.add_dependency 'moneta' diff --git a/lib/heroics.rb b/lib/heroics.rb index e9a4ac5..a001178 100644 --- a/lib/heroics.rb +++ b/lib/heroics.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true require 'base64' -require 'erubis' +require 'erb' require 'excon' require 'multi_json' require 'uri' diff --git a/lib/heroics/client_generator.rb b/lib/heroics/client_generator.rb index 1da1012..fc6d2a6 100644 --- a/lib/heroics/client_generator.rb +++ b/lib/heroics/client_generator.rb @@ -4,12 +4,15 @@ module Heroics # option if you want to ship a gem or generate API documentation using Yard. def self.generate_client filename = File.dirname(__FILE__) + '/views/client.erb' - eruby = Erubis::Eruby.new(File.read(filename)) + eruby = ERB.new(File.read(filename)) context = build_context(Heroics::Configuration.defaults.module_name, Heroics::Configuration.defaults.schema, Heroics::Configuration.defaults.base_url, Heroics::Configuration.defaults.options) - eruby.evaluate(context) + context.each do |k, v| + instance_variable_set(:"@#{k}", v) + end + eruby.result(binding) end private