rails-assets-manifest 1.0.0 → 1.1.0
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/rails/assets/manifest.rb +4 -0
- data/lib/rails/assets/manifest/helper.rb +31 -6
- data/lib/rails/assets/manifest/railtie.rb +12 -1
- data/lib/rails/assets/manifest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf7f05873e248861f8c1e82511a9a2006336acceaed1446555cc0ee9e4262228
|
4
|
+
data.tar.gz: cdfac3bf315ea70fd619c095f156b346e8f0fef8e4710db98e262ad25c080f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ac084087c8b7315975722241c18eef100a4148f10e70fa5f23ca515d26ede428bb222cae792c2cc116abe0873633d726f4dc23807f47622e0228ffbb203f519
|
7
|
+
data.tar.gz: e915fe0abf63b0c369aca79a5199b29f2d2e25927c4fbcd75d8c87adeb9f0e5634f50662d8090de96b69b638ba657e0e7fc4ba1b5be4ca3a81aab8719a31b0ba
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/).
|
5
5
|
|
6
6
|
|
7
|
+
|
7
8
|
## Unreleased
|
8
9
|
---
|
9
10
|
|
@@ -16,6 +17,16 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
|
|
16
17
|
### Breaks
|
17
18
|
|
18
19
|
|
20
|
+
## 1.1.0 - (2019-08-08)
|
21
|
+
---
|
22
|
+
|
23
|
+
### New
|
24
|
+
* Add passthrough option to load assets from other plugins (e.g. sprockets)
|
25
|
+
|
26
|
+
### Changes
|
27
|
+
* Only default to add available integrity if asset is from the manifest
|
28
|
+
|
29
|
+
|
19
30
|
## 1.0.0 - (2019-08-07)
|
20
31
|
---
|
21
32
|
|
@@ -4,10 +4,16 @@ module Rails::Assets::Manifest
|
|
4
4
|
module Helper
|
5
5
|
def compute_asset_path(name, **_kwargs)
|
6
6
|
::Rails::Assets::Manifest.lookup!(name).src
|
7
|
+
rescue EntryMissing => e
|
8
|
+
return super if Rails::Assets::Manifest.passthrough?
|
9
|
+
raise
|
7
10
|
end
|
8
11
|
|
9
12
|
def asset_integrity(name, **kwargs)
|
10
13
|
::Rails::Assets::Manifest.lookup!(path_with_extname(name, **kwargs)).integrity
|
14
|
+
rescue EntryMissing => e
|
15
|
+
return super if Rails::Assets::Manifest.passthrough?
|
16
|
+
raise
|
11
17
|
end
|
12
18
|
|
13
19
|
def javascript_include_tag(*sources, integrity: nil, **kwargs)
|
@@ -36,15 +42,34 @@ module Rails::Assets::Manifest
|
|
36
42
|
|
37
43
|
def with_integrity(sources, required, type, **kwargs)
|
38
44
|
sources.map do |source|
|
39
|
-
|
45
|
+
path = path_with_extname(source, type: type, **kwargs)
|
40
46
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
# integrity hash passed directly
|
48
|
+
if required.is_a?(String)
|
49
|
+
next yield(source, integrity: required, **kwargs)
|
50
|
+
|
51
|
+
# Explicit passed `true` option
|
52
|
+
elsif required
|
53
|
+
integrity = asset_integrity(source, type: type, **kwargs)
|
54
|
+
|
55
|
+
if !integrity
|
56
|
+
raise IntegrityMissing.new "SRI missing for #{path}"
|
57
|
+
end
|
58
|
+
|
59
|
+
next yield(source, integrity: integrity, **kwargs)
|
60
|
+
|
61
|
+
# No integrity option passed or `nil` default from above
|
62
|
+
elsif required.nil?
|
63
|
+
entry = ::Rails::Assets::Manifest.lookup(path)
|
64
|
+
|
65
|
+
# Only if it is an asset from our manifest and there is an integrity
|
66
|
+
# we default to adding one
|
67
|
+
if(entry && entry.integrity)
|
68
|
+
next yield(source, integrity: entry.integrity, **kwargs)
|
69
|
+
end
|
45
70
|
end
|
46
71
|
|
47
|
-
yield(source,
|
72
|
+
yield(source, **kwargs)
|
48
73
|
end.join.html_safe
|
49
74
|
end
|
50
75
|
|
@@ -4,9 +4,20 @@ module Rails
|
|
4
4
|
module Assets
|
5
5
|
module Manifest
|
6
6
|
class Railtie < ::Rails::Railtie
|
7
|
-
|
7
|
+
# If this plugin is used with sprockets this option
|
8
|
+
# already exists and must not be overriden. Otherwise
|
9
|
+
# all sprockets default options are removed breaking
|
10
|
+
# sprockets.
|
11
|
+
config.assets ||= ::ActiveSupport::OrderedOptions.new
|
12
|
+
|
13
|
+
# Path where the manifest file is loaded from.
|
8
14
|
config.assets.manifest = 'public/assets/manifest.json'
|
9
15
|
|
16
|
+
# If set to true missing assets will not raise an
|
17
|
+
# exception but are passed through to sprockets
|
18
|
+
# or rails own asset methods.
|
19
|
+
config.assets.passthrough = false
|
20
|
+
|
10
21
|
config.after_initialize do |_|
|
11
22
|
ActiveSupport.on_load(:action_view) do
|
12
23
|
include Helper
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-assets-manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|