non-stupid-digest-assets 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 034067fe0fa40bcabd92bfbc36651eb7d91a795a
4
+ data.tar.gz: 15805278962fcf3306dbcc6d99b633a2e3d4d27e
5
+ SHA512:
6
+ metadata.gz: c031696bbf8b17c29047135123e801b0d2f3c1c8363cb28ba50b5571f71e3557a944bb3c2917cbc27940f2bf453bbf323dfcaaf0cc834890cc9a8375d7fa7c81
7
+ data.tar.gz: 29622297ff236eda07436324bdf842d6ea76c4d0d99781f2441b0c70399176cd9d5d199c42596b83bda5467e3193a4931229da1a12dfdd1b808ef9bdac7ca28f
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 "non-stupid-digest-assets"
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,16 @@
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
+ FileUtils.cp full_digest_path, full_non_digest_path
11
+ end
12
+ end
13
+
14
+ alias_method_chain :compile, :non_digest
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: non-stupid-digest-assets
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-09-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ Rails 4, much to everyone's annoyance, provides no option to generate both digest
15
+ and non-digest assets. Installing this gem automatically creates both digest and
16
+ non-digest assets which are useful for many reasons. See this issue for more details:
17
+ https://github.com/rails/sprockets-rails/issues/49
18
+ email:
19
+ - alex@alexspeller.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - lib/non-stupid-digest-assets.rb
25
+ - LICENSE
26
+ - README.md
27
+ homepage: http://github.com/alexspeller/non-stupid-digest-assets
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.0.3
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Fix the Rails 4 asset pipeline to generate non-digest along with digest assets
51
+ test_files: []