cyborg 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cyborg/middleware.rb +52 -16
- data/lib/cyborg/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: d4391a22814aa388e782af12c327f4497715fbe0
|
4
|
+
data.tar.gz: 7ae0410c27217feaffd69f5a96b1ec57f9e43b77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf962bb6092dc6a91b4012980d8364808bbcddba1765ac504396f45f7c3f11b32246c208cda8d93916078dbb01e0d1ab97b557598c89a65c3f96b1f988d3e19
|
7
|
+
data.tar.gz: cf11a83001d91ef53e665e48c886fbde62f44931c07ab575509394543add2490099c651499377286755be0de4902e93765e7ed7a76dc9ea635b86e695f22d272
|
data/lib/cyborg/middleware.rb
CHANGED
@@ -15,31 +15,67 @@ module Cyborg
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
18
19
|
class StaticAssets
|
19
|
-
def initialize(app, path, index: 'index', headers: {}, engine_name: nil)
|
20
|
-
@app = app
|
21
|
-
@engine_name = engine_name
|
22
|
-
@file_handler = ActionDispatch::FileHandler.new(path, index: index, headers: headers)
|
23
|
-
end
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
# Rails 5 middleware patch
|
22
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
|
23
|
+
|
24
|
+
def initialize(app, path, index: 'index', headers: {}, engine_name: nil)
|
25
|
+
@app = app
|
26
|
+
@engine_name = engine_name
|
27
|
+
@file_handler = ActionDispatch::FileHandler.new(path, index: index, headers: headers)
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
req = Rack::Request.new env
|
32
|
+
prefix = File.join Application.config.assets.prefix, @engine_name
|
28
33
|
|
29
|
-
|
30
|
-
|
34
|
+
if req.get? || req.head?
|
35
|
+
path = req.path_info.chomp('/'.freeze)
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
if path.start_with? prefix
|
38
|
+
path = path.remove /\A#{prefix}\//
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
if match = @file_handler.match?(path)
|
41
|
+
req.path_info = match
|
42
|
+
return @file_handler.serve(req)
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
46
|
+
|
47
|
+
@app.call(req.env)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Rails 4 middleware patch
|
51
|
+
else
|
52
|
+
|
53
|
+
def initialize(app, path, cache_control=nil, engine_name: nil)
|
54
|
+
@app = app
|
55
|
+
@engine_name = engine_name
|
56
|
+
@file_handler = ::ActionDispatch::FileHandler.new(path, cache_control)
|
40
57
|
end
|
41
58
|
|
42
|
-
|
59
|
+
def call(env)
|
60
|
+
prefix = File.join Application.config.assets.prefix, @engine_name
|
61
|
+
|
62
|
+
case env['REQUEST_METHOD']
|
63
|
+
when 'GET', 'HEAD'
|
64
|
+
path = env['PATH_INFO'].chomp('/')
|
65
|
+
|
66
|
+
if path.start_with? prefix
|
67
|
+
path = path.remove /\A#{prefix}\//
|
68
|
+
|
69
|
+
if match = @file_handler.match?(path)
|
70
|
+
env["PATH_INFO"] = match
|
71
|
+
return @file_handler.call(env)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
@app.call(env)
|
77
|
+
end
|
43
78
|
end
|
44
79
|
end
|
80
|
+
|
45
81
|
end
|
data/lib/cyborg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyborg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|