flame 4.12.4 → 4.14.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
  SHA1:
3
- metadata.gz: 4ed5d54f5f6821749a7324ead082677cb04d669e
4
- data.tar.gz: 228dbe656d57d35ab38a75780ead602461a73827
3
+ metadata.gz: 5bc0b79cf5230c68de69ef02ca56cbcb87129596
4
+ data.tar.gz: 704eeb2d13348ff0a2550f2bec091b3ce31f0107
5
5
  SHA512:
6
- metadata.gz: d702039c0a51e0041d5bc41fb8b15c62bb1c9eb943fd2c6bfa74b88a8024f310921c9c22445fd8270e23a43815412fa9508ee42413aed7407a83b7efb89b93b2
7
- data.tar.gz: 5347d0bc63a7c39d725369de0d1c8afa7707ef41cd95ea18aa282d8d61379903cb28b4353c0f731d6f45ddba853fc7603deb9c4a4cc41e19dd10004de2f8e5de
6
+ metadata.gz: c7e1bab7ef3dea8e2b4ebd3c0a2794238363d2667b8231a693450c906dfb49013d5280893003e65484678be80ff130860b7e16fab477aa62484630026c0ac347
7
+ data.tar.gz: 22a49850f69e4ca3dfa5ac4a58bb9fcaf639be004b6f0c2ec9ce9d45e64a4784840ad90b4f7aaf5c6057d0bce35a1736dd965f0a7096d2eff8b110781443270c
@@ -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
- ## @overload redirect(uri)
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
- ## @overload redirect(*args)
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
- def redirect(*params)
58
- probably_url = params.first
59
- probably_url = probably_url.to_s if probably_url.is_a? URI
60
- response.redirect(
61
- probably_url.is_a?(String) ? probably_url : path_to(*params)
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,
@@ -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(File.join(__dir__, '..', '..', 'public')) ||
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
 
@@ -10,7 +10,7 @@ module Flame
10
10
 
11
11
  ## Override HTTP-method of the request if the param '_method' found
12
12
  def http_method
13
- params['_method'] || request_method
13
+ @http_method ||= (params['_method'] || request_method).upcase.to_sym
14
14
  end
15
15
  end
16
16
  end
@@ -107,7 +107,9 @@ module Flame
107
107
  end
108
108
 
109
109
  def compare_method(request_method)
110
- method.upcase.to_sym == request_method.upcase.to_sym
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flame
4
- VERSION = '4.12.4'
4
+ VERSION = '4.14.1'
5
5
  end
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.12.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-17 00:00:00.000000000 Z
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack