compressed-gzipped-assets 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/compressed-gzipped-assets.gemspec +2 -2
- data/lib/compressed-gzipped-assets.rb +23 -14
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{compressed-gzipped-assets}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Shaw"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.description = %q{for more info see the readme.}
|
14
14
|
s.email = %q{ryankshaw@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -9,16 +9,6 @@ raise "GoogleClosureCompiler only Supports Rails >= 2.1.x" unless Rails.version
|
|
9
9
|
# Supports Rails >= 2.1.x
|
10
10
|
module ActionView::Helpers::AssetTagHelper
|
11
11
|
private
|
12
|
-
def join_asset_file_contents_with_compilation(files)
|
13
|
-
content = join_asset_file_contents_without_compilation(files)
|
14
|
-
if !files.grep(%r[/javascripts]).empty?
|
15
|
-
content = AssetCompressorWithGoogleClosureOrYUI.javascript_compressor.compress(content)
|
16
|
-
elsif !files.grep(%r[/stylesheets]).empty?
|
17
|
-
content = AssetCompressorWithGoogleClosureOrYUI.css_compressor.compress(content)
|
18
|
-
end
|
19
|
-
content
|
20
|
-
end
|
21
|
-
alias_method_chain :join_asset_file_contents, :compilation
|
22
12
|
|
23
13
|
# this helps the NginxHttpGzipStaticModule do it's thing.
|
24
14
|
# from it's website:
|
@@ -31,12 +21,31 @@ private
|
|
31
21
|
contents = join_asset_file_contents(asset_paths)
|
32
22
|
File.open(joined_asset_path, "w+") { |cache| cache.write(contents) }
|
33
23
|
|
34
|
-
|
35
|
-
Zlib::GzipWriter.open(zip_name, Zlib::BEST_COMPRESSION) {|f| f.write(contents) }
|
24
|
+
mt = asset_paths.map { |p| File.mtime(asset_file_path(p)) }.max
|
36
25
|
# Set mtime to the latest of the combined files to allow for
|
37
26
|
# consistent ETag without a shared filesystem.
|
38
|
-
mt
|
39
|
-
|
27
|
+
File.utime(mt, mt, joined_asset_path)
|
28
|
+
|
29
|
+
# ok, now that we have created the dum concatenation of the files so they have the bare minimum
|
30
|
+
# for what they need to show the page, lets create a new thread and compress the file in the background and
|
31
|
+
# replace the original so they dont have to wait while we work.
|
32
|
+
Thread.new do
|
33
|
+
if !asset_paths.grep(%r[/javascripts]).empty?
|
34
|
+
compressed_content = AssetCompressorWithGoogleClosureOrYUI.javascript_compressor.compress(contents)
|
35
|
+
elsif !asset_paths.grep(%r[/stylesheets]).empty?
|
36
|
+
compressed_content = AssetCompressorWithGoogleClosureOrYUI.css_compressor.compress(contents)
|
37
|
+
else
|
38
|
+
raise "I expected that you were either going to cache javascript files or css files"
|
39
|
+
end
|
40
|
+
File.open(joined_asset_path, "w+") { |cache| cache.write(compressed_content) }
|
41
|
+
|
42
|
+
zip_name = "#{joined_asset_path}.gz"
|
43
|
+
Zlib::GzipWriter.open(zip_name, Zlib::BEST_COMPRESSION) {|f| f.write(compressed_content) }
|
44
|
+
# Set mtime to the latest of the combined files to allow for
|
45
|
+
# consistent ETag without a shared filesystem.
|
46
|
+
# reset the mtime for the new files we just created
|
47
|
+
File.utime(mt, mt, joined_asset_path, zip_name)
|
48
|
+
end
|
40
49
|
end
|
41
50
|
alias_method_chain :write_asset_file_contents, :create_static_gziped_files
|
42
51
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compressed-gzipped-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Shaw
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|