scorched 0.22 → 0.23

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
  SHA1:
3
- metadata.gz: 3f796c21d65c86f604be0aea1a3dbcecdff2abe0
4
- data.tar.gz: 7c192c6f91c1e00fd97cb32865b5c8f610cc1916
3
+ metadata.gz: 1007cc5234411333f49d1cacda15b2a384eb0a0c
4
+ data.tar.gz: 41e412b90cddee3e91c4f8785fecc0b73a394977
5
5
  SHA512:
6
- metadata.gz: 506421a43fcc2fa091978a349d910b3e016696b437ab26aaca12e258219455ba38f9a3483e99f83970df030c649ce2965598eff7c885b5185adfad7dc06d66b9
7
- data.tar.gz: cc0b1638943da206f905d46834ae0f2df3151459a1de60ff537028f3fd69f5732f57ae8d8e921bed302d639e7047a4239e9a5aa42edd4d181900f27fa628be2a
6
+ metadata.gz: 604562e9030f0e52a95a56ff61a43094de84c519daa5ee9f7d40a35734528d8dddcf4f52fc2fd73437a0069661fadab49b3a1ca24d40346ba95fd3eea6dac5e3
7
+ data.tar.gz: fbc6efbbd4508f04526d3910553a40136f037780d129f48298170eea136deeafb73b6cc7c28f8bef092413a82a44a992cd2643035c7eefdb9267bb8c4ee01d26
data/CHANGES.md CHANGED
@@ -3,6 +3,11 @@ Changelog
3
3
 
4
4
  _Note that Scorched is yet to reach a v1.0 release. This means breaking changes may still be made. If upgrading the version of Scorched for your project, review this changelog carefully._
5
5
 
6
+ ### v0.23
7
+ * Now using _scorched-accept_ for accept header parsing and logic, which fixes issues with the `:media_type` condition.
8
+ * Exceptions caught by Scorched are now assigned to env['rack.exception'].
9
+ * Implemented `respond_to_missing?` on Scorched::Controller.
10
+
6
11
  ### v0.22
7
12
  * The `redirect` method now passes the given URL through `absolute`.
8
13
  * The error page filter now always runs at the end-point controller so `:show_http_error_pages` behaves as expected when overriden in sub-controllers.
@@ -16,7 +21,7 @@ _Note that Scorched is yet to reach a v1.0 release. This means breaking changes
16
21
 
17
22
  ### v0.20
18
23
  * _After_ filters are now still processed when a request is halted. This restores the original behaviour prior to version 0.8. This fixes an issue where halting the request after setting flash session data would cause the request to bomb-out.
19
- * As an extension of the change above, filters can now be marked as _forced_ using the new `force` option, which if true, means the filter will run even if the request is halted within another filter (including within another forced filter). This ensures a particular filter is run for every request. This required changing the public interface for the _filter_ method. The sugar methods _before_, _after_, and _error_ have remained backwards compatible.
24
+ * As an extension of the change above, filters can now be marked as _forced_ using the new `force` option, which if true, means the filter will run even if the request is halted within another filter (including within another forced filter). This ensures a particular filter is run for every request. This required changing the public interface for the _filter_ method. The sugar methods _before_, _after_, and _error_ have remained backwards compatible.
20
25
  * Named captures are now passed to route proc's as a single hash argument. The previous behaviour was an oversight.
21
26
  * Halting within an error filter is now swallowed if the error filter is invoked by an error raised in a before or after filter.
22
27
  * The `controller` helper can now be used to map predefined controllers simply by omitting the block, which is now optional. This a more convenient means of mapping controllers as compared to the more barebones `map` method.
@@ -59,7 +64,7 @@ _Note that Scorched is yet to reach a v1.0 release. This means breaking changes
59
64
  * Bumped Tilt dependancy to v1.4 and removed work-around for Tilt encoding issue.
60
65
 
61
66
  ### v0.11
62
- * Route wildcards '*' and '**' (and their named equivalents) now match zero or more characters, instead of one or more. This means `/*` will now match both `/` and `/about` for example.
67
+ * Route wildcards '*' and '**' (and their named equivalents) now match zero or more characters, instead of one or more. This means `/*` will now match both `/` and `/about` for example.
63
68
  * Conditions can now be inverted by appending an exclamation mark to the condition, e.g. `method!: 'GET'` matches all HTTP methods, excluding GET.
64
69
  * While not strictly Scorched related, one planned feature for Scorched was to implement a simple form population mechanism. This has instead been implemented as a stand-alone project, [Formless](https://github.com/Wardrop/Formless), which can be used with any framework or application, including Scorched.
65
70
 
@@ -123,7 +128,7 @@ _Note that Scorched is yet to reach a v1.0 release. This means breaking changes
123
128
  * Added specs for each configuration option.
124
129
  * Using Ruby 2.0 features where applicable. No excuse not to be able to deploy on 2.0 by the time Scorched is ready for production.
125
130
  * Keyword arguments instead of `*args`ombined with ` `Hash === args.last` * Replaced instances of `__FILE__`ith ` `__dir__`Added expected Rack middleware, Rack::MethodOverride and Rack::Head.
126
-
131
+
127
132
  ### v0.4
128
133
  * Make filters behave like middleware. Inheritable, but are only executed once.
129
134
  * Improved implementation of Options and Collection classes
@@ -143,4 +148,3 @@ _Note that Scorched is yet to reach a v1.0 release. This means breaking changes
143
148
  * Added redirect helping for halting and redirecting request
144
149
  * Mechanism for handling exceptions in routes and before/after filters.
145
150
  * Added static resource serving. E.g. public folder.
146
-
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ gemspec
data/LICENSE CHANGED
File without changes
data/TODO.md CHANGED
@@ -8,6 +8,6 @@ Unlikely
8
8
  These features are unlikely to be implemented unless someone provides good enough justification.
9
9
 
10
10
  * Mutex locking option - I'm of the opinion that the web server should be configured for the concurrency model of the application, rather than the framework.
11
- * Using Rack::Protection by default - The problem here is that a good portion of Rack::Protection involves sessions, and given that Scorched doesn't itself load any session middleware, these components of Rack::Protection would have to be excluded. I wouldn't want to lull anyone into a false sense of security
11
+ * Using Rack::Protection by default - The problem here is that a good portion of Rack::Protection involves sessions, and given that Scorched doesn't itself load any session middleware, these components of Rack::Protection would have to be excluded. I wouldn't want to lull anyone into a false sense of security.
12
12
  * Filter priorities - They're technically possible, but I believe it would introduce the potential for _filter hell_; badly written filters and mass hysteria. Filter order has to be logical and predictable. Adding prioritisation would undermine that, and make for lazy use of filters. By not having prioritisation, there's incentive to design filters to be order-agnostic.
13
13
  * Verbose logging - I originally intended to add some form of debug-style logging to show the complete flow of a request as it traverses through filters and controllers, etc. For a couple of reasons, I've decided to leave this out of Scorched. For those unfamiliar with the order in which filters and routes are invoked, it's better to learn through first-hand experience writing little test applications, rather than depending on debug logging.
@@ -0,0 +1,51 @@
1
+ require File.expand_path('../../lib/scorched.rb', __FILE__)
2
+
3
+ class App < Scorched::Controller
4
+ end
5
+
6
+ module Scorched
7
+ module RestActions
8
+
9
+ def self.included(klass)
10
+ klass.get('/') { invoke_action :index }
11
+ klass.get('/new') { invoke_action :new }
12
+ klass.post('/') { invoke_action :create }
13
+ klass.get('/:id') { |id| invoke_action :show, id }
14
+ klass.get('/:id/edit') { |id| invoke_action :edit, id }
15
+ klass.route('/:id', method: ['PATCH', 'PUT']) { |id| invoke_action :update, id }
16
+ klass.delete('/:id') { |id| invoke_action :destroy, id }
17
+ end
18
+
19
+ def invoke_action(action, *captures)
20
+ respond_to?(action) ? send(action, *captures) : pass
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ class Root < App
27
+ include Scorched::RestActions
28
+
29
+ def index
30
+ 'Hello'
31
+ end
32
+
33
+ end
34
+
35
+ class Customer < App
36
+ include Scorched::RestActions
37
+
38
+ def index
39
+ 'Hello customer'
40
+ end
41
+
42
+ def show(id)
43
+ "Hello customer #{id}"
44
+ end
45
+
46
+ end
47
+
48
+ App.controller '/customer', Customer
49
+ App.controller '/', Root
50
+
51
+ run App
@@ -1,14 +1,14 @@
1
- require 'scorched'
1
+ require File.expand_path('../../lib/scorched.rb', __FILE__)
2
2
 
3
3
  class App < Scorched::Controller
4
4
  get '/:name' do
5
5
  @message = greeting(captures[:name])
6
6
  render :hello
7
7
  end
8
-
8
+
9
9
  def greeting(name)
10
10
  "Howdy #{name}"
11
11
  end
12
12
  end
13
13
 
14
- run App
14
+ run App
@@ -3,6 +3,7 @@ ENV['RACK_ENV'] ||= 'development'
3
3
  # Gems
4
4
  require 'rack'
5
5
  require 'rack/accept'
6
+ require 'scorched/accept'
6
7
  require 'tilt'
7
8
 
8
9
  # Stdlib
@@ -18,4 +19,4 @@ require_relative 'scorched/controller'
18
19
  require_relative 'scorched/error'
19
20
  require_relative 'scorched/request'
20
21
  require_relative 'scorched/response'
21
- require_relative 'scorched/version'
22
+ require_relative 'scorched/version'
@@ -2,7 +2,7 @@ require 'forwardable'
2
2
 
3
3
  module Scorched
4
4
  TemplateCache = Tilt::Cache.new
5
-
5
+
6
6
  class Controller
7
7
  include Scorched::Options('config')
8
8
  include Scorched::Options('render_defaults')
@@ -13,7 +13,7 @@ module Scorched
13
13
  include Scorched::Collection('error_filters')
14
14
 
15
15
  attr_reader :request, :response
16
-
16
+
17
17
  config << {
18
18
  :auto_pass => false, # Automatically _pass_ request back to outer controller if no route matches.
19
19
  :cache_templates => true,
@@ -22,9 +22,9 @@ module Scorched
22
22
  :show_http_error_pages => false, # If true, shows the default Scorched HTTP error page.
23
23
  :static_dir => false, # The directory Scorched should serve static files from. Set to false if web server or anything else is serving static files.
24
24
  :strip_trailing_slash => :redirect, # :redirect => Strips and redirects URL ending in forward slash, :ignore => internally ignores trailing slash, false => does nothing.
25
-
25
+
26
26
  }
27
-
27
+
28
28
  render_defaults << {
29
29
  :dir => 'views', # The directory containing all the view templates, relative to the current working directory.
30
30
  :layout => false, # The default layout template to use, relative to the view directory. Set to false for no default layout.
@@ -32,14 +32,14 @@ module Scorched
32
32
  :locals => {},
33
33
  :tilt => {default_encoding: 'UTF-8'}, # Options intended for Tilt. This gets around potential key name conflicts between Scorched and the renderer invoked by Tilt.
34
34
  }
35
-
35
+
36
36
  if ENV['RACK_ENV'] == 'development'
37
37
  config[:show_exceptions] = true
38
38
  config[:static_dir] = 'public'
39
39
  config[:cache_templates] = false
40
40
  config[:show_http_error_pages] = true
41
41
  end
42
-
42
+
43
43
  conditions << {
44
44
  charset: proc { |charsets|
45
45
  [*charsets].any? { |charset| env['rack-accept.request'].charset? charset }
@@ -58,16 +58,16 @@ module Scorched
58
58
  [*conditions].include? matches.first.failed_condition[0]
59
59
  end
60
60
  },
61
- host: proc { |host|
62
- (Regexp === host) ? host =~ request.host : host == request.host
61
+ host: proc { |host|
62
+ (Regexp === host) ? host =~ request.host : host == request.host
63
63
  },
64
64
  language: proc { |languages|
65
65
  [*languages].any? { |language| env['rack-accept.request'].language? language }
66
66
  },
67
67
  media_type: proc { |types|
68
- [*types].any? { |type| env['rack-accept.request'].media_type? type }
68
+ [*types].any? { |type| env['scorched.accept'][:accept].acceptable? type }
69
69
  },
70
- method: proc { |methods|
70
+ method: proc { |methods|
71
71
  [*methods].include?(request.request_method)
72
72
  },
73
73
  handled: proc { |bool|
@@ -76,33 +76,34 @@ module Scorched
76
76
  proc: proc { |blocks|
77
77
  [*blocks].all? { |b| instance_exec(&b) }
78
78
  },
79
- user_agent: proc { |user_agent|
80
- (Regexp === user_agent) ? user_agent =~ request.user_agent : user_agent == request.user_agent
79
+ user_agent: proc { |user_agent|
80
+ (Regexp === user_agent) ? user_agent =~ request.user_agent : user_agent == request.user_agent
81
81
  },
82
- status: proc { |statuses|
82
+ status: proc { |statuses|
83
83
  [*statuses].include?(response.status)
84
84
  },
85
85
  }
86
-
86
+
87
87
  middleware << proc { |controller|
88
88
  use Rack::Head
89
89
  use Rack::MethodOverride
90
90
  use Rack::Accept
91
+ use Scorched::Accept::Rack
91
92
  use Scorched::Static, controller.config[:static_dir] if controller.config[:static_dir]
92
93
  use Rack::Logger, controller.config[:logger] if controller.config[:logger]
93
94
  use Rack::ShowExceptions if controller.config[:show_exceptions]
94
95
  }
95
-
96
+
96
97
  class << self
97
-
98
+
98
99
  def mappings
99
100
  @mappings ||= []
100
101
  end
101
-
102
+
102
103
  def filters
103
104
  @filters ||= {before: before_filters, after: after_filters, error: error_filters}
104
105
  end
105
-
106
+
106
107
  def call(env)
107
108
  loaded = env['scorched.middleware'] ||= Set.new
108
109
  app = lambda do |env|
@@ -117,7 +118,7 @@ module Scorched
117
118
  builder.run(app)
118
119
  builder.call(env)
119
120
  end
120
-
121
+
121
122
  # Generates and assigns mapping hash from the given arguments.
122
123
  #
123
124
  # Accepts the following keyword arguments:
@@ -136,10 +137,10 @@ module Scorched
136
137
  }
137
138
  end
138
139
  alias :<< :map
139
-
140
+
140
141
  # Maps a new ad-hoc or predefined controller.
141
142
  #
142
- # If a block is given, creates a new controller as a sub-class of _klass_ (_self_ by default), otherwise maps
143
+ # If a block is given, creates a new controller as a sub-class of _klass_ (_self_ by default), otherwise maps
143
144
  # _klass_ itself. Returns the new anonymous controller class if a block is given, or _klass_ otherwise.
144
145
  def controller(pattern = '/', klass = self, **mapping, &block)
145
146
  if block_given?
@@ -151,7 +152,7 @@ module Scorched
151
152
  self << {pattern: pattern, target: controller}.merge(mapping)
152
153
  controller
153
154
  end
154
-
155
+
155
156
  # Generates and returns a new route proc from the given block, and optionally maps said proc using the given args.
156
157
  # Helper methods are provided for each HTTP method which automatically define the appropriate _:method_
157
158
  # condition.
@@ -176,7 +177,7 @@ module Scorched
176
177
  end
177
178
  target
178
179
  end
179
-
180
+
180
181
  ['get', 'post', 'put', 'delete', 'head', 'options', 'patch', 'link', 'unlink'].each do |method|
181
182
  methods = (method == 'get') ? ['GET', 'HEAD'] : [method.upcase]
182
183
  define_method(method) do |*args, **conds, &block|
@@ -184,36 +185,36 @@ module Scorched
184
185
  route(*args, **conds, &block)
185
186
  end
186
187
  end
187
-
188
- # Defines a filter of +type+.
188
+
189
+ # Defines a filter of +type+.
189
190
  # +args+ is used internally by Scorched for passing additional arguments to some filters, such as the exception in
190
- # the case of error filters.
191
+ # the case of error filters.
191
192
  def filter(type, args: nil, force: nil, conditions: nil, **more_conditions, &block)
192
193
  more_conditions.merge!(conditions || {})
193
194
  filters[type.to_sym] << {args: args, force: force, conditions: more_conditions, proc: block}
194
195
  end
195
-
196
+
196
197
  # Syntactic sugar for defining a before filter.
197
198
  # If +force+ is true, the filter is run even if another filter halts the request.
198
199
  def before(force: false, **conditions, &block)
199
200
  filter(:before, force: force, conditions: conditions, &block)
200
201
  end
201
-
202
+
202
203
  # Syntactic sugar for defining an after filter.
203
204
  # If +force+ is true, the filter is run even if another filter halts the request.
204
205
  def after(force: false, **conditions, &block)
205
206
  filter(:after, force: force, conditions: conditions, &block)
206
207
  end
207
-
208
+
208
209
  # Syntactic sugar for defining an error filter.
209
210
  # Takes one or more optional exception classes for which this error filter should handle. Handles all exceptions
210
211
  # by default.
211
212
  def error(*classes, **conditions, &block)
212
213
  filter(:error, args: classes, conditions: conditions, &block)
213
214
  end
214
-
215
+
215
216
  private
216
-
217
+
217
218
  # Parses and compiles the given URL string pattern into a regex if not already, returning the resulting regexp
218
219
  # object. Accepts an optional _match_to_end_ argument which will ensure the generated pattern matches to the end
219
220
  # of the string.
@@ -237,15 +238,19 @@ module Scorched
237
238
  Regexp.new(compiled)
238
239
  end
239
240
  end
240
-
241
+
241
242
  after(failed_condition: :host) { response.status = 404 }
242
243
  after(failed_condition: :method) { response.status = 405 }
243
244
  after(failed_condition: %i{charset encoding language media_type}) { response.status = 406 }
244
-
245
- def method_missing(method, *args, &block)
246
- (self.class.respond_to? method) ? self.class.__send__(method, *args, &block) : super
245
+
246
+ def method_missing(method_name, *args, &block)
247
+ (self.class.respond_to? method_name) ? self.class.__send__(method_name, *args, &block) : super
248
+ end
249
+
250
+ def respond_to_missing?(method_name, include_private = false)
251
+ self.class.respond_to? method_name
247
252
  end
248
-
253
+
249
254
  def initialize(env)
250
255
  define_singleton_method :env do
251
256
  env
@@ -254,13 +259,13 @@ module Scorched
254
259
  @request = Request.new(env)
255
260
  @response = Response.new
256
261
  end
257
-
262
+
258
263
  # This is where the magic happens. Applies filters, matches mappings, applies error handlers, catches :halt and
259
264
  # :pass, etc.
260
265
  def process
261
266
  inner_error = nil
262
267
  rescue_block = proc do |e|
263
- raise unless filters[:error].any? do |f|
268
+ (env['rack.exception'] = e && raise) unless filters[:error].any? do |f|
264
269
  if !f[:args] || f[:args].empty? || f[:args].any? { |type| e.is_a?(type) }
265
270
  instance_exec(e, &f[:proc]) unless check_for_failed_condition(f[:conditions])
266
271
  end
@@ -281,7 +286,7 @@ module Scorched
281
286
  [
282
287
  m.mapping[:priority] || 0,
283
288
  [*m.mapping[:conditions][:media_type]].map { |type|
284
- env['rack-accept.request'].media_type.qvalue(type)
289
+ env['scorched.accept'][:accept].rank(type, true)
285
290
  }.max || 0,
286
291
  -idx
287
292
  ]
@@ -313,7 +318,7 @@ module Scorched
313
318
  end
314
319
  response.finish
315
320
  end
316
-
321
+
317
322
  # Dispatches the request to the matched target.
318
323
  # Overriding this method provides the oppurtunity for one to have more control over how mapping targets are invoked.
319
324
  def dispatch(match)
@@ -329,7 +334,7 @@ module Scorched
329
334
  end
330
335
  end
331
336
  end
332
-
337
+
333
338
  # Finds mappings that match the unmatched portion of the request path, returning an array of `Match` objects, or an
334
339
  # empty array if no matches were found.
335
340
  #
@@ -352,7 +357,7 @@ module Scorched
352
357
  end
353
358
  }.compact
354
359
  end
355
-
360
+
356
361
  # Tests the given conditions, returning the name of the first failed condition, or nil otherwise.
357
362
  def check_for_failed_condition(conds)
358
363
  failed = (conds || []).find { |c, v| !check_condition?(c, v) }
@@ -361,7 +366,7 @@ module Scorched
361
366
  end
362
367
  failed
363
368
  end
364
-
369
+
365
370
  # Test the given condition, returning true if the condition passes, or false otherwise.
366
371
  def check_condition?(c, v)
367
372
  c = c[0..-2].to_sym if invert = (c[-1] == '!')
@@ -369,13 +374,13 @@ module Scorched
369
374
  retval = instance_exec(v, &self.conditions[c])
370
375
  invert ? !retval : !!retval
371
376
  end
372
-
377
+
373
378
  # Redirects to the specified path or URL. An optional HTTP status is also accepted.
374
379
  def redirect(url, status = (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302)
375
380
  response['Location'] = absolute(url)
376
381
  halt(status)
377
382
  end
378
-
383
+
379
384
  # call-seq:
380
385
  # halt(status=nil, body=nil)
381
386
  # halt(body)
@@ -388,20 +393,20 @@ module Scorched
388
393
  response.body = body if body
389
394
  throw :halt
390
395
  end
391
-
396
+
392
397
  def pass
393
398
  throw :pass
394
399
  end
395
-
400
+
396
401
  # Convenience method for accessing Rack session.
397
402
  def session
398
403
  env['rack.session']
399
404
  end
400
-
405
+
401
406
  # Delegate a few common `request` methods for conveniance.
402
407
  extend Forwardable
403
408
  def_delegators :request, :captures
404
-
409
+
405
410
  # Flash session storage helper.
406
411
  # Stores session data until the next time this method is called with the same arguments, at which point it's reset.
407
412
  # The typical use case is to provide feedback to the user on the previous action they performed.
@@ -417,11 +422,11 @@ module Scorched
417
422
  end
418
423
  session[key]
419
424
  end
420
-
425
+
421
426
  after(force: true) do
422
427
  env['scorched.flash'].each { |k,v| session[k] = v } if session && env['scorched.flash']
423
428
  end
424
-
429
+
425
430
  # Serves as a thin layer of convenience to Rack's built-in method: Request#cookies, Response#set_cookie, and
426
431
  # Response#delete_cookie.
427
432
  #
@@ -442,7 +447,7 @@ module Scorched
442
447
  end
443
448
  end
444
449
  end
445
-
450
+
446
451
  # Renders the given string or file path using the Tilt templating library.
447
452
  # Each option defaults to the corresponding value defined in _render_defaults_ attribute. Unrecognised options are
448
453
  # passed through to Tilt, but a `:tilt` option is also provided for passing options directly to Tilt.
@@ -464,12 +469,12 @@ module Scorched
464
469
  tilt_options = options.merge(tilt || {})
465
470
  tilt_engine = (derived_engine = Tilt[string_or_file.to_s]) || Tilt[engine]
466
471
  raise Error, "Invalid or undefined template engine: #{engine.inspect}" unless tilt_engine
467
-
472
+
468
473
  template = if Symbol === string_or_file
469
474
  file = string_or_file.to_s
470
475
  file = file << ".#{engine}" unless derived_engine
471
476
  file = File.expand_path(file, dir) if dir
472
-
477
+
473
478
  template_cache.fetch(:file, tilt_engine, file, tilt_options) do
474
479
  tilt_engine.new(file, nil, tilt_options)
475
480
  end
@@ -478,7 +483,7 @@ module Scorched
478
483
  tilt_engine.new(nil, nil, tilt_options) { string_or_file }
479
484
  end
480
485
  end
481
-
486
+
482
487
  # The following is responsible for preventing the rendering of layouts within views.
483
488
  begin
484
489
  original_no_default_layout = @_no_default_layout
@@ -487,7 +492,7 @@ module Scorched
487
492
  ensure
488
493
  @_no_default_layout = original_no_default_layout
489
494
  end
490
-
495
+
491
496
  if layout
492
497
  render(layout, dir: dir, layout: false, engine: engine, locals: locals, tilt: tilt, **options) { output }
493
498
  else
@@ -512,7 +517,7 @@ module Scorched
512
517
  uri.to_s
513
518
  end
514
519
  end
515
-
520
+
516
521
  # Takes an optional path, relative to the applications root URL, and returns an absolute path.
517
522
  # Example: absolute('/style.css') #=> /myapp/style.css
518
523
  def absolute(path = nil)
@@ -524,7 +529,7 @@ module Scorched
524
529
  end
525
530
  return_path[0] == '/' ? return_path : return_path.insert(0, '/')
526
531
  end
527
-
532
+
528
533
  # We always want this filter to run at the end-point controller, hence we include the conditions within the body of
529
534
  # the filter.
530
535
  after do
@@ -557,9 +562,9 @@ module Scorched
557
562
  end
558
563
  end
559
564
 
560
-
565
+
561
566
  private
562
-
567
+
563
568
  def run_filters(type, forced_only = false)
564
569
  tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new}
565
570
  filters[type].reject{ |f| tracker[type].include?(f) || (forced_only && !f[:force]) }.each do |f|
@@ -575,7 +580,7 @@ module Scorched
575
580
  end
576
581
  end
577
582
  end
578
-
583
+
579
584
  def log(type = nil, message = nil)
580
585
  config[:logger].progname ||= 'Scorched'
581
586
  if(type)