sprockets-rails 2.3.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce070066edd25fc773120801099deaa44cbab0a8
4
- data.tar.gz: 0ae39779bf56111b665205168d7b4daebd47ea94
3
+ metadata.gz: f20d1344a104a96a8fdc6ca1140776f9bee0b095
4
+ data.tar.gz: b2a9b8a9c86913d9ec6d55a221e2f433cac8201f
5
5
  SHA512:
6
- metadata.gz: 4032a379c2a1d87b5d28e2be7119c628aaf36814fc0d34c717068fc91b59b69af7ed979107f0c47d37aad0c42e485ade12b688cd8ea562ca2bfbdceb5daa75c4
7
- data.tar.gz: b32fc1c142d819cf55b734fda999b7a55f88d1ce7a164f6417ff6839f3acb15fe00a38004b6507dc867e50ffabcb186ca4e73e80f53be6b5f61068c2a2e3987c
6
+ metadata.gz: 5f0bfaac5eaaaa8db5681deb71749e0e1195b8f4e0c819125d70102359094baa1a535ad6a5d6163b60d24b5474848c7db2fc12d9bf917aa9c53d3809e69fa2f0
7
+ data.tar.gz: 8966809de396e82b543ccac54823f99c0abad6696f58bfdc40a1db9e884d196b2570b8c62720c2ac04c35de942a8a4469805c31418d070f09a262afb486124c4
data/README.md CHANGED
@@ -27,7 +27,7 @@ Only removes old assets (keeps the most recent 3 copies) from `public/assets`. U
27
27
 
28
28
  **`rake assets:clobber`**
29
29
 
30
- Nuke `public/assets` and clear the Sprockets file system cache.
30
+ Nuke `public/assets`.
31
31
 
32
32
  #### Customize
33
33
 
@@ -37,11 +37,6 @@ You can also redefine the task with the built in task generator.
37
37
 
38
38
  ``` ruby
39
39
  require 'sprockets/rails/task'
40
- # clean the old tasks
41
- Rake::Task["assets:environment"].clear
42
- Rake::Task["assets:precompile"].clear
43
- Rake::Task["assets:clean"].clear
44
- Rake::Task["assets:clobber"].clear
45
40
  Sprockets::Rails::Task.new(Rails.application) do |t|
46
41
  t.environment = lambda { Rails.application.assets }
47
42
  t.assets = %w( application.js application.css )
@@ -51,7 +46,7 @@ end
51
46
 
52
47
  Each asset task will invoke `assets:environment` first. By default this loads the Rails environment. You can override this task to add or remove dependencies for your specific compilation environment.
53
48
 
54
- Also see [Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::SprocketsTask](https://github.com/sstephenson/sprockets/blob/master/lib/rake/sprocketstask.rb).
49
+ Also see [Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::SprocketsTask](https://github.com/rails/sprockets/blob/master/lib/rake/sprocketstask.rb).
55
50
 
56
51
 
57
52
  ### Initializer options
@@ -60,10 +55,6 @@ Also see [Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/
60
55
 
61
56
  Add additional assets to compile on deploy. Defaults to `application.js`, `application.css` and any other non-js/css file under `app/assets`.
62
57
 
63
- **`config.assets.raise_runtime_errors`**
64
-
65
- Set to `true` to enable additional runtime error checking. Recommended in the `development` environment to minimize unexpected behavior when deploying to `production`.
66
-
67
58
  **`config.assets.paths`**
68
59
 
69
60
  Add additional load paths to this Array. Rails includes `app/assets`, `lib/assets` and `vendor/assets` for you already. Plugins might want to add their custom paths to this.
@@ -83,13 +74,9 @@ config.assets.version = 'v2'
83
74
 
84
75
  Defaults to `/assets`. Changes the directory to compile assets to.
85
76
 
86
- **`config.assets.manifest`**
87
-
88
- Defines the full path to be used for the asset precompiler's manifest file. Defaults to a randomly-generated filename in the `config.assets.prefix` directory within the public folder.
89
-
90
77
  **`config.assets.digest`**
91
78
 
92
- Link to undigest asset filenames. This option will eventually go away. Unless when `compile` is disabled.
79
+ When enabled, fingerprints will be added to asset filenames.
93
80
 
94
81
  **`config.assets.debug`**
95
82
 
@@ -97,7 +84,7 @@ Enable expanded asset debugging mode. Individual files will be served to make re
97
84
 
98
85
  **`config.assets.compile`**
99
86
 
100
- Enables Sprockets compile environment. If disabled, `Rails.application.assets` will be unavailable to any ActionView helpers. View helpers will depend on assets being precompiled to `public/assets` in order to link to them. You can still access the environment by directly calling `Rails.application.assets`.
87
+ Enables Sprockets compile environment. If disabled, `Rails.application.assets` will be `nil` to prevent inadvertent compilation calls. View helpers will depend on assets being precompiled to `public/assets` in order to link to them. Initializers expecting `Rails.application.assets` during boot should be accessing the environment in a `config.assets.configure` block. See below.
101
88
 
102
89
  **`config.assets.configure`**
103
90
 
@@ -105,7 +92,7 @@ Invokes block with environment when the environment is initialized. Allows direc
105
92
 
106
93
  ``` ruby
107
94
  config.assets.configure do |env|
108
- env.js_compressor = :uglify # or :closure, :yui
95
+ env.js_compressor = :uglifier # or :closure, :yui
109
96
  env.css_compressor = :sass # or :yui
110
97
 
111
98
  require 'my_processor'
@@ -117,6 +104,24 @@ config.assets.configure do |env|
117
104
  end
118
105
  ```
119
106
 
107
+ **`config.assets.resolve_with`**
108
+
109
+ A list of `:environment` and `:manifest` symbols that defines the order that
110
+ we try to find assets: manifest first, environment second? Manifest only?
111
+
112
+ By default, we check the manifest first if asset digests are enabled and debug
113
+ is not enabled, then we check the environment if compiling is enabled:
114
+ ```
115
+ # Dev where debug is true, or digests are disabled
116
+ %i[ environment ]
117
+
118
+ # Dev default, or production with compile enabled.
119
+ %i[ manifest environment ]
120
+
121
+ # Production default.
122
+ %i[ manifest ]
123
+ ```
124
+
120
125
 
121
126
  ## Complementary plugins
122
127
 
@@ -132,29 +137,33 @@ The following plugins provide some extras for the Sprockets Asset Pipeline.
132
137
 
133
138
  * Only compiles digest filenames. Static non-digest assets should simply live in public/.
134
139
  * Unmanaged asset paths and urls fallback to linking to public/. This should make it easier to work with both compiled assets and simple static assets. As a side effect, there will never be any "asset not precompiled errors" when linking to missing assets. They will just link to a public file which may or may not exist.
135
- * JS and CSS compressors must be explicitly set. Magic detection has been removed to avoid loading compressors in environments where you want to avoid loading any of the asset libraries. Assign `config.assets.js_compressor = :uglify` or `config.assets.css_compressor = :sass` for the standard compressors.
140
+ * JS and CSS compressors must be explicitly set. Magic detection has been removed to avoid loading compressors in environments where you want to avoid loading any of the asset libraries. Assign `config.assets.js_compressor = :uglifier` or `config.assets.css_compressor = :sass` for the standard compressors.
136
141
  * The manifest file is now in a JSON format. Since it lives in public/ by default, the initial filename is also randomized to obfuscate public access to the resource.
137
142
  * `config.assets.manifest` (if used) must now include the manifest filename, e.g. `Rails.root.join('config/manifest.json')`. It cannot be a directory.
138
143
  * Two cleanup tasks. `rake assets:clean` is now a safe cleanup that only removes older assets that are no longer used. While `rake assets:clobber` nukes the entire `public/assets` directory and clears your filesystem cache. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.
139
144
 
145
+ ## Experimental
140
146
 
141
- ## Contributing
147
+ ### [SRI](http://www.w3.org/TR/SRI/) support
142
148
 
143
- Usual bundler workflow.
149
+ Sprockets 3.x adds experimental support for subresource integrity checks. The spec is still evolving and the API may change in backwards incompatible ways.
144
150
 
145
- ``` shell
146
- $ git clone https://github.com/rails/sprockets-rails.git
147
- $ cd sprockets-rails/
148
- $ bundle install
149
- $ bundle exec rake test
151
+ ``` ruby
152
+ javascript_include_tag :application, integrity: true
153
+ # => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
150
154
  ```
151
155
 
152
- [![Build Status](https://secure.travis-ci.org/rails/sprockets-rails.png)](http://travis-ci.org/rails/sprockets-rails)
153
156
 
157
+ ## Contributing to Sprockets Rails
158
+
159
+ Sprockets Rails is work of many contributors. You're encouraged to submit pull requests, propose
160
+ features and discuss issues.
161
+
162
+ See [CONTRIBUTING](CONTRIBUTING.md).
154
163
 
155
164
  ## Releases
156
165
 
157
- sprockets-rails 2.x will primarily target sprockets 2.x with future compatibility for 3.x. Consider upgrading to sprockets-rails 3.x to take full advantage of 3.x features.
166
+ sprockets-rails 3.x will primarily target sprockets 3.x. And future versions will target the corresponding sprockets release line.
158
167
 
159
168
  The minor and patch version will be updated according to [semver](http://semver.org/).
160
169
 
@@ -162,9 +171,12 @@ The minor and patch version will be updated according to [semver](http://semver.
162
171
  * Any time the sprockets dependency is bumped, there will be a new minor release
163
172
  * Simple bug fixes will be patch releases
164
173
 
165
-
166
174
  ## License
167
175
 
168
- Copyright &copy; 2014 Joshua Peek.
176
+ Sprockets Rails is released under the [MIT License](MIT-LICENSE).
177
+
178
+ ## Code Status
169
179
 
170
- Released under the MIT license. See `LICENSE` for details.
180
+ * [![Travis CI](https://api.travis-ci.org/rails/sprockets-rails.svg)](http://travis-ci.org/rails/sprockets-rails)
181
+ * [![Gem Version](https://badge.fury.io/rb/sprockets-rails.svg)](http://badge.fury.io/rb/sprockets-rails)
182
+ * [![Dependencies](https://gemnasium.com/rails/sprockets-rails.svg)](https://gemnasium.com/rails/sprockets-rails)
@@ -0,0 +1,48 @@
1
+ require 'action_view'
2
+ require 'sprockets'
3
+
4
+ module Sprockets
5
+ module Rails
6
+ module Context
7
+ include ActionView::Helpers::AssetUrlHelper
8
+ include ActionView::Helpers::AssetTagHelper
9
+
10
+ def self.included(klass)
11
+ klass.class_eval do
12
+ class_attribute :config, :assets_prefix, :digest_assets
13
+ end
14
+ end
15
+
16
+ def compute_asset_path(path, options = {})
17
+ @dependencies << 'actioncontroller-asset-url-config'
18
+
19
+ begin
20
+ asset_uri = resolve(path)
21
+ rescue FileNotFound
22
+ # TODO: eh, we should be able to use a form of locate that returns
23
+ # nil instead of raising an exception.
24
+ end
25
+
26
+ if asset_uri
27
+ asset = link_asset(path)
28
+ digest_path = asset.digest_path
29
+ path = digest_path if digest_assets
30
+ File.join(assets_prefix || "/", path)
31
+ else
32
+ super
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ register_dependency_resolver 'actioncontroller-asset-url-config' do |env|
39
+ config = env.context_class.config
40
+ [config.relative_url_root,
41
+ (config.asset_host unless config.asset_host.respond_to?(:call))]
42
+ end
43
+
44
+ # fallback to the default pipeline when using Sprockets 3.x
45
+ unless config[:pipelines].include? :debug
46
+ register_pipeline :debug, config[:pipelines][:default]
47
+ end
48
+ end