turbo-sprockets-rails3 0.2.5 → 0.2.6

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.
@@ -35,15 +35,6 @@ namespace :assets do
35
35
  end
36
36
  end
37
37
 
38
- # Returns an array of assets recognized by config.assets.digests,
39
- # including gzipped assets and manifests
40
- def known_assets
41
- assets = Rails.application.config.assets.digests.to_a.flatten.map do |asset|
42
- [asset, "#{asset}.gz"]
43
- end.flatten
44
- assets + %w(manifest.yml sources_manifest.yml)
45
- end
46
-
47
38
  desc "Compile all the assets named in config.assets.precompile"
48
39
  task :precompile do
49
40
  invoke_or_reboot_rake_task "assets:precompile:all"
@@ -70,18 +61,6 @@ namespace :assets do
70
61
  env = Rails.application.assets
71
62
  target = File.join(::Rails.public_path, config.assets.prefix)
72
63
 
73
- # Before first compile, set the mtime of all current assets to current time.
74
- # This time reflects the last time the assets were being used.
75
- if digest.nil?
76
- ::Rails.logger.debug "Updating mtimes for current assets..."
77
- known_assets.each do |asset|
78
- full_path = File.join(target, asset)
79
- if File.exist?(full_path)
80
- File.utime(Time.now, Time.now, full_path)
81
- end
82
- end
83
- end
84
-
85
64
  # If processing non-digest assets, and compiled digest files are
86
65
  # present, then generate non-digest assets from existing assets.
87
66
  # It is assumed that `assets:precompile:nondigest` won't be run manually
@@ -128,29 +107,26 @@ namespace :assets do
128
107
  invoke_or_reboot_rake_task "assets:clean_expired:all"
129
108
  end
130
109
 
131
- # Remove assets that haven't been deployed since `config.assets.expire_after` (default 7 days).
132
- # The precompile task updates the mtime of the current assets before compiling,
133
- # which indicates when they were last in use.
134
- #
135
- # The current assets are ignored, which is faster than the alternative of
136
- # setting their mtimes only to check them again.
110
+ # Remove assets that aren't referenced by manifest.yml
137
111
  namespace :clean_expired do
138
112
  task :all => ["assets:environment"] do
139
113
  config = ::Rails.application.config
140
- expire_after = config.assets.expire_after || 7.days
141
114
  public_asset_path = File.join(::Rails.public_path, config.assets.prefix)
142
- @known_assets = known_assets
115
+
116
+ # Build an array of assets recognized by config.assets.digests,
117
+ # including gzipped assets and manifests
118
+ known_assets = Rails.application.config.assets.digests.to_a.flatten.map do |asset|
119
+ [asset, "#{asset}.gz"]
120
+ end.flatten
121
+ known_assets + %w(manifest.yml sources_manifest.yml)
143
122
 
144
123
  Dir.glob(File.join(public_asset_path, '**/*')).each do |asset|
145
124
  next if File.directory?(asset)
146
125
  logical_path = asset.sub("#{public_asset_path}/", '')
147
-
148
- unless logical_path.in?(@known_assets)
149
- # Delete asset if not used for more than expire_after seconds
150
- if File.mtime(asset) < (Time.now - expire_after)
151
- ::Rails.logger.debug "Removing expired asset: #{logical_path}"
152
- FileUtils.rm_f asset
153
- end
126
+ # Delete asset if not found in known_assets
127
+ unless logical_path.in?(known_assets)
128
+ ::Rails.logger.debug "Removing unreferenced asset: #{logical_path}"
129
+ FileUtils.rm_f asset
154
130
  end
155
131
  end
156
132
  end
@@ -1,3 +1,3 @@
1
1
  module TurboSprockets
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
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.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: -530756851904489456
105
+ hash: -15130413448249580
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: -530756851904489456
114
+ hash: -15130413448249580
115
115
  requirements: []
116
116
  rubyforge_project:
117
117
  rubygems_version: 1.8.24