Skip to content

Commit

Permalink
remove erubis dependency
Browse files Browse the repository at this point in the history
result_with_hash became available in ruby 2.5.0
  • Loading branch information
jjb committed Oct 12, 2021
1 parent 45987f2 commit 7bbfe8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion heroics.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
spec.summary = 'A Ruby client generator for HTTP APIs described with a JSON schema'
spec.homepage = 'https://github.com/interagent/heroics'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.5.0'

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|example)/}) }
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
Expand All @@ -27,7 +28,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'
Expand Down
2 changes: 1 addition & 1 deletion lib/heroics.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'base64'
require 'erubis'
require 'erb'
require 'excon'
require 'multi_json'
require 'uri'
Expand Down
4 changes: 2 additions & 2 deletions lib/heroics/client_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ 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)
eruby.result_with_hash(context)
end

private
Expand Down
16 changes: 8 additions & 8 deletions lib/heroics/views/client.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require 'heroics'
require 'uri'
require 'moneta'

module <%= @module_name %>
module <%= module_name %>
# Get a Client configured to use HTTP Basic or header-based authentication.
#
# @param api_key [String] The API key to use when connecting.
Expand Down Expand Up @@ -75,29 +75,29 @@ module <%= @module_name %>
if options[:default_headers]
final_options[:default_headers].merge!(options[:default_headers])
end
final_options[:cache] = options[:cache] || <%= @cache %>
final_options[:cache] = options[:cache] || <%= cache %>
final_options[:url] = options[:url] if options[:url]
final_options[:user] = options[:user] if options[:user]
final_options
end

# Get the default options.
def self.default_options
default_headers = <%= @default_headers %>
default_headers = <%= default_headers %>
{
default_headers: default_headers,
url: "<%= @url %>"
url: "<%= url %>"
}
end

private_class_method :default_options, :custom_options

# <%= @description %>
# <%= description %>
class Client
def initialize(client)
@client = client
end
<% for resource in @resources %>
<% for resource in resources %>

# <%= resource.description %>
#
Expand All @@ -109,7 +109,7 @@ module <%= @module_name %>
end

private
<% for resource in @resources %>
<% for resource in resources %>

# <%= resource.description %>
class <%= resource.class_name %>
Expand All @@ -133,6 +133,6 @@ module <%= @module_name %>
<% end %>

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

0 comments on commit 7bbfe8e

Please sign in to comment.