actionview-rev_manifest 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -2
- data/Rakefile +1 -1
- data/lib/actionview-rev_manifest.rb +10 -2
- data/lib/rev_manifest/actionview/base.rb +12 -6
- data/lib/rev_manifest/railtie.rb +13 -0
- data/lib/rev_manifest/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 481885e74b670eebecc555d9f797d2857745ffdf
|
4
|
+
data.tar.gz: b2b4fb55930c82c9a9c3dfd23763886539da048e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffc5a874529d219ea372931b7d322084460bbefd24ea914d2af13e6c51c38ece3c24bec3c959065150dc132b262e5c8d1c79008290a31eb61c135af92178aea4
|
7
|
+
data.tar.gz: 269dd0d2c20aae40c808f8d9fd87b136139771ad4eb6597496847593839a5ac58b4732f95827a0d6bb1f342c3491858c0cf64fcede742b64c44b0b87ec9573fa
|
data/README.md
CHANGED
@@ -19,9 +19,30 @@ bundle install
|
|
19
19
|
## Setup
|
20
20
|
|
21
21
|
```rb
|
22
|
-
#config/
|
22
|
+
# config/environments/production.rb
|
23
23
|
|
24
|
-
|
24
|
+
MyApp::Application.config do
|
25
|
+
config.rev_manifest.enabled = true
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
### With Sprockets
|
30
|
+
|
31
|
+
If you want to serve some assets with RevManifest and rest of them with Sprockets, specify all
|
32
|
+
sources' name, which you want to serve with RevManifest, as `config.rev_manifest.sources`:
|
33
|
+
|
34
|
+
```rb
|
35
|
+
MyApp::Application.config do
|
36
|
+
config.rev_manifest.sources = ["new_application.js", "new_application.css"]
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
In addition, make sure that sprockets is loaded ahead:
|
41
|
+
|
42
|
+
```rb
|
43
|
+
# Gemfile
|
44
|
+
gem "sprockets"
|
45
|
+
gem "actionview-rev_manifest"
|
25
46
|
```
|
26
47
|
|
27
48
|
## Sample gulpfile.coffee
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
@@ -1,5 +1,6 @@
|
|
1
|
-
require "rev_manifest/version"
|
2
1
|
require "rev_manifest/actionview/base"
|
2
|
+
require "rev_manifest/railtie"
|
3
|
+
require "rev_manifest/version"
|
3
4
|
|
4
5
|
module RevManifest
|
5
6
|
DEFAULT_ASSET_PUBLIC_DIRECTORIES = {
|
@@ -25,7 +26,8 @@ module RevManifest
|
|
25
26
|
DEFAULT_MANIFEST_PATH = "public/assets/rev-manifest.json"
|
26
27
|
|
27
28
|
class << self
|
28
|
-
attr_writer :enabled, :asset_prefixes, :asset_public_directories, :asset_root, :manifest_path
|
29
|
+
attr_writer :enabled, :asset_prefixes, :asset_public_directories, :asset_root, :manifest_path,
|
30
|
+
:sources
|
29
31
|
|
30
32
|
# @return [true, false]
|
31
33
|
def enabled?
|
@@ -37,6 +39,12 @@ module RevManifest
|
|
37
39
|
@asset_public_directories || DEFAULT_ASSET_PUBLIC_DIRECTORIES
|
38
40
|
end
|
39
41
|
|
42
|
+
# @return [true, false]
|
43
|
+
def include?(source)
|
44
|
+
return false unless @sources
|
45
|
+
@sources == :all ? true : @sources.include?(source)
|
46
|
+
end
|
47
|
+
|
40
48
|
# @return [String]
|
41
49
|
def resolve(source, options)
|
42
50
|
asset_root + manifest[asset_prefixes[options[:type]] + source]
|
@@ -1,13 +1,19 @@
|
|
1
1
|
module ActionView
|
2
2
|
class Base
|
3
|
-
# @note
|
4
|
-
def
|
5
|
-
if RevManifest.
|
6
|
-
RevManifest.
|
3
|
+
# @note Patch {ActionView::Helpers::AssetUrlHelper#compute_asset_path}.
|
4
|
+
def compute_asset_path_with_rev_manifest(source, options = {})
|
5
|
+
if RevManifest.include?(source)
|
6
|
+
if RevManifest.enabled?
|
7
|
+
RevManifest.resolve(source, options)
|
8
|
+
else
|
9
|
+
dir = RevManifest.asset_public_directories[options[:type]] || ""
|
10
|
+
File.join(dir, source)
|
11
|
+
end
|
7
12
|
else
|
8
|
-
|
9
|
-
File.join(dir, source)
|
13
|
+
compute_asset_path_without_rev_manifest(source, options)
|
10
14
|
end
|
11
15
|
end
|
16
|
+
|
17
|
+
alias_method_chain :compute_asset_path, :rev_manifest
|
12
18
|
end
|
13
19
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RevManifest
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
config.rev_manifest = ActiveSupport::OrderedOptions.new
|
4
|
+
|
5
|
+
config.rev_manifest.enabled = false
|
6
|
+
config.rev_manifest.sources = :all
|
7
|
+
|
8
|
+
initializer "rev_manifest.config", group: :all do |app|
|
9
|
+
RevManifest.enabled = app.config.rev_manifest.enabled
|
10
|
+
RevManifest.sources = app.config.rev_manifest.sources
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/rev_manifest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview-rev_manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuku Takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- actionview-rev_manifest.gemspec
|
83
83
|
- lib/actionview-rev_manifest.rb
|
84
84
|
- lib/rev_manifest/actionview/base.rb
|
85
|
+
- lib/rev_manifest/railtie.rb
|
85
86
|
- lib/rev_manifest/version.rb
|
86
87
|
homepage: https://github.com/yuku-t/actionview-rev_manifest
|
87
88
|
licenses:
|