Skip to content

Commit 7bbfe8e

Browse files
committed
remove erubis dependency
result_with_hash became available in ruby 2.5.0
1 parent 45987f2 commit 7bbfe8e

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

heroics.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
1414
spec.summary = 'A Ruby client generator for HTTP APIs described with a JSON schema'
1515
spec.homepage = 'https://github.com/interagent/heroics'
1616
spec.license = 'MIT'
17+
spec.required_ruby_version = '>= 2.5.0'
1718

1819
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|example)/}) }
1920
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -27,7 +28,6 @@ Gem::Specification.new do |spec|
2728
spec.add_development_dependency 'yard'
2829
spec.add_development_dependency 'pry'
2930

30-
spec.add_dependency 'erubis', '~> 2.0'
3131
spec.add_dependency 'excon'
3232
spec.add_dependency 'multi_json', '>= 1.9.2'
3333
spec.add_dependency 'moneta'

lib/heroics.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22
require 'base64'
3-
require 'erubis'
3+
require 'erb'
44
require 'excon'
55
require 'multi_json'
66
require 'uri'

lib/heroics/client_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ module Heroics
44
# option if you want to ship a gem or generate API documentation using Yard.
55
def self.generate_client
66
filename = File.dirname(__FILE__) + '/views/client.erb'
7-
eruby = Erubis::Eruby.new(File.read(filename))
7+
eruby = ERB.new(File.read(filename))
88
context = build_context(Heroics::Configuration.defaults.module_name,
99
Heroics::Configuration.defaults.schema,
1010
Heroics::Configuration.defaults.base_url,
1111
Heroics::Configuration.defaults.options)
12-
eruby.evaluate(context)
12+
eruby.result_with_hash(context)
1313
end
1414

1515
private

lib/heroics/views/client.erb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require 'heroics'
1111
require 'uri'
1212
require 'moneta'
1313

14-
module <%= @module_name %>
14+
module <%= module_name %>
1515
# Get a Client configured to use HTTP Basic or header-based authentication.
1616
#
1717
# @param api_key [String] The API key to use when connecting.
@@ -75,29 +75,29 @@ module <%= @module_name %>
7575
if options[:default_headers]
7676
final_options[:default_headers].merge!(options[:default_headers])
7777
end
78-
final_options[:cache] = options[:cache] || <%= @cache %>
78+
final_options[:cache] = options[:cache] || <%= cache %>
7979
final_options[:url] = options[:url] if options[:url]
8080
final_options[:user] = options[:user] if options[:user]
8181
final_options
8282
end
8383

8484
# Get the default options.
8585
def self.default_options
86-
default_headers = <%= @default_headers %>
86+
default_headers = <%= default_headers %>
8787
{
8888
default_headers: default_headers,
89-
url: "<%= @url %>"
89+
url: "<%= url %>"
9090
}
9191
end
9292

9393
private_class_method :default_options, :custom_options
9494

95-
# <%= @description %>
95+
# <%= description %>
9696
class Client
9797
def initialize(client)
9898
@client = client
9999
end
100-
<% for resource in @resources %>
100+
<% for resource in resources %>
101101

102102
# <%= resource.description %>
103103
#
@@ -109,7 +109,7 @@ module <%= @module_name %>
109109
end
110110

111111
private
112-
<% for resource in @resources %>
112+
<% for resource in resources %>
113113

114114
# <%= resource.description %>
115115
class <%= resource.class_name %>
@@ -133,6 +133,6 @@ module <%= @module_name %>
133133
<% end %>
134134

135135
SCHEMA = Heroics::Schema.new(MultiJson.load(<<-'HEROICS_SCHEMA'))
136-
<%= @schema %>
136+
<%= schema %>
137137
HEROICS_SCHEMA
138138
end

0 commit comments

Comments
 (0)