paperclip-remote_assets 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a4c54f192a36c8cb8d9d6d2e5afc09bbdb1e4c7
4
- data.tar.gz: 4451e2ea53e7ef9eb4253b9542a879f6501c5a7e
3
+ metadata.gz: 6481d8da11f4581db7bb6d9560a1ff8730fcf6fd
4
+ data.tar.gz: e2560ae2ea2497a7844a147cd0fc53d188b533fa
5
5
  SHA512:
6
- metadata.gz: 3a344c7c664fc44964486af885a51adf87cc3524698254d9b9f5f2b2228dccd7575bc80de2ab408dd9e4f6da0c3e1a2d4168912cdfbebff5ea70d4a8b9fcf466
7
- data.tar.gz: 3c868d23c6694a3bb1b1e4d0f422d04576a4e0ba4a009d1f162c0483f9a4dfbdc4f4884878e669642ab861dc34af4e1273555f85580c96b8ff76d8a105cf0fca
6
+ metadata.gz: 33eb6314f6c643e1cda1bc530630a8046f1b44c70de09cdbb63a5b32ecd9428f14c488822e22b3c91791a97d334d2dfe814e3d2461790e7f23b892e49e4e8d65
7
+ data.tar.gz: 41e11aaf79923890ee62213a8453738b7b1fea3dc5fcc06553f1dbbdce34b8fa380845877fdcf71422850da4386b99164e785419ccb1e6aaa11dfe79b6ee8acc
@@ -0,0 +1,11 @@
1
+ module Paperclip
2
+ module RemoteAssets
3
+ class Engine < ::Rails::Engine
4
+ initializer 'paperclip.remote_assets.insert_middleware' do |app|
5
+ if Rails.env.development? && Paperclip::RemoteAssets.remote_root
6
+ app.config.middleware.use Paperclip::RemoteAssets::Middleware
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ module Paperclip
2
+ module RemoteAssets
3
+ class Middleware
4
+ attr_reader :app
5
+
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ if remote_asset?(env['REQUEST_PATH'])
12
+ [302, { 'Location': remote_asset_path_for(env['REQUEST_PATH']) }, []]
13
+ else
14
+ app.call(env)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def remote_asset?(path)
21
+ path.match(/\A\/system\//) && !File.exist?(Rails.root.join('public', path))
22
+ end
23
+
24
+ def remote_asset_path_for(path)
25
+ File.join(Paperclip::RemoteAssets.remote_root, path)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module RemoteAssets
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-remote_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - vala
@@ -84,6 +84,8 @@ files:
84
84
  - bin/console
85
85
  - bin/setup
86
86
  - lib/paperclip/remote_assets.rb
87
+ - lib/paperclip/remote_assets/engine.rb
88
+ - lib/paperclip/remote_assets/middleware.rb
87
89
  - lib/paperclip/remote_assets/version.rb
88
90
  - paperclip-remote_assets.gemspec
89
91
  homepage: https://github.com/glyph-fr/paperclip-remote_assets