sprockets-digest-assets-fix 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +22 -0
- data/README.md +41 -0
- data/lib/sprockets-digest-assets-fix.rb +20 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjNiNzgwN2QzN2I5ZWQxMDk3ZWRjYTNjMjc5YWEzMGFhYTYwZWJhZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTZkNzMxYjZiNmQyMjBhOWQ4MDY0YjBhNTU4YzBjNDMyMjlkMWFlZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NGFjYmZjNmVkYWMwYWVmZTkzOWM5NzdlMjQ1NmViMmRhOWRlYjY3NjI1OTZi
|
10
|
+
OWEyYzlkZjM0MmY2ZWViMGY4YmQ2OTYxMzY1YmFjMzViYjZmOWQ2MjM5ZGUx
|
11
|
+
ZTQ0NDM5M2NlMGI0ZWIxMzc4MWI0OWZjODdkNWViN2RiMDM2NTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YmQ1Y2UzZWU4MTk4Nzg4NDU2YTAzNzMxZWUzYmZhY2JlYjNmYzA3NzM4YWY3
|
14
|
+
N2EyYzc4N2U4Mzg5MjA0OTVkZmNjNTRkZDA2MTc3MmNkZDZkMmFjOTBjOWRm
|
15
|
+
MTFmNzE5NmEyOWEzZDkwNGFlOGU1NDFlMDNlMGMxZDBiZWU3ZjE=
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Alex Speller
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Non-stupid non-digest assets in Rails 4
|
2
|
+
=======================================
|
3
|
+
|
4
|
+
What is it?
|
5
|
+
-----------
|
6
|
+
|
7
|
+
In Rails 4, there is no way to by default compile both digest and non-digest assets. This is a pain in the arse for almost everyone developing a Rails 4 app. This gem solves the problem with the minimum possible effort.
|
8
|
+
|
9
|
+
How do I install it?
|
10
|
+
--------------------
|
11
|
+
|
12
|
+
Just put it in your Gemfile
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem "sprockets-digest-assets-fix"
|
16
|
+
```
|
17
|
+
|
18
|
+
But shouldn't I always use the Rails asset helpers anyway?
|
19
|
+
----------------------------------------------------------
|
20
|
+
|
21
|
+
Yes. But there are some obvious cases where you can't do this:
|
22
|
+
|
23
|
+
* Third party libraries in `vendor/assets` that need to include e.g. css / images
|
24
|
+
* In a static error page, e.g. a 404 page or a 500 page
|
25
|
+
* Referencing the assets from outside your rails application
|
26
|
+
|
27
|
+
What about other solutions?
|
28
|
+
--------------------------
|
29
|
+
[sprockets-redirect](https://github.com/sikachu/sprockets-redirect) uses a rack middleware to 302 redirect to the digest asset. This is terrible for performance because it requires 2 HTTP requests, and it also hits your ruby stack. An asset request should be handled by your webserver (e.g. nginx) because that's what it's good at.
|
30
|
+
|
31
|
+
[This rake task](https://github.com/rails/sprockets-rails/issues/49#issuecomment-20535134) will solve this problem, but requires an extra rake task. It won't work by default with things like capistrano / heroku. And it requires you to manage the code in your app.
|
32
|
+
|
33
|
+
Why do I need digest assets at all?
|
34
|
+
-----------------------------------
|
35
|
+
|
36
|
+
Digests are used for cache busting. Remember that if you use the non-digest assets and serve them with far-future expires headers, you will cause problems with cached assets if the contents ever need to change. You must bear this in mind when using non-digest assets.
|
37
|
+
|
38
|
+
Why is this not the default / a config option in Rails 4?
|
39
|
+
---------------------------------------------------------
|
40
|
+
|
41
|
+
Good question. I think it should be. [Complain here](https://github.com/rails/sprockets-rails/issues/49)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Sprockets
|
2
|
+
class Manifest
|
3
|
+
def compile_with_non_digest *args
|
4
|
+
compile_without_non_digest *args
|
5
|
+
|
6
|
+
files.each do |(digest_path, info)|
|
7
|
+
full_digest_path = File.join dir, digest_path
|
8
|
+
full_non_digest_path = File.join dir, info['logical_path']
|
9
|
+
logger.info "Writing #{full_non_digest_path}"
|
10
|
+
if File.exists?(full_digest_path)
|
11
|
+
FileUtils.cp full_digest_path, full_non_digest_path
|
12
|
+
else
|
13
|
+
logger.info "Not found: #{full_digest_path}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method_chain :compile, :non_digest
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprockets-digest-assets-fix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Speller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ! " Rails 4, much to everyone's annoyance, provides no option to generate
|
14
|
+
both digest\n and non-digest assets. Installing this gem automatically creates
|
15
|
+
both digest and\n non-digest assets which are useful for many reasons. See this
|
16
|
+
issue for more details:\n https://github.com/rails/sprockets-rails/issues/49\n"
|
17
|
+
email:
|
18
|
+
- alex@alexspeller.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/sprockets-digest-assets-fix.rb
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
homepage: http://github.com/alexspeller/non-stupid-digest-assets
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.0.5
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: Fix the Rails 4 asset pipeline to generate non-digest along with digest assets
|
50
|
+
test_files: []
|