Skip to content

Commit

Permalink
Drop activesupport dependency
Browse files Browse the repository at this point in the history
ActiveSupport was being loaded to provide Object#try. It's a very large
dependency that can monkey patch many core classes, and although the
require in sinatra-contrib is targeted and doesn't load all of
ActiveSupport, once the gem is on the load path some other libraries
will opportunistically load more of it.

Object#try is only used twice, maybe it's ok to live with a manual check
for nil for now? sinatra-contrib currently requires ruby 2.2 or better -
once the minimum is lifted to 2.3, Object#try will be provided by ruby
core.
  • Loading branch information
yob committed Jun 15, 2018
1 parent 1b35eaa commit 7989a78
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 2 additions & 3 deletions sinatra-contrib/lib/sinatra/capture.rb
@@ -1,6 +1,5 @@
require 'sinatra/base'
require 'sinatra/engine_tracking'
require 'active_support/core_ext/object/try.rb'

module Sinatra
#
Expand Down Expand Up @@ -106,12 +105,12 @@ def capture(*args, &block)
dummy = DUMMIES.fetch(current_engine)
options = { :layout => false, :locals => {:args => args, :block => block }}

buffer.try :clear
buffer.clear unless buffer.nil?
result = render(current_engine, dummy, options, &block)
end
result.strip.empty? && @capture ? @capture : result
ensure
buffer.try :replace, old_buffer
buffer.replace(old_buffer) unless buffer.nil?
end

def capture_later(&block)
Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/sinatra-contrib.gemspec
Expand Up @@ -24,7 +24,6 @@ Gem::Specification.new do |s|
s.add_dependency "sinatra", version
s.add_dependency "mustermann", "~> 1.0"
s.add_dependency "backports", ">= 2.8.2"
s.add_dependency "activesupport", ">= 4.0.0"
s.add_dependency "tilt", ">= 1.3", "< 3"
s.add_dependency "rack-protection", version
s.add_dependency "multi_json"
Expand Down

0 comments on commit 7989a78

Please sign in to comment.