Skip to content

Commit

Permalink
soft-require typhoeus (#1486)
Browse files Browse the repository at this point in the history
resolves #453
  • Loading branch information
svix-gabriel authored Oct 17, 2024
2 parents be5e3c4 + 5f43eea commit 6c1525a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 0 additions & 6 deletions ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ PATH
remote: .
specs:
svix (1.38.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.4.4)
ethon (0.14.0)
ffi (>= 1.38.0)
ffi (1.15.1)
rake (13.0.6)
rspec (3.10.0)
rspec-core (~> 3.10.0)
Expand All @@ -25,8 +21,6 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
typhoeus (1.4.0)
ethon (>= 0.9.0)

PLATFORMS
ruby
Expand Down
9 changes: 8 additions & 1 deletion ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ Add this line to your application's Gemfile:
gem 'svix'
```

If you are using svix to send outgoing webhhooks, you should also install the `typhoeus` gem.
If you are only using svix to consume incoming webhooks, you do not need it.

```ruby
gem 'typhoeus`
```
And then execute:
```sh
Expand All @@ -69,7 +76,7 @@ First checkout the [core README](../README.md#development) for details on how to
## Building
```sh
bundler exec rake build
bundle exec rake build
```
## Contributing
Expand Down
13 changes: 11 additions & 2 deletions ruby/svix.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ Gem::Specification.new do |spec|
"Learn more at https://www.svix.com"
spec.homepage = "https://www.svix.com"

spec.post_install_message = <<~MESSAGE
Thank you for install svix!
If you are using svix to send outgoing webhhooks, you should also install the `typhoeus` gem.
If you are only using svix to consume incoming webhooks, you do not need it.
gem 'typhoeus`
MESSAGE

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
Expand Down Expand Up @@ -45,8 +56,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.2"
end
12 changes: 12 additions & 0 deletions ruby/templates/api_client_typhoeus_partial.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})

begin
require 'typhoeus'
rescue LoadError
raise <<~MESSAGE
To use svix for sending outgoing webhooks, you need to install the typheous gem.
Please add it to your Gemfile and then run `bundle install`:

gem 'typhoeus'
MESSAGE
end

url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase

Expand Down

0 comments on commit 6c1525a

Please sign in to comment.