rack-app-front_end 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -10
- data/Gemfile +4 -0
- data/VERSION +1 -1
- data/lib/rack/app/front_end/helpers.rb +4 -0
- data/lib/rack/app/front_end/middlewares/method_override.rb +55 -0
- data/lib/rack/app/front_end/middlewares.rb +3 -0
- data/lib/rack/app/front_end.rb +1 -0
- data/rack-app-front_end.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11568951dd88c8fa3d8790e965114fbc316d1453
|
4
|
+
data.tar.gz: 28ca9775167da3c132ba14a383c0c6762db8f661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4160f5bf15487a4b43c914c34835300d50380b4b6e916c0da2c4bde588d6293d3a53c9929d6a8d67d7e88afc34e7d54e85d3a1142cc2e2f8445395dca18cdbe4
|
7
|
+
data.tar.gz: 137a1658518dca98a7eee704697b950225ff082b6ed05cf5bc270925d60e37dd87827e17ef09befe5dfc610315d1cbbf1c823655a03783716c92da88e30536ff
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
language: ruby
|
2
|
-
script: rspec
|
2
|
+
script: rspec -f d
|
3
3
|
|
4
4
|
rvm:
|
5
5
|
|
@@ -14,12 +14,3 @@ rvm:
|
|
14
14
|
branches:
|
15
15
|
only:
|
16
16
|
- master
|
17
|
-
|
18
|
-
matrix:
|
19
|
-
allow_failures:
|
20
|
-
- rvm: ruby-head
|
21
|
-
- rvm: jruby-head
|
22
|
-
|
23
|
-
notifications:
|
24
|
-
email:
|
25
|
-
- adamluzsi@gmail.com
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.20.0
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Rack::App::FrontEnd::Middlewares::MethodOverride
|
2
|
+
|
3
|
+
ALLOWED_METHODS = %w[GET POST].freeze
|
4
|
+
METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
|
5
|
+
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
|
6
|
+
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
if affected_request?(env)
|
13
|
+
try_override(env)
|
14
|
+
end
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def try_override(env)
|
22
|
+
method = method_override(env)
|
23
|
+
if valid_https_method?(method)
|
24
|
+
set_request_method(method, env)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_request_method(method, env)
|
29
|
+
env[Rack::App::Constants::ENV::METHODOVERRIDE_ORIGINAL_METHOD] = env[Rack::REQUEST_METHOD]
|
30
|
+
env[Rack::REQUEST_METHOD] = method
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid_https_method?(method)
|
34
|
+
Rack::App::Constants::HTTP::METHODS.include?(method)
|
35
|
+
end
|
36
|
+
|
37
|
+
def affected_request?(env)
|
38
|
+
ALLOWED_METHODS.include?(env[Rack::REQUEST_METHOD])
|
39
|
+
end
|
40
|
+
|
41
|
+
def method_override(env)
|
42
|
+
req = Rack::Request.new(env)
|
43
|
+
method = env[HTTP_METHOD_OVERRIDE_HEADER] ||
|
44
|
+
method_override_param(req,:POST) ||
|
45
|
+
method_override_param(req,:GET)
|
46
|
+
|
47
|
+
method.to_s.upcase
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_override_param(req, http_method)
|
51
|
+
req.__send__(http_method)[METHOD_OVERRIDE_PARAM_KEY]
|
52
|
+
rescue Rack::Utils::InvalidParameterError, Rack::Utils::ParameterTypeError
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/lib/rack/app/front_end.rb
CHANGED
@@ -8,6 +8,7 @@ module Rack::App::FrontEnd
|
|
8
8
|
require 'rack/app/front_end/version'
|
9
9
|
require 'rack/app/front_end/helpers'
|
10
10
|
require 'rack/app/front_end/template'
|
11
|
+
require 'rack/app/front_end/middlewares'
|
11
12
|
require 'rack/app/front_end/syntax_sugar'
|
12
13
|
require 'rack/app/front_end/folder_mounter'
|
13
14
|
require 'rack/app/front_end/endpoint_methods'
|
data/rack-app-front_end.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app-front_end
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 6.3.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 6.3.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: tilt
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +107,8 @@ files:
|
|
107
107
|
- lib/rack/app/front_end/helpers/html_dsl/tag_builder.rb
|
108
108
|
- lib/rack/app/front_end/helpers/rendering.rb
|
109
109
|
- lib/rack/app/front_end/helpers/table.rb
|
110
|
+
- lib/rack/app/front_end/middlewares.rb
|
111
|
+
- lib/rack/app/front_end/middlewares/method_override.rb
|
110
112
|
- lib/rack/app/front_end/singleton_methods.rb
|
111
113
|
- lib/rack/app/front_end/syntax_sugar.rb
|
112
114
|
- lib/rack/app/front_end/syntax_sugar/dsl.rb
|
@@ -137,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
139
|
version: '0'
|
138
140
|
requirements: []
|
139
141
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.1
|
141
143
|
signing_key:
|
142
144
|
specification_version: 4
|
143
145
|
summary: Rack::App FrontEnd framework to create beautiful website with style
|