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.
- data/lib/turbo-sprockets/tasks/assets.rake +12 -36
- data/lib/turbo-sprockets/version.rb +1 -1
- metadata +3 -3
@@ -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
|
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
|
-
|
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?(
|
149
|
-
|
150
|
-
|
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
|
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.
|
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: -
|
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: -
|
114
|
+
hash: -15130413448249580
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
117
|
rubygems_version: 1.8.24
|