sinatra-contrib 2.0.8.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f20c83e70cf4ab1d1433ac3f3795c168259f0e2d964c095db13ee3db12a94b28
4
- data.tar.gz: 7f7d70137b46068e37f1c7b73216f07c90216f5cbd70bf360dfcc66a67454f5e
3
+ metadata.gz: 9c39f2f87ea6fe310e1ee1ba3b6e59d358bba08e7c5262ac1c3b929a7f960913
4
+ data.tar.gz: d089938141342b810a03f360623a38361bdd9535031c385fa2d33202119de48e
5
5
  SHA512:
6
- metadata.gz: 0023522137ae873a8533d8be320fcd2b6715c46caa9ec0170e4b581a677dc96f75b4dc30e58402c0a0f5fb35d6b0b011f9ac3c24a313dca5839849b5e09e4ab1
7
- data.tar.gz: a301fd1006159f2551d6cd70daa0179ce1b334797e5221e7bb3024092925983bff0f451db0c6e596870890dacfcb7a85241053ba2ad6b2e7ed7820206b93e596
6
+ metadata.gz: 5b12a1e1e513525d3bed0845ce085099c2869a8518c65bf7a64fbb0dc1aa563a9f4b3eb459c0b54ff43e9eb9bc7953ad4e4d8f281c279a339fe2958ecde5815c
7
+ data.tar.gz: db98ec6a5d297b0fc553a021d02e1339c3561070e962e12685bbe7852c9268aeb43008841254dbd4a9a7e2c352b1d1d20a2651c3fc23507c7997bedc2de0eb7d
data/README.md CHANGED
@@ -67,6 +67,9 @@ Currently included:
67
67
  * [`sinatra/test_helpers`][sinatra-test-helpers]: Helper methods to ease testing your Sinatra
68
68
  application. Partly extracted from Sinatra. Testing framework agnostic
69
69
 
70
+ * `sinatra/quiet_logger`: Extension to exclude specific pathes from access log.
71
+ It works by patching Rack::CommonLogger
72
+
70
73
  ## Installation
71
74
 
72
75
  Add `gem 'sinatra-contrib'` to *Gemfile*, then execute `bundle install`.
@@ -124,7 +124,11 @@ module Sinatra
124
124
  raise UnsupportedConfigType unless ['.yml', '.yaml', '.erb'].include?(File.extname(file))
125
125
  logger.info "loading config file '#{file}'" if logging? && respond_to?(:logger)
126
126
  document = ERB.new(IO.read(file)).result
127
- yaml = YAML.load(document)
127
+ yaml = begin
128
+ YAML.load(document, aliases: true)
129
+ rescue ArgumentError
130
+ YAML.load(document)
131
+ end
128
132
  config = config_for_env(yaml)
129
133
  config.each_pair { |key, value| set(key, value) }
130
134
  end
@@ -1,6 +1,5 @@
1
1
  require 'sinatra/base'
2
2
  require 'sinatra/contrib/version'
3
- require 'backports/rails/string' # for String#underscore
4
3
 
5
4
  module Sinatra
6
5
  module Contrib
@@ -9,16 +8,15 @@ module Sinatra
9
8
  @extensions ||= {:helpers => [], :register => []}
10
9
  end
11
10
 
12
- def register(name, path = nil)
11
+ def register(name, path)
13
12
  autoload name, path, :register
14
13
  end
15
14
 
16
- def helpers(name, path = nil)
15
+ def helpers(name, path)
17
16
  autoload name, path, :helpers
18
17
  end
19
18
 
20
- def autoload(name, path = nil, method = nil)
21
- path ||= "sinatra/#{name.to_s.underscore}"
19
+ def autoload(name, path, method = nil)
22
20
  extensions[method] << name if method
23
21
  Sinatra.autoload(name, path)
24
22
  end
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Contrib
3
- VERSION = '2.0.8.1'
3
+ VERSION = '2.2.1'
4
4
  end
5
5
  end
6
6
 
@@ -7,32 +7,32 @@ module Sinatra
7
7
  # or breaks if external dependencies are missing. Will extend
8
8
  # Sinatra::Application by default.
9
9
  module Common
10
- register :ConfigFile
11
- register :MultiRoute
12
- register :Namespace
13
- register :RespondWith
10
+ register :ConfigFile, 'sinatra/config_file'
11
+ register :MultiRoute, 'sinatra/multi_route'
12
+ register :Namespace, 'sinatra/namespace'
13
+ register :RespondWith, 'sinatra/respond_with'
14
14
 
15
- helpers :Capture
16
- helpers :ContentFor
17
- helpers :Cookies
18
- helpers :EngineTracking
19
- helpers :JSON
20
- helpers :LinkHeader
21
- helpers :Streaming
22
- helpers :RequiredParams
15
+ helpers :Capture, 'sinatra/capture'
16
+ helpers :ContentFor, 'sinatra/content_for'
17
+ helpers :Cookies, 'sinatra/cookies'
18
+ helpers :EngineTracking, 'sinatra/engine_tracking'
19
+ helpers :JSON, 'sinatra/json'
20
+ helpers :LinkHeader, 'sinatra/link_header'
21
+ helpers :Streaming, 'sinatra/streaming'
22
+ helpers :RequiredParams, 'sinatra/required_params'
23
23
  end
24
24
 
25
25
  ##
26
26
  # Other extensions you don't want to be loaded unless needed.
27
27
  module Custom
28
- # register :Compass
29
- register :Reloader
28
+ # register :Compass, 'sinatra/compass'
29
+ register :Reloader, 'sinatra/reloader'
30
30
  end
31
31
 
32
32
  ##
33
33
  # Stuff that aren't Sinatra extensions, technically.
34
- autoload :Extension
35
- autoload :TestHelpers
34
+ autoload :Extension, 'sinatra/extension'
35
+ autoload :TestHelpers, 'sinatra/test_helpers'
36
36
  end
37
37
 
38
38
  register Sinatra::Contrib::Common
@@ -224,6 +224,12 @@ module Sinatra
224
224
  include SharedMethods
225
225
  attr_reader :base, :templates
226
226
 
227
+ ALLOWED_ENGINES = [
228
+ :erb, :erubi, :erubis, :haml, :hamlit, :builder, :nokogiri, :sass, :scss,
229
+ :less, :liquid, :markdown, :textile, :rdoc, :asciidoc, :radius, :markaby,
230
+ :rabl, :slim, :creole, :mediawiki, :coffee, :stylus, :yajl, :wlang
231
+ ]
232
+
227
233
  def self.prefixed(*names)
228
234
  names.each { |n| define_method(n) { |*a, &b| prefixed(n, *a, &b) }}
229
235
  end
@@ -278,8 +284,8 @@ module Sinatra
278
284
  end
279
285
 
280
286
  def set(key, value = self, &block)
281
- raise ArgumentError, "may not set #{key}" if key != :views
282
- return key.each { |k,v| set(k, v) } if block.nil? and value == self
287
+ return key.each { |k,v| set(k, v) } if key.respond_to?(:each) and block.nil? and value == self
288
+ raise ArgumentError, "may not set #{key}" unless ([:views] + ALLOWED_ENGINES).include?(key)
283
289
  block ||= proc { value }
284
290
  singleton_class.send(:define_method, key, &block)
285
291
  end
@@ -332,7 +338,7 @@ module Sinatra
332
338
  def prefixed(method, pattern = nil, conditions = {}, &block)
333
339
  default = %r{(?:/.*)?} if method == :before or method == :after
334
340
  pattern, conditions = compile pattern, conditions, default
335
- result = base.send(method, pattern, conditions, &block)
341
+ result = base.send(method, pattern, **conditions, &block)
336
342
  invoke_hook :route_added, method.to_s.upcase, pattern, block
337
343
  result
338
344
  end
@@ -0,0 +1,50 @@
1
+ module Sinatra
2
+ # = Sinatra::QuietLogger
3
+ #
4
+ # QuietLogger extension allows you to define paths excluded
5
+ # from logging using the +quiet_logger_prefixes+ setting.
6
+ # It is inspired from rails quiet_logger, but handles multiple paths.
7
+ #
8
+ # == Usage
9
+ #
10
+ # === Classic Application
11
+ #
12
+ # You have to require the quiet_logger, set the prefixes
13
+ # and register the extension in your application.
14
+ #
15
+ # require 'sinatra'
16
+ # require 'sinatra/quiet_logger'
17
+ #
18
+ # set :quiet_logger_prefixes, %w(css js images fonts)
19
+ # register Sinatra::QuietLogger
20
+ #
21
+ # === Modular Application
22
+ #
23
+ # The same for modular application:
24
+ #
25
+ # require 'sinatra/base'
26
+ # require 'sinatra/quiet_logger'
27
+ #
28
+ # set :quiet_logger_prefixes, %w(css js images fonts)
29
+ #
30
+ # class App < Sinatra::Base
31
+ # register Sinatra::QuietLogger
32
+ # end
33
+ #
34
+ module QuietLogger
35
+
36
+ def self.registered(app)
37
+ quiet_logger_prefixes = app.settings.quiet_logger_prefixes.join('|') rescue ''
38
+ return warn('You need to specify the paths you wish to exclude from logging via `set :quiet_logger_prefixes, %w(images css fonts)`') if quiet_logger_prefixes.empty?
39
+ const_set('QUIET_LOGGER_REGEX', %r(\A/{0,2}(?:#{quiet_logger_prefixes})))
40
+ ::Rack::CommonLogger.prepend(
41
+ ::Module.new do
42
+ def log(env, *)
43
+ super unless env['PATH_INFO'] =~ QUIET_LOGGER_REGEX
44
+ end
45
+ end
46
+ )
47
+ end
48
+
49
+ end
50
+ end
@@ -269,7 +269,7 @@ module Sinatra
269
269
  #
270
270
  # Note: We are using #compile! so we don't interfere with extensions
271
271
  # changing #route.
272
- def compile!(verb, path, block, options = {})
272
+ def compile!(verb, path, block, **options)
273
273
  source_location = block.respond_to?(:source_location) ?
274
274
  block.source_location.first : caller_files[1]
275
275
  signature = super
@@ -302,7 +302,7 @@ module Sinatra
302
302
  # Does everything Sinatra::Base#add_filter does, but it also tells
303
303
  # the +Watcher::List+ for the Sinatra application to watch the defined
304
304
  # filter.
305
- def add_filter(type, path = nil, options = {}, &block)
305
+ def add_filter(type, path = nil, **options, &block)
306
306
  source_location = block.respond_to?(:source_location) ?
307
307
  block.source_location.first : caller_files[1]
308
308
  result = super
@@ -221,7 +221,7 @@ module Sinatra
221
221
 
222
222
  private
223
223
 
224
- def compile!(verb, path, block, options = {})
224
+ def compile!(verb, path, block, **options)
225
225
  options[:provides] ||= respond_to if respond_to
226
226
  super
227
227
  end
@@ -240,7 +240,7 @@ module Sinatra
240
240
  :css => [:less, :sass, :scss],
241
241
  :xml => [:builder, :nokogiri],
242
242
  :js => [:coffee],
243
- :html => [:erb, :erubi, :erubis, :haml, :halmit, :slim, :liquid, :radius,
243
+ :html => [:erb, :erubi, :erubis, :haml, :hamlit, :slim, :liquid, :radius,
244
244
  :mab, :markdown, :textile, :rdoc],
245
245
  :all => (Sinatra::Templates.instance_methods.map(&:to_sym) +
246
246
  [:mab] - [:find_template, :markaby]),
@@ -34,11 +34,10 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
34
34
  EOF
35
35
  end
36
36
 
37
- s.required_ruby_version = '>= 2.2.0'
37
+ s.required_ruby_version = '>= 2.3.0'
38
38
 
39
39
  s.add_dependency "sinatra", version
40
40
  s.add_dependency "mustermann", "~> 1.0"
41
- s.add_dependency "backports", ">= 2.8.2"
42
41
  s.add_dependency "tilt", "~> 2.0"
43
42
  s.add_dependency "rack-protection", version
44
43
  s.add_dependency "multi_json"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/sinatra/sinatra/graphs/contributors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-01 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.8.1
19
+ version: 2.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.8.1
26
+ version: 2.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mustermann
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: backports
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 2.8.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 2.8.2
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: tilt
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +58,14 @@ dependencies:
72
58
  requirements:
73
59
  - - '='
74
60
  - !ruby/object:Gem::Version
75
- version: 2.0.8.1
61
+ version: 2.2.1
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - '='
81
67
  - !ruby/object:Gem::Version
82
- version: 2.0.8.1
68
+ version: 2.2.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: multi_json
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -400,6 +386,7 @@ files:
400
386
  - lib/sinatra/link_header.rb
401
387
  - lib/sinatra/multi_route.rb
402
388
  - lib/sinatra/namespace.rb
389
+ - lib/sinatra/quiet_logger.rb
403
390
  - lib/sinatra/reloader.rb
404
391
  - lib/sinatra/required_params.rb
405
392
  - lib/sinatra/respond_with.rb
@@ -415,7 +402,7 @@ metadata:
415
402
  source_code_uri: https://github.com/sinatra/sinatra/tree/master/sinatra-contrib
416
403
  homepage_uri: http://sinatrarb.com/contrib/
417
404
  documentation_uri: https://www.rubydoc.info/gems/sinatra-contrib
418
- post_install_message:
405
+ post_install_message:
419
406
  rdoc_options: []
420
407
  require_paths:
421
408
  - lib
@@ -423,16 +410,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
423
410
  requirements:
424
411
  - - ">="
425
412
  - !ruby/object:Gem::Version
426
- version: 2.2.0
413
+ version: 2.3.0
427
414
  required_rubygems_version: !ruby/object:Gem::Requirement
428
415
  requirements:
429
416
  - - ">="
430
417
  - !ruby/object:Gem::Version
431
418
  version: '0'
432
419
  requirements: []
433
- rubyforge_project:
434
- rubygems_version: 2.7.3
435
- signing_key:
420
+ rubygems_version: 3.0.3.1
421
+ signing_key:
436
422
  specification_version: 4
437
423
  summary: Collection of useful Sinatra extensions
438
424
  test_files: []