paperclip-remote_assets 0.1.1 → 0.1.2

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: 6481d8da11f4581db7bb6d9560a1ff8730fcf6fd
4
- data.tar.gz: e2560ae2ea2497a7844a147cd0fc53d188b533fa
3
+ metadata.gz: 8f2492873d2b543667d59b27e1355c80c14a692b
4
+ data.tar.gz: dab9d11741e5065c8eb89cfabd313d53c8649961
5
5
  SHA512:
6
- metadata.gz: 33eb6314f6c643e1cda1bc530630a8046f1b44c70de09cdbb63a5b32ecd9428f14c488822e22b3c91791a97d334d2dfe814e3d2461790e7f23b892e49e4e8d65
7
- data.tar.gz: 41e11aaf79923890ee62213a8453738b7b1fea3dc5fcc06553f1dbbdce34b8fa380845877fdcf71422850da4386b99164e785419ccb1e6aaa11dfe79b6ee8acc
6
+ metadata.gz: 66db547ecbd44968c2a8ca688a92f6a1a6fc232c74456cc491bc5fafe4fec2dfc1611ff7bf555dd7207ad2b5f291b020635bfc9f18ba8ecf8441ff04089c65ad
7
+ data.tar.gz: 42d922ab0644cf2abdafd7837de7b81e7781d0740aa125da4f5846a9b09b1f217cfce043ea8c15e5eb063f5e5de106b785726876b7b7adda10337abad49a5c6a
data/README.md CHANGED
@@ -8,7 +8,7 @@ the middleware checks if the file exists in your `public/system` folder and
8
8
  redirects to the remote target if it doesn't.
9
9
 
10
10
  > **Note** : This only works if your local assets storing path matches the
11
- remote one. Your remote path should start with /system/ too.
11
+ remote one.
12
12
 
13
13
  ## Installation
14
14
 
@@ -43,7 +43,19 @@ alternatively, in some initializer or environment file :
43
43
  Paperclip::RemoteAssets.remote_root = 'http://www.my-production-domain.com'
44
44
  ```
45
45
 
46
- That's all.
46
+ If your remote assets root path does not start with `/system`, you can set
47
+ the following flag, so the middleware strips the leading `/system` from the
48
+ requested path.
49
+
50
+ ```bash
51
+ ENV['REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM'] = 'false'
52
+ ```
53
+
54
+ alternatively, in some initializer or environment file :
55
+
56
+ ```ruby
57
+ Paperclip::RemoteAssets.remote_root_includes_system = false
58
+ ```
47
59
 
48
60
  ## Contributing
49
61
 
@@ -1,6 +1,8 @@
1
1
  module Paperclip
2
2
  module RemoteAssets
3
3
  class Middleware
4
+ SYSTEM_PREFIX_REGEX = /\A\/system\//
5
+
4
6
  attr_reader :app
5
7
 
6
8
  def initialize(app)
@@ -18,10 +20,14 @@ module Paperclip
18
20
  private
19
21
 
20
22
  def remote_asset?(path)
21
- path.match(/\A\/system\//) && !File.exist?(Rails.root.join('public', path))
23
+ path.match(SYSTEM_PREFIX_REGEX) && !File.exist?(Rails.root.join('public', path))
22
24
  end
23
25
 
24
26
  def remote_asset_path_for(path)
27
+ unless Paperclip::RemoteAssets.remote_root_includes_system?
28
+ path = path.gsub(SYSTEM_PREFIX_REGEX, '/')
29
+ end
30
+
25
31
  File.join(Paperclip::RemoteAssets.remote_root, path)
26
32
  end
27
33
  end
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module RemoteAssets
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -7,10 +7,19 @@ module Paperclip
7
7
  autoload :Middleware
8
8
 
9
9
  mattr_writer :remote_root
10
+ mattr_writer :remote_root_includes_system
10
11
 
11
12
  def self.remote_root
12
13
  @@remote_root ||= ENV['REMOTE_ASSETS_ROOT']
13
14
  end
15
+
16
+ def self.remote_root_includes_system?
17
+ @@remote_root_includes_system ||= if ENV.key?('REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM')
18
+ ENV['REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM'] == 'true'
19
+ else
20
+ true
21
+ end
22
+ end
14
23
  end
15
24
  end
16
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-remote_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - vala
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails