flame 3.5.2 → 3.6.0

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: 23607516bfdad9950e8dda86e0d603026a852a26
4
- data.tar.gz: 35085671967fa0ed58751675b9f23305a0376a56
3
+ metadata.gz: bcf30b3c7d0ec4bc8ad73a500492c9d3dcf8c72b
4
+ data.tar.gz: 4a983a6a28dfadd477337400752190d8a8cd54f8
5
5
  SHA512:
6
- metadata.gz: 91dac6fe1127feb439fe69c68bb9de9528a9834a742e807377fe38788fe78b4f2b8e81766225b5a1c675d6abdb7dba38c3d56b1a10fe2d0232e81dbc37b916d6
7
- data.tar.gz: ae3703f5353e6896e72a7aa25dc9517de0debc8b0ac51987d918b3d59953bb74ed22b241da0ffd26fb2c2ebc00c32e6c21a2afd8cacad6c4974c3a4111207fc1
6
+ metadata.gz: 05fa7acabaa2b16f9cde14dc5de48fb4869bd3424dceece06c8068d2cc5ea5afa683c9b39fcd15319f1ebf94dc5af53679eef1c215aa7090cfd9b811829e5b79
7
+ data.tar.gz: 11c78bdbba3080266fb0486b42ebd9cfcbdfb02f7f90fcb88b2acf7a9d37e784655dad9954105f30b2d02aeb00500b5a5074a404fdd0381f553024696e94e17a
@@ -28,6 +28,7 @@ module Flame
28
28
  try_static(File.join(__dir__, '..', '..', 'public')) ||
29
29
  try_error(404)
30
30
  end
31
+ response.write body
31
32
  response.finish
32
33
  end
33
34
 
@@ -37,6 +38,10 @@ module Flame
37
38
  value ? response.status = value : response.status
38
39
  end
39
40
 
41
+ def body(value = nil)
42
+ value ? @body = value : @body
43
+ end
44
+
40
45
  def params
41
46
  @params ||= request.params.merge(request.params.keys_to_sym)
42
47
  end
@@ -60,14 +65,14 @@ module Flame
60
65
  path.empty? ? '/' : path
61
66
  end
62
67
 
63
- def halt(new_status = nil, body = nil, new_headers = {})
68
+ def halt(new_status = nil, new_body = nil, new_headers = {})
64
69
  case new_status
65
- when String then body = new_status
70
+ when String then new_body = new_status
66
71
  when Integer then status new_status
67
72
  end
68
73
  # new_status.is_a?(String) ? () : (status new_status)
69
- body = default_body if body.nil? && response.body.empty?
70
- response.body = body if body
74
+ new_body = default_body if new_body.nil? && body.empty?
75
+ body new_body if new_body
71
76
  response.headers.merge!(new_headers)
72
77
  throw :halt
73
78
  end
@@ -101,7 +106,7 @@ module Flame
101
106
 
102
107
  def execute_route(route)
103
108
  exec_route = route.executable
104
- response.body = exec_route.run!(self)
109
+ exec_route.run!(self)
105
110
  rescue => exception
106
111
  dump_error(exception)
107
112
  # status 500
@@ -1,11 +1,5 @@
1
1
  module Flame
2
2
  ## Class for responses
3
3
  class Response < Rack::Response
4
- ## Rewrite body assign (reset Content-Length and use #write)
5
- def body=(value)
6
- @length = 0
7
- body.clear
8
- write value
9
- end
10
4
  end
11
5
  end
data/lib/flame/route.rb CHANGED
@@ -104,9 +104,8 @@ module Flame
104
104
  def run!(dispatcher)
105
105
  @ctrl = @route[:controller].new(dispatcher)
106
106
  execute_hooks(:before)
107
- result = @ctrl.send(@route[:action], *arranged_params)
107
+ dispatcher.body @ctrl.send(@route[:action], *arranged_params)
108
108
  execute_hooks(:after)
109
- result
110
109
  end
111
110
 
112
111
  def execute_errors(status = 500)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flame
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov