rails-assets-manifest 2.0.0 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31f22a9a97254698d652e6724a019c23db31f7a3550c31cd8b69dc1697103cd8
4
- data.tar.gz: a4bc81e134d549c8cb8001403281fa4b4c535b44e1598a77d2a7c10b74851c6f
3
+ metadata.gz: f74ada8a7abade960a8bbb990ef4bcf5b9f042e09024d1de5b39cbf1a2ccf1ec
4
+ data.tar.gz: d45b22c32fe3981382d47c9680e3102e48c2d30211c24a1eac1e7baab8cd24a6
5
5
  SHA512:
6
- metadata.gz: 6abbeff6a818cbe8ceff2f5737c564c336baded7d58df41508a0ae0e28b32021e1bfadd0fef206c6c6df30acc709002a343ebe1d1e2afdf70d3708f6caef9fb4
7
- data.tar.gz: 6ac071032f401ac1aae354a4de86189e665918be1060104fa3a83a8dfeb645fb345a70b24b7455c4bce1074315232e70425df9e837c01d54f9e187bb401c1a67
6
+ metadata.gz: d993c84c80510ab83df09c15838c8a07fc909d8d90b7891f340fb7501319bbac75d934d8f5fbfc52864d62ed47c560da9bbd93687b2d9dc5ce3d8d6abac94ec1
7
+ data.tar.gz: a6543487813204d1061a4db57edaaa3fe721c90b51f71ca787d2d858873719491a71e159ffa1618cb2edd5e579e77eefeb16771aff81313cdec9d66e2f36c421
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: test
3
+ on: push
4
+ jobs:
5
+ rspec:
6
+ name: "Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}"
7
+ runs-on: ubuntu-20.04
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby:
13
+ - "3.0"
14
+ - "2.7"
15
+ - "2.6"
16
+ - "2.5"
17
+ rails:
18
+ - "6.1"
19
+ - "6.0"
20
+ - "5.2"
21
+ - master
22
+ exclude:
23
+ - ruby: "3.0"
24
+ rails: "5.2"
25
+ - ruby: "2.6"
26
+ rails: master
27
+ - ruby: "2.5"
28
+ rails: master
29
+
30
+ env:
31
+ BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
32
+
33
+ steps:
34
+ - uses: actions/checkout@master
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+ env:
40
+ BUNDLE_WITHOUT: development
41
+ BUNDLE_JOBS: 4
42
+ BUNDLE_RETRY: 3
43
+
44
+ - run: bundle exec rspec --color
45
+
46
+ rubocop:
47
+ name: rubocop
48
+ runs-on: ubuntu-20.04
49
+
50
+ steps:
51
+ - uses: actions/checkout@master
52
+ - uses: ruby/setup-ruby@v1
53
+ with:
54
+ ruby-version: 3.0
55
+ bundler-cache: true
56
+ env:
57
+ BUNDLE_WITHOUT: development
58
+ BUNDLE_JOBS: 4
59
+ BUNDLE_RETRY: 3
60
+
61
+ - run: bundle exec rubocop --parallel --fail-level E
data/.gitignore CHANGED
@@ -3,6 +3,8 @@
3
3
  /coverage
4
4
  /doc
5
5
  /pkg
6
+ /spec/dummy/log
7
+ /spec/dummy/tmp
6
8
  /spec/examples.txt
7
9
  /tmp
8
10
  /vendor/bundle
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
- --format documentation
1
+ --backtrace
2
2
  --color
3
+ --format documentation
3
4
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,106 +1,18 @@
1
- require:
2
- - rubocop-rspec
3
-
4
1
  AllCops:
5
- Exclude:
6
- - 'bin/**'
7
- - 'config/initializers/integration*'
8
- - 'db/schema.rb'
9
- - 'vendor/**'
10
- TargetRubyVersion: 2.5
11
- TargetRailsVersion: 5.2
12
-
13
-
14
-
15
- # -----------------------------------------------------------------------------
16
- # RAILS
17
-
18
- Rails:
19
- Enabled: true
20
-
21
- #
22
- # False positives:
23
- # * On Acfs::Resource#update_attriubutes!
24
- #
25
- Rails/ActiveRecordAliases:
26
- Exclude:
27
- - spec/**/*_spec.rb
28
-
29
- #
30
- # False positives:
31
- # * On embedded models in migrations.
32
- #
33
- Rails/ApplicationRecord:
34
- Exclude:
35
- - 'db/**/*'
36
-
37
- #
38
- # Often when triggered it just wants to pass joined paths as separate
39
- # arguments but that can hurt readability.
40
- #
41
- Rails/FilePath:
42
- Enabled: false
43
-
44
- #
45
- # False positives:
46
- # * Specs and migrations often need to update things without validations.
47
- #
48
- Rails/SkipsModelValidations:
49
- Exclude:
50
- - 'db/migrations/**.rb'
51
- - 'spec/**/*_spec.rb'
52
-
53
-
54
-
55
- # -----------------------------------------------------------------------------
56
- # RSPEC
57
-
58
- RSpec:
59
2
  Include:
60
- - 'spec/**/*_spec.rb'
61
- - 'spec/spec_helper.rb'
62
- - 'spec/rails_helper.rb'
63
-
64
- RSpec/ContextWording:
65
- Enabled: false
66
-
67
- RSpec/ExampleLength:
68
- Enabled: false
69
-
70
- RSpec/ExpectInHook:
71
- Enabled: false
72
-
73
- RSpec/FilePath:
74
- Exclude:
75
- - 'spec/client/**/*_spec.rb'
76
-
77
- RSpec/MessageSpies:
78
- Enabled: false
79
-
80
- RSpec/MissingExampleGroupArgument:
81
- Enabled: false
82
-
83
- RSpec/MultipleExpectations:
84
- Enabled: false
85
-
86
- RSpec/NestedGroups:
87
- Max: 5
88
-
89
- # -----------------------------------------------------------------------------
90
- # Layout
91
-
92
- Layout/AlignParameters:
93
- EnforcedStyle: with_fixed_indentation
3
+ - '**/*.rb'
4
+ TargetRubyVersion: 2.5
5
+ NewCops: enable
94
6
 
95
7
  Layout/CaseIndentation:
96
8
  EnforcedStyle: end
9
+ IndentOneStep: true
97
10
  SupportedStyles:
98
11
  - case
99
12
  - end
100
- IndentOneStep: true
101
13
 
102
- Layout/MultilineMethodCallIndentation:
103
- EnforcedStyle: indented
14
+ Layout/ArgumentAlignment:
15
+ EnforcedStyle: with_fixed_indentation
104
16
 
105
17
  Layout/SpaceInsideBlockBraces:
106
18
  EnforcedStyle: space
@@ -111,101 +23,26 @@ Layout/SpaceInsideHashLiteralBraces:
111
23
  EnforcedStyle: no_space
112
24
 
113
25
 
114
-
115
- # -----------------------------------------------------------------------------
116
- # Lint
117
-
118
- #
119
- # False positives:
120
- # * expect { something }.to change { something } often triggers this
121
- #
122
- Lint/AmbiguousBlockAssociation:
123
- Exclude:
124
- - 'spec/**/*_spec.rb'
125
-
126
-
127
-
128
- # -----------------------------------------------------------------------------
129
- # Metrics
130
-
131
26
  Metrics/BlockLength:
132
27
  Exclude:
133
- - 'db/**/*'
134
- - 'spec/**/*'
135
- - 'config/**/*'
136
- - '**/*.rake'
137
-
138
- Metrics/ClassLength:
139
- Max: 200
28
+ - spec/**/*_spec.rb
140
29
 
141
30
  Metrics/LineLength:
142
31
  Exclude:
143
- - 'db/**/*'
144
- - 'spec/**/*'
145
- - 'config/**/*'
146
-
147
- Metrics/MethodLength:
148
- Exclude:
149
- - 'db/**/*'
150
-
151
-
152
-
153
- # -----------------------------------------------------------------------------
154
- # Style
32
+ - spec/**/*_spec.rb
155
33
 
156
- Style/BracesAroundHashParameters:
157
- EnforcedStyle: context_dependent
158
34
 
159
- #
160
- # Both styles or mixtures are reasonable
161
- #
162
35
  Style/ClassAndModuleChildren:
163
- EnforcedStyle: compact
164
36
  Enabled: false
165
37
 
166
- #
167
- # Would be better but unlikely...
168
- #
169
38
  Style/Documentation:
170
39
  Enabled: false
171
40
 
172
- #
173
- # Scripts might include on top-level
174
- #
175
- Style/MixinUsage:
176
- Exclude:
177
- - 'scripts/**/*'
178
-
179
41
  Style/RaiseArgs:
180
42
  EnforcedStyle: compact
181
43
 
182
- #
183
- # Quick single line rescues in specs
184
- #
185
- Style/RescueModifier:
186
- Exclude:
187
- - 'spec/**/*_spec.rb'
188
-
189
- #
190
- # Quick single line rescues in specs
191
- #
192
- Style/RescueStandardError:
193
- Exclude:
194
- - 'spec/**/*_spec.rb'
195
-
196
- #
197
- # Often used pattern in chaining subjects in specs
198
- #
199
- Style/Semicolon:
200
- Exclude:
201
- - 'spec/**/*_spec.rb'
202
-
203
44
  Style/SignalException:
204
45
  EnforcedStyle: only_raise
205
46
 
206
- Style/TrailingCommaInArrayLiteral:
207
- EnforcedStyleForMultiline: comma
208
-
209
- Style/TrailingCommaInHashLiteral:
210
- EnforcedStyleForMultiline: comma
211
-
47
+ Style/TrivialAccessors:
48
+ AllowPredicates: true
data/Appraisals ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-6.1' do
4
+ gem 'rails', '~> 6.1.0'
5
+ end
6
+
7
+ appraise 'rails-6.0' do
8
+ gem 'rails', '~> 6.0.0'
9
+ end
10
+
11
+ appraise 'rails-5.2' do
12
+ gem 'rails', '~> 5.2.0'
13
+ end
14
+
15
+ appraise 'rails-master' do
16
+ gem 'rails', github: 'rails/rails'
17
+ end
data/CHANGELOG.md CHANGED
@@ -17,6 +17,38 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
17
17
  ### Breaks
18
18
 
19
19
 
20
+ ## 2.1.2 - (2021-09-05)
21
+ ---
22
+
23
+ ### Fixes
24
+ * Return correct fully qualified URLs from manifest when relative URL host or asset host is configured
25
+
26
+
27
+ ## 2.1.1 - (2021-06-20)
28
+ ---
29
+
30
+ ### Fixes
31
+ * Super method signature for keyword arguments
32
+
33
+
34
+ ## 2.1.0 - (2019-09-11)
35
+ ---
36
+
37
+ ### New
38
+ * Automatically add `crossorigin="anonymous"` for SRI resources
39
+ * Separate manifest caching and eager loading
40
+
41
+ ### Changes
42
+ * Remove defunct onboot manifest validation (f3fe8f57)
43
+
44
+
45
+ ## 2.0.1 - (2019-08-09)
46
+ ---
47
+
48
+ ### Fixes
49
+ * Fix check if assets option node already exists
50
+
51
+
20
52
  ## 2.0.0 - (2019-08-08)
21
53
  ---
22
54
 
@@ -26,7 +58,6 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
26
58
 
27
59
  ### Breaks
28
60
  * Change `manifest` configuration option into `manifests` to support multiple files
29
- * Change configuration option into to support multiple files
30
61
 
31
62
 
32
63
  ## 1.1.0 - (2019-08-08)
data/Gemfile CHANGED
@@ -5,5 +5,15 @@ source 'https://rubygems.org'
5
5
  # Load gem's dependencies
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 12.0'
8
+ gem 'rails'
9
+
10
+ gem 'rake', '~> 13.0'
9
11
  gem 'rspec', '~> 3.0'
12
+ gem 'rspec-rails', '~> 5.0'
13
+ gem 'rubocop', '~> 1.14'
14
+
15
+ gem 'pry'
16
+
17
+ group :development do
18
+ gem 'appraisal'
19
+ end
data/README.md CHANGED
@@ -17,7 +17,7 @@ This gem does not make any assumption on which tool to use to make your assets n
17
17
  }
18
18
  ```
19
19
 
20
- This gem does not add new helper methods but extends the existing helpers. SRI is automatically added if available and within a secure context:
20
+ This gem does not add new helper methods but extends the existing helpers. SRI is automatically added if available and within a secure context. A `crossorigin="anonymous"` attribute is automatically added if non is present.
21
21
 
22
22
  ```slim
23
23
  html
@@ -27,8 +27,8 @@ html
27
27
  ```
28
28
 
29
29
  ```html
30
- <link rel="stylesheet" media="all" href="2b16adf6f756625a0194.css" integrity="sha384-/oreyvcV6U6htGZD0fDWR8/Txezke8KhD0QNgHb660hSaW7M+ZzxxuB4Vo+PuAC9">
31
- <script src="2b16adf6f756625a0194.js" integrity="sha384-iJ55fQQApbQGxWEWSbWStBabi+yNGxZSQy/010+1Dhxl+rymyhGF4NtjUkOsYv7B"></script>
30
+ <link rel="stylesheet" media="all" href="2b16adf6f756625a0194.css" integrity="sha384-/oreyvcV6U6htGZD0fDWR8/Txezke8KhD0QNgHb660hSaW7M+ZzxxuB4Vo+PuAC9" crossorigin="anonymous">
31
+ <script src="2b16adf6f756625a0194.js" integrity="sha384-iJ55fQQApbQGxWEWSbWStBabi+yNGxZSQy/010+1Dhxl+rymyhGF4NtjUkOsYv7B" crossorigin="anonymous"></script>
32
32
  ```
33
33
 
34
34
  ## Installation
@@ -47,7 +47,7 @@ The manifest path can be configured e.g. in an environment:
47
47
  config.assets.manifests = %w(public/.asset-manifest.json)
48
48
  ```
49
49
 
50
- If `config.cache_classes` is set to `true` the manifest file be loaded once on boot and raise errors if missing or invalid.
50
+ If `config.cache_classes` is set to `true` the manifest file be loaded once on boot.
51
51
 
52
52
  Assets included with `integrity: true` will raise an error if the integrity option is missing in the manifest.
53
53
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'rails/assets/manifest'
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.2.0"
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rspec-rails", "~> 5.0"
9
+ gem "rubocop", "~> 1.14"
10
+ gem "pry"
11
+
12
+ group :development do
13
+ gem "appraisal"
14
+ end
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rspec-rails", "~> 5.0"
9
+ gem "rubocop", "~> 1.14"
10
+ gem "pry"
11
+
12
+ group :development do
13
+ gem "appraisal"
14
+ end
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.1.0"
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rspec-rails", "~> 5.0"
9
+ gem "rubocop", "~> 1.14"
10
+ gem "pry"
11
+
12
+ group :development do
13
+ gem "appraisal"
14
+ end
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", github: "rails/rails"
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rspec-rails", "~> 5.0"
9
+ gem "rubocop", "~> 1.14"
10
+ gem "pry"
11
+
12
+ group :development do
13
+ gem "appraisal"
14
+ end
15
+
16
+ gemspec path: "../"
@@ -2,22 +2,44 @@
2
2
 
3
3
  module Rails::Assets::Manifest
4
4
  module Helper
5
- def compute_asset_path(name, **_kwargs)
5
+ URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}i.freeze
6
+
7
+ def path_to_asset(source, options)
8
+ if (entry = ::Rails::Assets::Manifest.lookup(path_with_extname(source, options)))
9
+ # Directly return the entry src if it is a fully qualified URL. Otherwise,
10
+ # Rails will join the URL with `relative_url_root` and/or asset host.
11
+ return entry.src if URI_REGEXP.match?(entry.src)
12
+
13
+ if entry.src[0] == '/'
14
+ # When the asset name starts with a slash, Rails will skip an
15
+ # additional lookup via `#compute_asset_path` and directly use the
16
+ # provided path. As we already have looked up the manifest entry here,
17
+ # we can pass the entry source, but only *if* it starts with a slash.
18
+ return super entry.src, options
19
+ end
20
+ end
21
+
22
+ super
23
+ end
24
+
25
+ def compute_asset_path(name, _options)
6
26
  ::Rails::Assets::Manifest.lookup!(name).src
7
- rescue EntryMissing => e
27
+ rescue EntryMissing
8
28
  return super if Rails::Assets::Manifest.passthrough?
29
+
9
30
  raise
10
31
  end
11
32
 
12
- def asset_integrity(name, **kwargs)
13
- ::Rails::Assets::Manifest.lookup!(path_with_extname(name, **kwargs)).integrity
14
- rescue EntryMissing => e
33
+ def asset_integrity(name, options)
34
+ ::Rails::Assets::Manifest.lookup!(path_with_extname(name, options)).integrity
35
+ rescue EntryMissing
15
36
  return super if Rails::Assets::Manifest.passthrough?
37
+
16
38
  raise
17
39
  end
18
40
 
19
41
  def javascript_include_tag(*sources, integrity: nil, **kwargs)
20
- return super(*sources, **kwargs) unless compute_integrity?(integrity)
42
+ return super(*sources, **kwargs) unless manifest_use_integrity?(integrity)
21
43
 
22
44
  with_integrity(sources, integrity, :javascript, **kwargs) do |source, options|
23
45
  super(source, options)
@@ -25,7 +47,7 @@ module Rails::Assets::Manifest
25
47
  end
26
48
 
27
49
  def stylesheet_link_tag(*sources, integrity: nil, **kwargs)
28
- return super(*sources, **kwargs) unless compute_integrity?(integrity)
50
+ return super(*sources, **kwargs) unless manifest_use_integrity?(integrity)
29
51
 
30
52
  with_integrity(sources, integrity, :stylesheet, **kwargs) do |source, options|
31
53
  super(source, options)
@@ -34,48 +56,57 @@ module Rails::Assets::Manifest
34
56
 
35
57
  private
36
58
 
37
- def compute_integrity?(option)
38
- return false unless secure_subresource_integrity_context?
59
+ def manifest_use_integrity?(option)
60
+ return false unless secure_request_context?
39
61
 
40
62
  option || option.nil?
41
63
  end
42
64
 
65
+ # http://www.w3.org/TR/SRI/#non-secure-contexts-remain-non-secure
66
+ def secure_request_context?
67
+ respond_to?(:request) && request && (request.local? || request.ssl?)
68
+ end
69
+
70
+ # rubocop:disable Metrics/AbcSize
71
+ # rubocop:disable Metrics/CyclomaticComplexity
72
+ # rubocop:disable Metrics/MethodLength
73
+ # rubocop:disable Style/IfUnlessModifier
43
74
  def with_integrity(sources, required, type, **kwargs)
44
75
  sources.map do |source|
45
76
  path = path_with_extname(source, type: type, **kwargs)
46
77
 
47
78
  # integrity hash passed directly
48
79
  if required.is_a?(String)
49
- next yield(source, integrity: required, **kwargs)
80
+ next yield(source, integrity: required, crossorigin: 'anonymous', **kwargs)
81
+ end
50
82
 
51
83
  # Explicit passed `true` option
52
- elsif required
84
+ if required
53
85
  integrity = asset_integrity(source, type: type, **kwargs)
54
86
 
55
- if !integrity
56
- raise IntegrityMissing.new "SRI missing for #{path}"
57
- end
87
+ raise IntegrityMissing.new "SRI missing for #{path}" unless integrity
58
88
 
59
- next yield(source, integrity: integrity, **kwargs)
89
+ next yield(source, integrity: integrity, crossorigin: 'anonymous', **kwargs)
90
+ end
60
91
 
61
92
  # No integrity option passed or `nil` default from above
62
- elsif required.nil?
93
+ if required.nil?
63
94
  entry = ::Rails::Assets::Manifest.lookup(path)
64
95
 
65
96
  # Only if it is an asset from our manifest and there is an integrity
66
97
  # we default to adding one
67
- if(entry && entry.integrity)
68
- next yield(source, integrity: entry.integrity, **kwargs)
98
+ if entry && entry.integrity
99
+ next yield(source, integrity: entry.integrity, crossorigin: 'anonymous', **kwargs)
69
100
  end
70
101
  end
71
102
 
72
103
  yield(source, **kwargs)
73
104
  end.join.html_safe
74
105
  end
75
-
76
- def secure_subresource_integrity_context?
77
- respond_to?(:request) && (request&.local? || request&.ssl?)
78
- end
106
+ # rubocop:enable Style/IfUnlessModifier
107
+ # rubocop:enable Metrics/MethodLength
108
+ # rubocop:enable Metrics/CyclomaticComplexity
109
+ # rubocop:enable Metrics/AbcSize
79
110
 
80
111
  def path_with_extname(path, options)
81
112
  path = path.to_s
@@ -7,8 +7,6 @@ module Rails::Assets::Manifest
7
7
  def initialize(files:, cache: true)
8
8
  @files = Array(files).flatten.each(&:freeze).freeze
9
9
  @cache = cache
10
-
11
- data if cache?
12
10
  end
13
11
 
14
12
  def cache?
@@ -32,6 +30,10 @@ module Rails::Assets::Manifest
32
30
  data.key?(name.to_s)
33
31
  end
34
32
 
33
+ def eager_load!
34
+ data
35
+ end
36
+
35
37
  private
36
38
 
37
39
  Entry = Struct.new(:src, :integrity) do
@@ -68,7 +70,7 @@ module Rails::Assets::Manifest
68
70
  raise ManifestMissing.new <<~ERROR
69
71
  Asset manifest does not exist: #{e}
70
72
  ERROR
71
- rescue => e
73
+ rescue StandardError => e
72
74
  raise ManifestInvalid.new <<~ERROR
73
75
  Asset manifest could not be loaded: #{e}
74
76
  ERROR
@@ -5,10 +5,10 @@ module Rails
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
8
+ # already exists and must not be overridden. Otherwise
9
9
  # all sprockets default options are removed breaking
10
10
  # sprockets.
11
- config.assets ||= ::ActiveSupport::OrderedOptions.new
11
+ config.assets = ::ActiveSupport::OrderedOptions.new unless config.respond_to?(:assets)
12
12
 
13
13
  # Path where the manifest files are loaded from.
14
14
  config.assets.manifests = ['public/assets/manifest.json']
@@ -20,30 +20,16 @@ module Rails
20
20
 
21
21
  config.after_initialize do |_|
22
22
  ActiveSupport.on_load(:action_view) do
23
- include Helper
23
+ prepend Helper
24
24
  end
25
25
  end
26
26
 
27
- initializer 'rails-assets-manifest' do |app|
28
- ::Rails::Assets::Manifest.instance if server?
27
+ config.to_prepare do
28
+ ::Rails::Assets::Manifest.prepare!
29
29
  end
30
30
 
31
- private
32
-
33
- def server?
34
- !(console? || generator? || rake?)
35
- end
36
-
37
- def console?
38
- defined?(Rails::Console)
39
- end
40
-
41
- def generator?
42
- defined?(Rails::Generators)
43
- end
44
-
45
- def rake?
46
- File.basename($0) == "rake"
31
+ config.before_eager_load do
32
+ ::Rails::Assets::Manifest.eager_load!
47
33
  end
48
34
  end
49
35
  end
@@ -5,8 +5,8 @@ module Rails
5
5
  module Manifest
6
6
  module VERSION
7
7
  MAJOR = 2
8
- MINOR = 0
9
- PATCH = 0
8
+ MINOR = 1
9
+ PATCH = 2
10
10
  STAGE = nil
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
@@ -13,23 +13,34 @@ module Rails
13
13
  require 'rails/assets/manifest/railtie' if defined?(Rails::Railtie)
14
14
 
15
15
  class ManifestMissing < StandardError; end
16
+
16
17
  class ManifestInvalid < StandardError; end
18
+
17
19
  class EntryMissing < StandardError; end
20
+
18
21
  class IntegrityMissing < StandardError; end
19
22
 
20
23
  class << self
21
24
  delegate :lookup, :lookup!, to: :instance
22
25
 
23
- def instance
24
- @instance ||= begin
26
+ attr_reader :instance
27
+
28
+ def prepare!
29
+ @instance = begin
25
30
  config = Rails.application.config
26
31
 
27
32
  Manifest.new \
28
- files: config.assets.manifests,
33
+ files: config.assets.manifests.map {|path| Rails.root.join(path) },
29
34
  cache: config.cache_classes
30
35
  end
31
36
  end
32
37
 
38
+ def eager_load!
39
+ return unless @instance
40
+
41
+ @instance.eager_load!
42
+ end
43
+
33
44
  def passthrough?
34
45
  Rails.application.config.assets.passthrough
35
46
  end
data/renovate.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["config:base", "schedule:earlyMondays"]
3
+ }
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: 2.0.0
4
+ version: 2.1.2
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-08 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -60,10 +60,11 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".editorconfig"
63
+ - ".github/workflows/test.yml"
63
64
  - ".gitignore"
64
65
  - ".rspec"
65
66
  - ".rubocop.yml"
66
- - ".travis.yml"
67
+ - Appraisals
67
68
  - CHANGELOG.md
68
69
  - Gemfile
69
70
  - LICENSE
@@ -71,17 +72,17 @@ files:
71
72
  - Rakefile
72
73
  - bin/console
73
74
  - bin/setup
74
- - gemfiles/rails-4-2.gemfile
75
- - gemfiles/rails-5-0.gemfile
76
- - gemfiles/rails-5-1.gemfile
77
- - gemfiles/rails-5-2.gemfile
78
- - gemfiles/rails-master.gemfile
75
+ - gemfiles/rails_5.2.gemfile
76
+ - gemfiles/rails_6.0.gemfile
77
+ - gemfiles/rails_6.1.gemfile
78
+ - gemfiles/rails_master.gemfile
79
79
  - lib/rails/assets/manifest.rb
80
80
  - lib/rails/assets/manifest/helper.rb
81
81
  - lib/rails/assets/manifest/manifest.rb
82
82
  - lib/rails/assets/manifest/railtie.rb
83
83
  - lib/rails/assets/manifest/version.rb
84
84
  - rails-assets-manifest.gemspec
85
+ - renovate.json
85
86
  homepage: https://github.com/jgraichen/rails-assets-manifest
86
87
  licenses: []
87
88
  metadata:
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.0.3
107
+ rubygems_version: 3.2.22
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Load all rails assets from an external manifest.
data/.travis.yml DELETED
@@ -1,37 +0,0 @@
1
- dist: xenial
2
- language: ruby
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.6.3
7
- - 2.5.5
8
-
9
- gemfile:
10
- - gemfiles/rails-5-2.gemfile
11
- - gemfiles/rails-master.gemfile
12
-
13
- before_install:
14
- - gem update --system
15
- - gem install bundler
16
-
17
- script:
18
- - bundle exec rspec spec
19
-
20
- jobs:
21
- allow_failures:
22
- - gemfile: gemfiles/rails-master.gemfile
23
-
24
- include:
25
- - stage: Release
26
- rvm: 2.6.3
27
- env: []
28
- script: skip
29
- install: skip
30
- deploy:
31
- provider: rubygems
32
- api_key:
33
- secure: m5gUzb8J40lo4EJ2xE8XwoeHq4S3ZEDE+AyikDHzGKc5NEQQcCRoc469UlDO7fYfBHGKLh2eEe6+e/T+dyRE/C0qE/tfd6pVWf8xdyzt9+rB0zM3k7pR2Aud2hZ8NFF4bAQ28OvQ2y9pWWLVS9Bn/C0Xou951yZM+vufPVZpX7+08Aw+ZdPQrmg+v9SxsvWElm/is0CMjsHxpEy1vpyyBlF/DhNpHgd+69nupyTuZP8bg3lirZexek0xNaccNpflmrUeRwE7yofVGMfrRhvm5kOniYI+sQl/Zwru9+hK2WaSzfX/ou4ENihiLDGo5gdWeYcyLbS61yQARsRn21cN6SA0iYVuVnAruHC3uoxRh7ty1H8s3aUJnPTnnBj5cnfP9pqOyZI8zFi54CujkEFbRVLlWfGjKtCScgFBwkpXS5aB6CBplulMrX3kz/jYXFgodXLsV10WD725WGJ2Jkb52PoT5i2GyA/Ao746s7+wPIEV/l8NAurcroSHOzr9PcAUG/CwdzgidSnLfwl+qplMCGaUHtdHkPaRHqJL9j4BmcqoGVMaU0a4mAXsrlJG/drT2PMMrREKChtnQPtWg3L9HHDHBIKuXZCIQ7G9n2Dz7lpWnyKZKjJTcFyZWbbnKHLXlE1KDBUiG9qqrYbpky+IEPUt4jZ1W8hx4tKGjNlNwjU=
34
- gem: rails-assets-manifest
35
- on:
36
- tags: true
37
- repo: jgraichen/rails-assets-manifest
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Load root Gemfile
6
- eval_gemfile '../Gemfile'
7
-
8
- gem 'activesupport', '~> 4.2.0'
9
- gem 'railties', '~> 4.2.0'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Load root Gemfile
6
- eval_gemfile '../Gemfile'
7
-
8
- gem 'activesupport', '~> 5.0.0'
9
- gem 'railties', '~> 5.0.0'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Load root Gemfile
6
- eval_gemfile '../Gemfile'
7
-
8
- gem 'activesupport', '~> 5.1.0'
9
- gem 'railties', '~> 5.1.0'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Load root Gemfile
6
- eval_gemfile '../Gemfile'
7
-
8
- gem 'activesupport', '~> 5.2.0'
9
- gem 'railties', '~> 5.2.0'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Load root Gemfile
6
- eval_gemfile '../Gemfile'
7
-
8
- gem 'activesupport', git: 'https://github.com/rails/rails'
9
- gem 'railties', git: 'https://github.com/rails/rails'