Skip to content

Commit

Permalink
Merge pull request #1208 from mwpastore/contrib-deps
Browse files Browse the repository at this point in the history
Sinatra::Contrib dependency updates. Fixes #1207
  • Loading branch information
namusyaka authored Mar 18, 2018
2 parents 14f86a8 + 6417330 commit 045a05b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 31 deletions.
5 changes: 2 additions & 3 deletions sinatra-contrib/lib/sinatra/capture.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'sinatra/base'
require 'sinatra/engine_tracking'
require 'backports'

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 if buffer.respond_to?(:clear)
result = render(current_engine, dummy, options, &block)
end
result.strip.empty? && @capture ? @capture : result
ensure
buffer.try :replace, old_buffer
buffer.replace(old_buffer) if buffer.respond_to?(:replace)
end

def capture_later(&block)
Expand Down
32 changes: 16 additions & 16 deletions sinatra-contrib/lib/sinatra/contrib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ module Contrib
# or breaks if external dependencies are missing. Will extend
# Sinatra::Application by default.
module Common
register :ConfigFile
register :MultiRoute
register :Namespace
register :RespondWith
register :ConfigFile, 'sinatra/config_file'
register :MultiRoute, 'sinatra/multi_route'
register :Namespace, 'sinatra/namespace'
register :RespondWith, 'sinatra/respond_with'

helpers :Capture
helpers :ContentFor
helpers :Cookies
helpers :EngineTracking
helpers :JSON
helpers :LinkHeader
helpers :Streaming
helpers :RequiredParams
helpers :Capture, 'sinatra/capture'
helpers :ContentFor, 'sinatra/content_for'
helpers :Cookies, 'sinatra/cookies'
helpers :EngineTracking, 'sinatra/engine_tracking'
helpers :JSON, 'sinatra/json'
helpers :LinkHeader, 'sinatra/link_header'
helpers :Streaming, 'sinatra/streaming'
helpers :RequiredParams, 'sinatra/required_params'
end

##
# Other extensions you don't want to be loaded unless needed.
module Custom
# register :Compass
register :Reloader
# register :Compass, 'sinatra/compass'
register :Reloader, 'sinatra/reloader'
end

##
# Stuff that aren't Sinatra extensions, technically.
autoload :Extension
autoload :TestHelpers
autoload :Extension, 'sinatra/extension'
autoload :TestHelpers, 'sinatra/test_helpers'
end

register Sinatra::Contrib::Common
Expand Down
8 changes: 3 additions & 5 deletions sinatra-contrib/lib/sinatra/contrib/setup.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'sinatra/base'
require 'sinatra/contrib/version'
require 'backports'

module Sinatra
module Contrib
Expand All @@ -9,16 +8,15 @@ def extensions
@extensions ||= {:helpers => [], :register => []}
end

def register(name, path = nil)
def register(name, path)
autoload name, path, :register
end

def helpers(name, path = nil)
def helpers(name, path)
autoload name, path, :helpers
end

def autoload(name, path = nil, method = nil)
path ||= "sinatra/#{name.to_s.underscore}"
def autoload(name, path, method = nil)
extensions[method] << name if method
Sinatra.autoload(name, path)
end
Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/lib/sinatra/cookies.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'sinatra/base'
require 'backports'

module Sinatra
# = Sinatra::Cookies
Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/lib/sinatra/extension.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'sinatra/base'
require 'backports/basic_object' unless defined? BasicObject

module Sinatra

Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/lib/sinatra/namespace.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'backports'
require 'sinatra/base'
require 'mustermann'

Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/lib/sinatra/streaming.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'sinatra/base'
require 'backports'

module Sinatra

Expand Down
3 changes: 1 addition & 2 deletions sinatra-contrib/sinatra-contrib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Gem::Specification.new do |s|

s.add_dependency "sinatra", version
s.add_dependency "mustermann", "~> 1.0"
s.add_dependency "backports", ">= 2.0"
s.add_dependency "tilt", ">= 1.3", "< 3"
s.add_dependency "tilt", ">= 1.3", "< 3"
s.add_dependency "rack-protection", version
s.add_dependency "multi_json"

Expand Down
1 change: 0 additions & 1 deletion sinatra-contrib/spec/streaming_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'backports'
require 'spec_helper'

describe Sinatra::Streaming do
Expand Down

0 comments on commit 045a05b

Please sign in to comment.