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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82bc5755ca9c2513786f46e4cc522771af004199
4
- data.tar.gz: 60d535e47177d591f0dee474cba3b0b532468ab4
3
+ metadata.gz: d4391a22814aa388e782af12c327f4497715fbe0
4
+ data.tar.gz: 7ae0410c27217feaffd69f5a96b1ec57f9e43b77
5
5
  SHA512:
6
- metadata.gz: d18429cc529df9ae3551625f8d77aed1708acbf57429b091b74e2e32d272a59ad4b11559abedc89c95a95e5885c3e8f7ad62b3077150afa3259e6fd62234f3a9
7
- data.tar.gz: b943de6964048a25deaa5bcd5adc3a702d8e8b0f3c1c1392ddfa19d288f1d0e09ce70da281a43c8b827870e30b4f34e01ce4542892d40bb00952ff86a67b4c5f
6
+ metadata.gz: ccf962bb6092dc6a91b4012980d8364808bbcddba1765ac504396f45f7c3f11b32246c208cda8d93916078dbb01e0d1ab97b557598c89a65c3f96b1f988d3e19
7
+ data.tar.gz: cf11a83001d91ef53e665e48c886fbde62f44931c07ab575509394543add2490099c651499377286755be0de4902e93765e7ed7a76dc9ea635b86e695f22d272
@@ -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
- def call(env)
26
- req = Rack::Request.new env
27
- prefix = File.join Application.config.assets.prefix, @engine_name
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
- if req.get? || req.head?
30
- path = req.path_info.chomp('/'.freeze)
34
+ if req.get? || req.head?
35
+ path = req.path_info.chomp('/'.freeze)
31
36
 
32
- if path.start_with? prefix
33
- path = path.remove /\A#{prefix}\//
37
+ if path.start_with? prefix
38
+ path = path.remove /\A#{prefix}\//
34
39
 
35
- if match = @file_handler.match?(path)
36
- req.path_info = match
37
- return @file_handler.serve(req)
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
- @app.call(req.env)
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
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass