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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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