actionpack 3.1.0.rc8 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/lib/action_pack/version.rb +1 -1
- data/lib/sprockets/assets.rake +8 -1
- data/lib/sprockets/helpers/rails_helper.rb +27 -14
- data/lib/sprockets/railtie.rb +10 -0
- metadata +15 -24
data/lib/action_pack/version.rb
CHANGED
data/lib/sprockets/assets.rake
CHANGED
@@ -18,7 +18,9 @@ namespace :assets do
|
|
18
18
|
|
19
19
|
config = Rails.application.config
|
20
20
|
env = Rails.application.assets
|
21
|
-
target =
|
21
|
+
target = Pathname.new(File.join(Rails.public_path, config.assets.prefix))
|
22
|
+
manifest = {}
|
23
|
+
manifest_path = config.assets.manifest || target
|
22
24
|
|
23
25
|
if env.respond_to?(:each_logical_path)
|
24
26
|
config.assets.precompile.each do |path|
|
@@ -30,6 +32,7 @@ namespace :assets do
|
|
30
32
|
end
|
31
33
|
|
32
34
|
if asset = env.find_asset(logical_path)
|
35
|
+
manifest[logical_path] = asset.digest_path
|
33
36
|
filename = target.join(asset.digest_path)
|
34
37
|
mkdir_p filename.dirname
|
35
38
|
asset.write_to(filename)
|
@@ -43,6 +46,10 @@ namespace :assets do
|
|
43
46
|
assets << {:to => target}
|
44
47
|
env.precompile(*assets)
|
45
48
|
end
|
49
|
+
|
50
|
+
File.open("#{manifest_path}/manifest.yml", 'w') do |f|
|
51
|
+
YAML.dump(manifest, f)
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
@@ -14,6 +14,7 @@ module Sprockets
|
|
14
14
|
paths = RailsHelper::AssetPaths.new(config, controller)
|
15
15
|
paths.asset_environment = asset_environment
|
16
16
|
paths.asset_prefix = asset_prefix
|
17
|
+
paths.asset_digests = asset_digests
|
17
18
|
paths
|
18
19
|
end
|
19
20
|
end
|
@@ -71,10 +72,14 @@ module Sprockets
|
|
71
72
|
|
72
73
|
private
|
73
74
|
def debug_assets?
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
begin
|
76
|
+
Rails.application.config.assets.compile &&
|
77
|
+
(Rails.application.config.assets.debug ||
|
78
|
+
params[:debug_assets] == '1' ||
|
79
|
+
params[:debug_assets] == 'true')
|
80
|
+
rescue NoMethodError
|
81
|
+
false
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
# Override to specify an alternative prefix for asset path generation.
|
@@ -87,6 +92,10 @@ module Sprockets
|
|
87
92
|
Rails.application.config.assets.prefix
|
88
93
|
end
|
89
94
|
|
95
|
+
def asset_digests
|
96
|
+
Rails.application.config.assets.digests
|
97
|
+
end
|
98
|
+
|
90
99
|
# Override to specify an alternative asset environment for asset
|
91
100
|
# path generation. The environment should already have been mounted
|
92
101
|
# at the prefix returned by +asset_prefix+.
|
@@ -95,7 +104,9 @@ module Sprockets
|
|
95
104
|
end
|
96
105
|
|
97
106
|
class AssetPaths < ::ActionView::AssetPaths #:nodoc:
|
98
|
-
attr_accessor :asset_environment, :asset_prefix
|
107
|
+
attr_accessor :asset_environment, :asset_prefix, :asset_digests
|
108
|
+
|
109
|
+
class AssetNotPrecompiledError < StandardError; end
|
99
110
|
|
100
111
|
def compute_public_path(source, dir, ext=nil, include_host=true, protocol=nil)
|
101
112
|
super(source, asset_prefix, ext, include_host, protocol)
|
@@ -114,18 +125,25 @@ module Sprockets
|
|
114
125
|
end
|
115
126
|
|
116
127
|
def digest_for(logical_path)
|
117
|
-
if
|
118
|
-
return
|
128
|
+
if asset_digests && (digest = asset_digests[logical_path])
|
129
|
+
return digest
|
119
130
|
end
|
120
131
|
|
121
|
-
|
132
|
+
if Rails.application.config.assets.compile
|
133
|
+
if asset = asset_environment[logical_path]
|
134
|
+
return asset.digest_path
|
135
|
+
end
|
136
|
+
return logical_path
|
137
|
+
else
|
138
|
+
raise AssetNotPrecompiledError.new("#{logical_path} isn't precompiled")
|
139
|
+
end
|
122
140
|
end
|
123
141
|
|
124
142
|
def rewrite_asset_path(source, dir)
|
125
143
|
if source[0] == ?/
|
126
144
|
source
|
127
145
|
else
|
128
|
-
source = digest_for(source) if
|
146
|
+
source = digest_for(source) if Rails.application.config.assets.digest
|
129
147
|
source = File.join(dir, source)
|
130
148
|
source = "/#{source}" unless source =~ /^\//
|
131
149
|
source
|
@@ -139,11 +157,6 @@ module Sprockets
|
|
139
157
|
source
|
140
158
|
end
|
141
159
|
end
|
142
|
-
|
143
|
-
# When included in Sprockets::Context, we need to ask the top-level config as the controller is not available
|
144
|
-
def performing_caching?
|
145
|
-
config.action_controller.present? ? config.action_controller.perform_caching : config.perform_caching
|
146
|
-
end
|
147
160
|
end
|
148
161
|
end
|
149
162
|
end
|
data/lib/sprockets/railtie.rb
CHANGED
@@ -26,6 +26,16 @@ module Sprockets
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
if config.assets.manifest
|
30
|
+
path = File.join(config.assets.manifest, "manifest.yml")
|
31
|
+
else
|
32
|
+
path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")
|
33
|
+
end
|
34
|
+
|
35
|
+
if File.exist?(path)
|
36
|
+
config.assets.digests = YAML.load_file(path)
|
37
|
+
end
|
38
|
+
|
29
39
|
ActiveSupport.on_load(:action_view) do
|
30
40
|
include ::Sprockets::Helpers::RailsHelper
|
31
41
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 0
|
10
|
-
|
11
|
-
version: 3.1.0.rc8
|
10
|
+
version: 3.1.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- David Heinemeier Hansson
|
@@ -16,8 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2011-08-
|
20
|
-
default_executable:
|
18
|
+
date: 2011-08-31 00:00:00 Z
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
23
21
|
name: activesupport
|
@@ -27,13 +25,12 @@ dependencies:
|
|
27
25
|
requirements:
|
28
26
|
- - "="
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
28
|
+
hash: 3
|
31
29
|
segments:
|
32
30
|
- 3
|
33
31
|
- 1
|
34
32
|
- 0
|
35
|
-
|
36
|
-
version: 3.1.0.rc8
|
33
|
+
version: 3.1.0
|
37
34
|
type: :runtime
|
38
35
|
version_requirements: *id001
|
39
36
|
- !ruby/object:Gem::Dependency
|
@@ -44,13 +41,12 @@ dependencies:
|
|
44
41
|
requirements:
|
45
42
|
- - "="
|
46
43
|
- !ruby/object:Gem::Version
|
47
|
-
hash:
|
44
|
+
hash: 3
|
48
45
|
segments:
|
49
46
|
- 3
|
50
47
|
- 1
|
51
48
|
- 0
|
52
|
-
|
53
|
-
version: 3.1.0.rc8
|
49
|
+
version: 3.1.0
|
54
50
|
type: :runtime
|
55
51
|
version_requirements: *id002
|
56
52
|
- !ruby/object:Gem::Dependency
|
@@ -156,14 +152,12 @@ dependencies:
|
|
156
152
|
requirements:
|
157
153
|
- - ~>
|
158
154
|
- !ruby/object:Gem::Version
|
159
|
-
hash:
|
155
|
+
hash: 15
|
160
156
|
segments:
|
161
157
|
- 2
|
162
158
|
- 0
|
163
159
|
- 0
|
164
|
-
|
165
|
-
- 15
|
166
|
-
version: 2.0.0.beta.15
|
160
|
+
version: 2.0.0
|
167
161
|
type: :runtime
|
168
162
|
version_requirements: *id009
|
169
163
|
- !ruby/object:Gem::Dependency
|
@@ -392,7 +386,6 @@ files:
|
|
392
386
|
- lib/sprockets/helpers/rails_helper.rb
|
393
387
|
- lib/sprockets/helpers.rb
|
394
388
|
- lib/sprockets/railtie.rb
|
395
|
-
has_rdoc: true
|
396
389
|
homepage: http://www.rubyonrails.org
|
397
390
|
licenses: []
|
398
391
|
|
@@ -415,18 +408,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
415
408
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
416
409
|
none: false
|
417
410
|
requirements:
|
418
|
-
- - "
|
411
|
+
- - ">="
|
419
412
|
- !ruby/object:Gem::Version
|
420
|
-
hash:
|
413
|
+
hash: 3
|
421
414
|
segments:
|
422
|
-
-
|
423
|
-
|
424
|
-
- 1
|
425
|
-
version: 1.3.1
|
415
|
+
- 0
|
416
|
+
version: "0"
|
426
417
|
requirements:
|
427
418
|
- none
|
428
419
|
rubyforge_project:
|
429
|
-
rubygems_version: 1.
|
420
|
+
rubygems_version: 1.8.8
|
430
421
|
signing_key:
|
431
422
|
specification_version: 3
|
432
423
|
summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
|