Skip to content

Commit

Permalink
Update templates to use Addressable::URI
Browse files Browse the repository at this point in the history
  • Loading branch information
fotos committed Jun 5, 2022
1 parent 9ac2b25 commit eb2585d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/resources/ruby-client/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require 'json'
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
require 'addressable/uri'

module {{moduleName}}
module API
Expand Down Expand Up @@ -56,7 +56,7 @@ module {{moduleName}}
:message => response.return_message)
else
fail API::Error.new(:code => response.code,
:response_headers => response.headers,
:response_headers => response.headers.to_h,
:response_body => response.body),
response.status_message
end
Expand Down Expand Up @@ -264,7 +264,7 @@ module {{moduleName}}
def build_request_url(path)
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
URI.encode(@config.base_url + path)
Addressable::URI.encode(@config.base_url + path)
end

# Builds the HTTP request body
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/ruby-client/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{> api_info}}
=end

require 'uri'
require 'addressable/uri'

module {{moduleName}}
module API
Expand Down Expand Up @@ -168,7 +168,7 @@ module {{moduleName}}

def base_url
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
URI.encode(url)
Addressable::URI.encode(url)
end

# Gets API key (with prefix if set).
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ruby-client/gemspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
s.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.0'
end

0 comments on commit eb2585d

Please sign in to comment.