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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fb632d1377966158485faf82fc05990bf697039
4
- data.tar.gz: 35266c8691804698bfd4e24eeb1302d8eded723b
3
+ metadata.gz: 11568951dd88c8fa3d8790e965114fbc316d1453
4
+ data.tar.gz: 28ca9775167da3c132ba14a383c0c6762db8f661
5
5
  SHA512:
6
- metadata.gz: 6eb3d13d856bb9ed714ac05beec9e412e5d47b62b05dabe460b6c40fb60639d0ff6337aaeddac19bd8ed40d7ca02e960ee016c17da58a250effefa05ffd9b24a
7
- data.tar.gz: d16dd21f15f0231b2183c9973dc0e7f2bb79fc58012f4a529cf9d88416e9a861f9a3475e3187a78d91c2064b49afc1f8a4edf62968aecb07e22991bbd824055d
6
+ metadata.gz: 4160f5bf15487a4b43c914c34835300d50380b4b6e916c0da2c4bde588d6293d3a53c9929d6a8d67d7e88afc34e7d54e85d3a1142cc2e2f8445395dca18cdbe4
7
+ data.tar.gz: 137a1658518dca98a7eee704697b950225ff082b6ed05cf5bc270925d60e37dd87827e17ef09befe5dfc610315d1cbbf1c823655a03783716c92da88e30536ff
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- script: rspec spec
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
@@ -1,2 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
  gemspec
3
+
4
+ if RUBY_VERSION < '2.2.2'
5
+ gem 'rack', '< 2.0.0'
6
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.19.0
1
+ 0.20.0
@@ -6,4 +6,8 @@ module Rack::App::FrontEnd::Helpers
6
6
 
7
7
  include Rack::App::FrontEnd::Helpers::Rendering
8
8
 
9
+ def path_to(*args)
10
+ @request.env[::Rack::App::Constants::ENV::HANDLER].path_to(*args)
11
+ end
12
+
9
13
  end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Rack::App::FrontEnd::Middlewares
2
+ require 'rack/app/front_end/middlewares/method_override'
3
+ end
@@ -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'
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
25
25
 
26
- spec.add_dependency 'rack-app','>= 2.0.0'
26
+ spec.add_dependency 'rack-app','>= 6.3.1'
27
27
  spec.add_dependency 'tilt'
28
28
 
29
29
  end
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.19.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: 2016-04-05 00:00:00.000000000 Z
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: 2.0.0
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: 2.0.0
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.4.8
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