rails-assets-manifest 1.1.0 → 2.0.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 +12 -0
- data/README.md +7 -1
- data/lib/rails/assets/manifest.rb +1 -1
- data/lib/rails/assets/manifest/manifest.rb +20 -10
- data/lib/rails/assets/manifest/railtie.rb +2 -2
- data/lib/rails/assets/manifest/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f22a9a97254698d652e6724a019c23db31f7a3550c31cd8b69dc1697103cd8
|
4
|
+
data.tar.gz: a4bc81e134d549c8cb8001403281fa4b4c535b44e1598a77d2a7c10b74851c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6abbeff6a818cbe8ceff2f5737c564c336baded7d58df41508a0ae0e28b32021e1bfadd0fef206c6c6df30acc709002a343ebe1d1e2afdf70d3708f6caef9fb4
|
7
|
+
data.tar.gz: 6ac071032f401ac1aae354a4de86189e665918be1060104fa3a83a8dfeb645fb345a70b24b7455c4bce1074315232e70425df9e837c01d54f9e187bb401c1a67
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,18 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
|
|
17
17
|
### Breaks
|
18
18
|
|
19
19
|
|
20
|
+
## 2.0.0 - (2019-08-08)
|
21
|
+
---
|
22
|
+
|
23
|
+
### New
|
24
|
+
* Accept glob patterns for `manifests` option
|
25
|
+
|
26
|
+
|
27
|
+
### Breaks
|
28
|
+
* Change `manifest` configuration option into `manifests` to support multiple files
|
29
|
+
* Change configuration option into to support multiple files
|
30
|
+
|
31
|
+
|
20
32
|
## 1.1.0 - (2019-08-08)
|
21
33
|
---
|
22
34
|
|
data/README.md
CHANGED
@@ -44,13 +44,19 @@ gem 'rails-assets-manifest'
|
|
44
44
|
The manifest path can be configured e.g. in an environment:
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
config.assets.
|
47
|
+
config.assets.manifests = %w(public/.asset-manifest.json)
|
48
48
|
```
|
49
49
|
|
50
50
|
If `config.cache_classes` is set to `true` the manifest file be loaded once on boot and raise errors if missing or invalid.
|
51
51
|
|
52
52
|
Assets included with `integrity: true` will raise an error if the integrity option is missing in the manifest.
|
53
53
|
|
54
|
+
Multiple manifests can be loaded by specifying multiple files. Glob patterns are supported:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
config.assets.manifests = %w(public/.manifest.*.json lib/manifest.json)
|
58
|
+
```
|
59
|
+
|
54
60
|
## TODO
|
55
61
|
|
56
62
|
* Override/Join with `asset_host` URL?
|
@@ -4,8 +4,8 @@ module Rails::Assets::Manifest
|
|
4
4
|
class Manifest
|
5
5
|
attr_reader :path
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(files:, cache: true)
|
8
|
+
@files = Array(files).flatten.each(&:freeze).freeze
|
9
9
|
@cache = cache
|
10
10
|
|
11
11
|
data if cache?
|
@@ -22,12 +22,16 @@ module Rails::Assets::Manifest
|
|
22
22
|
def lookup!(name)
|
23
23
|
lookup(name) || begin
|
24
24
|
raise EntryMissing.new <<~ERROR
|
25
|
-
Can't find #{name} in #{path}. Your
|
25
|
+
Can't find #{name} in #{path}. Your manifests contain:
|
26
26
|
#{JSON.pretty_generate(data.keys)}
|
27
27
|
ERROR
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def key?(name)
|
32
|
+
data.key?(name.to_s)
|
33
|
+
end
|
34
|
+
|
31
35
|
private
|
32
36
|
|
33
37
|
Entry = Struct.new(:src, :integrity) do
|
@@ -44,14 +48,20 @@ module Rails::Assets::Manifest
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
def files
|
52
|
+
@files.map {|path| Dir.glob(path) }.flatten
|
53
|
+
end
|
54
|
+
|
47
55
|
def load
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
files.each_with_object({}) do |file, entries|
|
57
|
+
JSON.parse(File.read(file)).each_pair do |key, entry|
|
58
|
+
if entry.is_a?(String)
|
59
|
+
entries[key] = Entry.new(entry, nil)
|
60
|
+
elsif entry.is_a?(Hash) && entry.key?('src')
|
61
|
+
entries[key] = Entry.new(entry['src'], entry['integrity'])
|
62
|
+
else
|
63
|
+
raise "Invalid manifest entry: #{entry.inspect}"
|
64
|
+
end
|
55
65
|
end
|
56
66
|
end
|
57
67
|
rescue Errno::ENOENT => e
|
@@ -10,8 +10,8 @@ module Rails
|
|
10
10
|
# sprockets.
|
11
11
|
config.assets ||= ::ActiveSupport::OrderedOptions.new
|
12
12
|
|
13
|
-
# Path where the manifest
|
14
|
-
config.assets.
|
13
|
+
# Path where the manifest files are loaded from.
|
14
|
+
config.assets.manifests = ['public/assets/manifest.json']
|
15
15
|
|
16
16
|
# If set to true missing assets will not raise an
|
17
17
|
# exception but are passed through to sprockets
|