checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: cf7f05873e248861f8c1e82511a9a2006336acceaed1446555cc0ee9e4262228
4
- data.tar.gz: cdfac3bf315ea70fd619c095f156b346e8f0fef8e4710db98e262ad25c080f11
3
+ metadata.gz: 31f22a9a97254698d652e6724a019c23db31f7a3550c31cd8b69dc1697103cd8
4
+ data.tar.gz: a4bc81e134d549c8cb8001403281fa4b4c535b44e1598a77d2a7c10b74851c6f
5
5
SHA512:
6
- metadata.gz: 8ac084087c8b7315975722241c18eef100a4148f10e70fa5f23ca515d26ede428bb222cae792c2cc116abe0873633d726f4dc23807f47622e0228ffbb203f519
7
- data.tar.gz: e915fe0abf63b0c369aca79a5199b29f2d2e25927c4fbcd75d8c87adeb9f0e5634f50662d8090de96b69b638ba657e0e7fc4ba1b5be4ca3a81aab8719a31b0ba
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.manifest = "public/.asset-manifest.json"
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?
data/lib/rails/assets/manifest.rb CHANGED
@@ -25,7 +25,7 @@ module Rails
25
25
config = Rails.application.config
26
26
27
27
Manifest.new \
28
- path: config.assets.manifest,
28
+ files: config.assets.manifests,
29
29
cache: config.cache_classes
30
30
end
31
31
end
data/lib/rails/assets/manifest/manifest.rb CHANGED
@@ -4,8 +4,8 @@ module Rails::Assets::Manifest
4
4
class Manifest
5
5
attr_reader :path
6
6
7
- def initialize(path:, cache: true)
8
- @path = path.to_s.freeze
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 manifest contains:
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
- JSON.parse(File.read(path)).transform_values do |entry|
49
- if entry.is_a?(String)
50
- Entry.new(entry, nil)
51
- elsif entry.is_a?(Hash)
52
- Entry.new(entry.fetch('src'), entry['integrity'])
53
- else
54
- raise "Invalid entry: #{entry.inspect}"
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
data/lib/rails/assets/manifest/railtie.rb CHANGED
@@ -10,8 +10,8 @@ module Rails
10
10
# sprockets.
11
11
config.assets ||= ::ActiveSupport::OrderedOptions.new
12
12
13
- # Path where the manifest file is loaded from.
14
- config.assets.manifest = 'public/assets/manifest.json'
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
data/lib/rails/assets/manifest/version.rb CHANGED
@@ -4,8 +4,8 @@ module Rails
4
4
module Assets
5
5
module Manifest
6
6
module VERSION
7
- MAJOR = 1
8
- MINOR = 1
7
+ MAJOR = 2
8
+ MINOR = 0
9
9
PATCH = 0
10
10
STAGE = nil
11
11
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: rails-assets-manifest
3
3
version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
platform: ruby
6
6
authors:
7
7
- Jan Graichen