turbo-sprockets-rails3 0.1.12 → 0.1.13

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.
@@ -32,50 +32,51 @@ module Sprockets
32
32
  end
33
33
  next unless compile_path?(logical_path)
34
34
 
35
- digest_path = @digest_files[logical_path]
36
- abs_digest_path = "#{@target}/#{digest_path}"
37
- abs_logical_path = "#{@target}/#{logical_path}"
35
+ if digest_path = @digest_files[logical_path]
36
+ abs_digest_path = "#{@target}/#{digest_path}"
37
+ abs_logical_path = "#{@target}/#{logical_path}"
38
38
 
39
- mtime = File.mtime(abs_digest_path)
39
+ mtime = File.mtime(abs_digest_path)
40
40
 
41
- # Remove known digests from css & js
42
- if abs_digest_path.match(/\.(?:js|css)$/)
43
- asset_body = File.read(abs_digest_path)
41
+ # Remove known digests from css & js
42
+ if abs_digest_path.match(/\.(?:js|css)$/)
43
+ asset_body = File.read(abs_digest_path)
44
44
 
45
- # Find all hashes in the asset body with a leading '-'
46
- asset_body.gsub!(DIGEST_REGEX) do |match|
47
- # Only remove if known digest
48
- $1.in?(@asset_digests.values) ? '' : match
49
- end
45
+ # Find all hashes in the asset body with a leading '-'
46
+ asset_body.gsub!(DIGEST_REGEX) do |match|
47
+ # Only remove if known digest
48
+ $1.in?(@asset_digests.values) ? '' : match
49
+ end
50
50
 
51
- # Write non-digest file
52
- File.open abs_logical_path, 'w' do |f|
53
- f.write asset_body
54
- end
55
- # Set modification and access times
56
- File.utime(File.atime(abs_digest_path), mtime, abs_logical_path)
57
-
58
- # Also write gzipped asset
59
- File.open("#{abs_logical_path}.gz", 'wb') do |f|
60
- gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
61
- gz.mtime = mtime.to_i
62
- gz.write asset_body
63
- gz.close
64
- end
51
+ # Write non-digest file
52
+ File.open abs_logical_path, 'w' do |f|
53
+ f.write asset_body
54
+ end
55
+ # Set modification and access times
56
+ File.utime(File.atime(abs_digest_path), mtime, abs_logical_path)
57
+
58
+ # Also write gzipped asset
59
+ File.open("#{abs_logical_path}.gz", 'wb') do |f|
60
+ gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
61
+ gz.mtime = mtime.to_i
62
+ gz.write asset_body
63
+ gz.close
64
+ end
65
65
 
66
- env.logger.debug "Stripped digests, copied to #{logical_path}, and created gzipped asset"
66
+ env.logger.debug "Stripped digests, copied to #{logical_path}, and created gzipped asset"
67
67
 
68
- else
69
- # Otherwise, treat file as binary and copy it.
70
- # Ignore paths that have no digests, such as READMEs
71
- unless abs_digest_path == abs_logical_path
72
- FileUtils.cp_r abs_digest_path, abs_logical_path, :remove_destination => true
73
- env.logger.debug "Copied binary asset to #{logical_path}"
74
-
75
- # Copy gzipped asset if exists
76
- if File.exist? "#{abs_digest_path}.gz"
77
- FileUtils.cp_r "#{abs_digest_path}.gz", "#{abs_logical_path}.gz", :remove_destination => true
78
- env.logger.debug "Copied gzipped asset to #{logical_path}.gz"
68
+ else
69
+ # Otherwise, treat file as binary and copy it.
70
+ # Ignore paths that have no digests, such as READMEs
71
+ unless abs_digest_path == abs_logical_path
72
+ FileUtils.cp_r abs_digest_path, abs_logical_path, :remove_destination => true
73
+ env.logger.debug "Copied binary asset to #{logical_path}"
74
+
75
+ # Copy gzipped asset if exists
76
+ if File.exist? "#{abs_digest_path}.gz"
77
+ FileUtils.cp_r "#{abs_digest_path}.gz", "#{abs_logical_path}.gz", :remove_destination => true
78
+ env.logger.debug "Copied gzipped asset to #{logical_path}.gz"
79
+ end
79
80
  end
80
81
  end
81
82
  end
@@ -34,27 +34,27 @@ if defined?(Sprockets::StaticCompiler)
34
34
 
35
35
  # Fetch asset without any processing or compression,
36
36
  # to calculate a digest of the concatenated source files
37
- asset = env.find_asset(logical_path, :process => false)
37
+ if asset = env.find_asset(logical_path, :process => false)
38
+ @source_digests[logical_path] = asset.digest
38
39
 
39
- @source_digests[logical_path] = asset.digest
40
+ # Recompile if digest has changed or compiled digest file is missing
41
+ current_digest_file = @current_digest_files[logical_path]
40
42
 
41
- # Recompile if digest has changed or compiled digest file is missing
42
- current_digest_file = @current_digest_files[logical_path]
43
+ if @source_digests[logical_path] != @current_source_digests[logical_path] ||
44
+ !(current_digest_file && File.exists?("#{@target}/#{current_digest_file}"))
43
45
 
44
- if @source_digests[logical_path] != @current_source_digests[logical_path] ||
45
- !(current_digest_file && File.exists?("#{@target}/#{current_digest_file}"))
46
+ if asset = env.find_asset(logical_path)
47
+ @digest_files[logical_path] = write_asset(asset)
48
+ end
46
49
 
47
- if asset = env.find_asset(logical_path)
48
- @digest_files[logical_path] = write_asset(asset)
49
- end
50
-
51
- else
52
- # Set asset file from manifest.yml
53
- digest_file = @current_digest_files[logical_path]
54
- @digest_files[logical_path] = digest_file
50
+ else
51
+ # Set asset file from manifest.yml
52
+ digest_file = @current_digest_files[logical_path]
53
+ @digest_files[logical_path] = digest_file
55
54
 
56
- env.logger.debug "Not compiling #{logical_path}, sources digest has not changed " <<
57
- "(#{@source_digests[logical_path][0...7]})"
55
+ env.logger.debug "Not compiling #{logical_path}, sources digest has not changed " <<
56
+ "(#{@source_digests[logical_path][0...7]})"
57
+ end
58
58
  end
59
59
  end
60
60
 
@@ -1,3 +1,3 @@
1
1
  module TurboSprockets
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-sprockets-rails3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: