flame 4.12.4 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/flame/controller.rb +23 -9
- data/lib/flame/dispatcher.rb +4 -2
- data/lib/flame/request.rb +1 -1
- data/lib/flame/route.rb +3 -1
- data/lib/flame/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc0b79cf5230c68de69ef02ca56cbcb87129596
|
4
|
+
data.tar.gz: 704eeb2d13348ff0a2550f2bec091b3ce31f0107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e1bab7ef3dea8e2b4ebd3c0a2794238363d2667b8231a693450c906dfb49013d5280893003e65484678be80ff130860b7e16fab477aa62484630026c0ac347
|
7
|
+
data.tar.gz: 22a49850f69e4ca3dfa5ac4a58bb9fcaf639be004b6f0c2ec9ce9d45e64a4784840ad90b4f7aaf5c6057d0bce35a1736dd965f0a7096d2eff8b110781443270c
|
data/lib/flame/controller.rb
CHANGED
@@ -39,27 +39,41 @@ module Flame
|
|
39
39
|
end
|
40
40
|
|
41
41
|
## Redirect for response
|
42
|
-
## @overload redirect(path)
|
42
|
+
## @overload redirect(path, status)
|
43
43
|
## Redirect to the string path
|
44
44
|
## @param path [String] path
|
45
|
+
## @param status [Ingeter, nil] HTTP status
|
46
|
+
## @return [nil]
|
45
47
|
## @example Redirect to '/hello'
|
46
48
|
## redirect '/hello'
|
47
|
-
##
|
49
|
+
## @example Redirect to '/hello' with status 301
|
50
|
+
## redirect '/hello', 301
|
51
|
+
## @overload redirect(uri, status)
|
48
52
|
## Redirect to the URI location
|
49
53
|
## @param uri [URI] URI object
|
54
|
+
## @param status [Ingeter, nil] HTTP status
|
55
|
+
## @return [nil]
|
50
56
|
## @example Redirect to 'http://example.com'
|
51
57
|
## redirect URI::HTTP.build(host: 'example.com')
|
52
|
-
##
|
58
|
+
## @example Redirect to 'http://example.com' with status 301
|
59
|
+
## redirect URI::HTTP.build(host: 'example.com'), 301
|
60
|
+
## @overload redirect(*args, status)
|
53
61
|
## Redirect to the path of `path_to` method
|
54
62
|
## @param args arguments for `path_to` method
|
63
|
+
## @param status [Ingeter, nil] HTTP status
|
64
|
+
## @return [nil]
|
55
65
|
## @example Redirect to `show` method of `ArticlesController` with id = 2
|
56
66
|
## redirect ArticlesController, :show, id: 2
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
67
|
+
## @example Redirect to method of controller with status 301
|
68
|
+
## redirect ArticlesController, :show, { id: 2 }, 301
|
69
|
+
def redirect(*args)
|
70
|
+
args[0] = args.first.to_s if args.first.is_a? URI
|
71
|
+
unless args.first.is_a? String
|
72
|
+
path_to_args_range = 0..(args.last.is_a?(Integer) ? -2 : -1)
|
73
|
+
args[path_to_args_range] = path_to(*args[path_to_args_range])
|
74
|
+
end
|
75
|
+
response.redirect(*args)
|
76
|
+
nil
|
63
77
|
end
|
64
78
|
|
65
79
|
## Set the Content-Disposition to "attachment" with the specified filename,
|
data/lib/flame/dispatcher.rb
CHANGED
@@ -10,6 +10,8 @@ require_relative 'static'
|
|
10
10
|
module Flame
|
11
11
|
## Helpers for dispatch Flame::Application#call
|
12
12
|
class Dispatcher
|
13
|
+
GEM_STATIC_FILES = File.join __dir__, '..', '..', 'public'
|
14
|
+
|
13
15
|
attr_reader :request, :response
|
14
16
|
|
15
17
|
include Flame::Dispatcher::Static
|
@@ -28,11 +30,11 @@ module Flame
|
|
28
30
|
def run!
|
29
31
|
catch :halt do
|
30
32
|
try_static ||
|
31
|
-
try_static(
|
33
|
+
try_static(GEM_STATIC_FILES) ||
|
32
34
|
try_route ||
|
33
35
|
halt(404)
|
34
36
|
end
|
35
|
-
response.write body
|
37
|
+
response.write body unless request.http_method == :HEAD
|
36
38
|
response.finish
|
37
39
|
end
|
38
40
|
|
data/lib/flame/request.rb
CHANGED
data/lib/flame/route.rb
CHANGED
@@ -107,7 +107,9 @@ module Flame
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def compare_method(request_method)
|
110
|
-
|
110
|
+
request_method = request_method.upcase.to_sym
|
111
|
+
request_method = :GET if request_method == :HEAD
|
112
|
+
method.upcase.to_sym == request_method
|
111
113
|
end
|
112
114
|
|
113
115
|
def compare_path_parts(request_parts)
|
data/lib/flame/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|