asset_hat 0.2.1 → 0.3.0
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/HISTORY +38 -19
- data/README.rdoc +99 -41
- data/Rakefile +17 -10
- data/VERSION.yml +3 -3
- data/app/helpers/asset_hat_helper.rb +40 -20
- data/asset_hat.gemspec +105 -101
- data/doc/classes/AssetHat.html +173 -59
- data/doc/classes/AssetHat/CSS.html +35 -26
- data/doc/classes/AssetHat/CSS/Engines.html +13 -12
- data/doc/classes/AssetHat/JS.html +11 -11
- data/doc/classes/AssetHat/JS/Engines.html +10 -10
- data/doc/classes/AssetHat/JS/Vendors.html +9 -5
- data/doc/classes/AssetHatHelper.html +18 -14
- data/doc/created.rid +1 -1
- data/doc/files/HISTORY.html +66 -24
- data/doc/files/LICENSE.html +1 -1
- data/doc/files/README_rdoc.html +112 -37
- data/doc/files/app/helpers/asset_hat_helper_rb.html +1 -1
- data/doc/files/lib/asset_hat/capistrano_rb.html +1 -1
- data/doc/files/lib/asset_hat/css_rb.html +1 -1
- data/doc/files/lib/asset_hat/js/vendors_rb.html +1 -1
- data/doc/files/lib/asset_hat/js_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks/css_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks/js_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks_rb.html +1 -1
- data/doc/files/lib/asset_hat/vcs_rb.html +1 -1
- data/doc/files/lib/asset_hat/version_rb.html +1 -1
- data/doc/files/lib/asset_hat_rb.html +1 -1
- data/doc/fr_method_index.html +54 -46
- data/lib/asset_hat.rb +100 -16
- data/lib/asset_hat/capistrano.rb +4 -3
- data/lib/asset_hat/css.rb +69 -20
- data/lib/asset_hat/js.rb +2 -2
- data/lib/asset_hat/js/vendors.rb +14 -10
- data/lib/asset_hat/tasks.rb +22 -3
- data/lib/asset_hat/tasks/css.rb +118 -74
- data/lib/asset_hat/tasks/js.rb +79 -35
- data/lib/asset_hat/vcs.rb +19 -0
- data/public/stylesheets/bundles/ssl/css-bundle-1.min.css +3 -0
- data/public/stylesheets/bundles/ssl/css-bundle-2.min.css +3 -0
- data/public/stylesheets/bundles/ssl/css-bundle-3.min.css +3 -0
- data/rails/init.rb +1 -16
- data/test/asset_hat_helper_test.rb +172 -28
- data/test/asset_hat_test.rb +167 -25
- metadata +54 -21
- data/.gitignore +0 -2
data/asset_hat.gemspec
CHANGED
@@ -1,132 +1,136 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{asset_hat}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ron DeVera", "Mint Digital"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.description = %q{
|
14
|
-
s.email = %q{
|
12
|
+
s.date = %q{2010-12-08}
|
13
|
+
s.description = %q{Minifies, bundles, and optimizes CSS/JS assets ahead of time (e.g., on deploy), not at runtime. Loads popular JS frameworks (like jQuery and Prototype) from localhost in development, and auto-switches to Google's CDN in production. Can rewrite stylesheets to use CDN hosts (not just your web server) and cache-busting hashes for updated images.}
|
14
|
+
s.email = %q{hello@rondevera.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
20
|
+
"HISTORY",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION.yml",
|
25
|
+
"app/helpers/asset_hat_helper.rb",
|
26
|
+
"asset_hat.gemspec",
|
27
|
+
"config/assets.yml",
|
28
|
+
"doc/classes/AssetHat.html",
|
29
|
+
"doc/classes/AssetHat/CSS.html",
|
30
|
+
"doc/classes/AssetHat/CSS/Engines.html",
|
31
|
+
"doc/classes/AssetHat/JS.html",
|
32
|
+
"doc/classes/AssetHat/JS/Engines.html",
|
33
|
+
"doc/classes/AssetHat/JS/Vendors.html",
|
34
|
+
"doc/classes/AssetHatHelper.html",
|
35
|
+
"doc/created.rid",
|
36
|
+
"doc/files/HISTORY.html",
|
37
|
+
"doc/files/LICENSE.html",
|
38
|
+
"doc/files/README_rdoc.html",
|
39
|
+
"doc/files/app/helpers/asset_hat_helper_rb.html",
|
40
|
+
"doc/files/lib/asset_hat/capistrano_rb.html",
|
41
|
+
"doc/files/lib/asset_hat/css_rb.html",
|
42
|
+
"doc/files/lib/asset_hat/js/vendors_rb.html",
|
43
|
+
"doc/files/lib/asset_hat/js_rb.html",
|
44
|
+
"doc/files/lib/asset_hat/tasks/css_rb.html",
|
45
|
+
"doc/files/lib/asset_hat/tasks/js_rb.html",
|
46
|
+
"doc/files/lib/asset_hat/tasks_rb.html",
|
47
|
+
"doc/files/lib/asset_hat/vcs_rb.html",
|
48
|
+
"doc/files/lib/asset_hat/version_rb.html",
|
49
|
+
"doc/files/lib/asset_hat_rb.html",
|
50
|
+
"doc/fr_class_index.html",
|
51
|
+
"doc/fr_file_index.html",
|
52
|
+
"doc/fr_method_index.html",
|
53
|
+
"doc/index.html",
|
54
|
+
"doc/rdoc-style.css",
|
55
|
+
"lib/asset_hat.rb",
|
56
|
+
"lib/asset_hat/capistrano.rb",
|
57
|
+
"lib/asset_hat/css.rb",
|
58
|
+
"lib/asset_hat/js.rb",
|
59
|
+
"lib/asset_hat/js/vendors.rb",
|
60
|
+
"lib/asset_hat/tasks.rb",
|
61
|
+
"lib/asset_hat/tasks/css.rb",
|
62
|
+
"lib/asset_hat/tasks/js.rb",
|
63
|
+
"lib/asset_hat/vcs.rb",
|
64
|
+
"lib/asset_hat/version.rb",
|
65
|
+
"public/javascripts/bundles/js-bundle-1.min.js",
|
66
|
+
"public/javascripts/bundles/js-bundle-2.min.js",
|
67
|
+
"public/javascripts/bundles/js-bundle-3.min.js",
|
68
|
+
"public/javascripts/js-file-1-1.js",
|
69
|
+
"public/javascripts/js-file-1-2.js",
|
70
|
+
"public/javascripts/js-file-1-3.js",
|
71
|
+
"public/javascripts/js-file-2-1.js",
|
72
|
+
"public/javascripts/js-file-2-2.js",
|
73
|
+
"public/javascripts/js-file-2-3.js",
|
74
|
+
"public/javascripts/js-file-3-1.js",
|
75
|
+
"public/javascripts/js-file-3-2.js",
|
76
|
+
"public/javascripts/js-file-3-3.js",
|
77
|
+
"public/stylesheets/bundles/css-bundle-1.min.css",
|
78
|
+
"public/stylesheets/bundles/css-bundle-2.min.css",
|
79
|
+
"public/stylesheets/bundles/css-bundle-3.min.css",
|
80
|
+
"public/stylesheets/bundles/ssl/css-bundle-1.min.css",
|
81
|
+
"public/stylesheets/bundles/ssl/css-bundle-2.min.css",
|
82
|
+
"public/stylesheets/bundles/ssl/css-bundle-3.min.css",
|
83
|
+
"public/stylesheets/css-file-1-1.css",
|
84
|
+
"public/stylesheets/css-file-1-2.css",
|
85
|
+
"public/stylesheets/css-file-1-3.css",
|
86
|
+
"public/stylesheets/css-file-2-1.css",
|
87
|
+
"public/stylesheets/css-file-2-2.css",
|
88
|
+
"public/stylesheets/css-file-2-3.css",
|
89
|
+
"public/stylesheets/css-file-3-1.css",
|
90
|
+
"public/stylesheets/css-file-3-2.css",
|
91
|
+
"public/stylesheets/css-file-3-3.css",
|
92
|
+
"rails/init.rb",
|
93
|
+
"tasks/asset_hat.rake",
|
94
|
+
"test/asset_hat_helper_test.rb",
|
95
|
+
"test/asset_hat_test.rb",
|
96
|
+
"test/test_helper.rb"
|
95
97
|
]
|
96
98
|
s.homepage = %q{http://github.com/mintdigital/asset_hat}
|
97
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
98
99
|
s.require_paths = ["lib"]
|
99
|
-
s.rubygems_version = %q{1.3.
|
100
|
+
s.rubygems_version = %q{1.3.7}
|
100
101
|
s.summary = %q{Your assets are covered.}
|
101
102
|
s.test_files = [
|
102
103
|
"test/asset_hat_helper_test.rb",
|
103
|
-
|
104
|
-
|
104
|
+
"test/asset_hat_test.rb",
|
105
|
+
"test/test_helper.rb"
|
105
106
|
]
|
106
107
|
|
107
108
|
if s.respond_to? :specification_version then
|
108
109
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
109
110
|
s.specification_version = 3
|
110
111
|
|
111
|
-
if Gem::Version.new(Gem::
|
112
|
-
s.add_development_dependency(%q<flexmock>, ["
|
113
|
-
s.add_development_dependency(%q<hanna>, ["
|
114
|
-
s.add_development_dependency(%q<
|
115
|
-
s.
|
116
|
-
s.add_runtime_dependency(%q<
|
112
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
113
|
+
s.add_development_dependency(%q<flexmock>, ["~> 0.8.6"])
|
114
|
+
s.add_development_dependency(%q<hanna>, ["~> 0.1.12"])
|
115
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.4.0"])
|
116
|
+
s.add_development_dependency(%q<shoulda>, ["~> 2.10.2"])
|
117
|
+
s.add_runtime_dependency(%q<cssmin>, ["~> 1.0.2"])
|
118
|
+
s.add_runtime_dependency(%q<jsmin>, ["~> 1.0.1"])
|
117
119
|
else
|
118
|
-
s.add_dependency(%q<flexmock>, ["
|
119
|
-
s.add_dependency(%q<hanna>, ["
|
120
|
-
s.add_dependency(%q<
|
121
|
-
s.add_dependency(%q<
|
122
|
-
s.add_dependency(%q<
|
120
|
+
s.add_dependency(%q<flexmock>, ["~> 0.8.6"])
|
121
|
+
s.add_dependency(%q<hanna>, ["~> 0.1.12"])
|
122
|
+
s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
|
123
|
+
s.add_dependency(%q<shoulda>, ["~> 2.10.2"])
|
124
|
+
s.add_dependency(%q<cssmin>, ["~> 1.0.2"])
|
125
|
+
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
|
123
126
|
end
|
124
127
|
else
|
125
|
-
s.add_dependency(%q<flexmock>, ["
|
126
|
-
s.add_dependency(%q<hanna>, ["
|
127
|
-
s.add_dependency(%q<
|
128
|
-
s.add_dependency(%q<
|
129
|
-
s.add_dependency(%q<
|
128
|
+
s.add_dependency(%q<flexmock>, ["~> 0.8.6"])
|
129
|
+
s.add_dependency(%q<hanna>, ["~> 0.1.12"])
|
130
|
+
s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
|
131
|
+
s.add_dependency(%q<shoulda>, ["~> 2.10.2"])
|
132
|
+
s.add_dependency(%q<cssmin>, ["~> 1.0.2"])
|
133
|
+
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
|
130
134
|
end
|
131
135
|
end
|
132
136
|
|
data/doc/classes/AssetHat.html
CHANGED
@@ -83,7 +83,7 @@
|
|
83
83
|
</li>
|
84
84
|
<li>Add an image’s last <a href="http://git-scm.com/">Git</a> commit ID
|
85
85
|
to its <a href="AssetHat/CSS.html">CSS</a> URLs to <strong>bust browser
|
86
|
-
caches</strong> (e.g., <tt>/images/foo.png?
|
86
|
+
caches</strong> (e.g., <tt>/images/foo.png?ab12cd3</tt>).
|
87
87
|
|
88
88
|
</li>
|
89
89
|
</ul>
|
@@ -103,17 +103,21 @@
|
|
103
103
|
<h2>Methods</h2>
|
104
104
|
<h3>public class</h3>
|
105
105
|
<ol>
|
106
|
-
<li><a href="#
|
107
|
-
<li><a href="#
|
108
|
-
<li><a href="#
|
109
|
-
<li><a href="#
|
110
|
-
<li><a href="#M000007">
|
111
|
-
<li><a href="#
|
112
|
-
<li><a href="#
|
113
|
-
<li><a href="#
|
106
|
+
<li><a href="#M000008">asset_exists?</a></li>
|
107
|
+
<li><a href="#M000006">assets_dir</a></li>
|
108
|
+
<li><a href="#M000011">bundle_filenames</a></li>
|
109
|
+
<li><a href="#M000012">bundle_filepaths</a></li>
|
110
|
+
<li><a href="#M000007">bundles_dir</a></li>
|
111
|
+
<li><a href="#M000009">cache?</a></li>
|
112
|
+
<li><a href="#M000003">cache_last_commit_ids</a></li>
|
113
|
+
<li><a href="#M000015">clear_html_cache</a></li>
|
114
|
+
<li><a href="#M000013">compute_asset_host</a></li>
|
115
|
+
<li><a href="#M000005">config</a></li>
|
116
|
+
<li><a href="#M000002">last_bundle_commit_id</a></li>
|
114
117
|
<li><a href="#M000001">last_commit_id</a></li>
|
115
|
-
<li><a href="#
|
116
|
-
<li><a href="#
|
118
|
+
<li><a href="#M000010">min_filepath</a></li>
|
119
|
+
<li><a href="#M000014">ssl_asset_host_differs?</a></li>
|
120
|
+
<li><a href="#M000004">version</a></li>
|
117
121
|
</ol>
|
118
122
|
</div>
|
119
123
|
<div id='section'>
|
@@ -159,7 +163,7 @@
|
|
159
163
|
<tr class='top-aligned-row context-row'>
|
160
164
|
<td class='context-item-name'>STYLESHEETS_DIR</td>
|
161
165
|
<td>=</td>
|
162
|
-
<td class='context-item-value'
|
166
|
+
<td class='context-item-value'>File.join(ASSETS_DIR, 'stylesheets')</td>
|
163
167
|
<td> </td>
|
164
168
|
<td class='context-item-desc'>
|
165
169
|
|
@@ -170,7 +174,7 @@
|
|
170
174
|
<tr class='top-aligned-row context-row'>
|
171
175
|
<td class='context-item-name'>JAVASCRIPTS_DIR</td>
|
172
176
|
<td>=</td>
|
173
|
-
<td class='context-item-value'
|
177
|
+
<td class='context-item-value'>File.join(ASSETS_DIR, 'javascripts')</td>
|
174
178
|
<td> </td>
|
175
179
|
<td class='context-item-desc'>
|
176
180
|
|
@@ -203,8 +207,8 @@
|
|
203
207
|
</div>
|
204
208
|
<div id='methods'>
|
205
209
|
<h2>Public class methods</h2>
|
206
|
-
<div class='method public-class' id='method-
|
207
|
-
<a name='
|
210
|
+
<div class='method public-class' id='method-M000008'>
|
211
|
+
<a name='M000008'></a>
|
208
212
|
<div class='synopsis'>
|
209
213
|
<span class='name'>asset_exists?</span>
|
210
214
|
<span class='arguments'>(filename, type)</span>
|
@@ -213,43 +217,43 @@
|
|
213
217
|
<p>
|
214
218
|
Returns true if the specified asset exists in the file system:
|
215
219
|
</p>
|
216
|
-
<pre>AssetHat.asset_exists?('application', :css)
 # => true if
|
220
|
+
<pre>AssetHat.asset_exists?('application.css', :css)
 # => true if public/stylesheets/application.css exists
AssetHat.asset_exists?('some-plugin.js', :js)
 # => true if public/javascripts/some-plugin.js exists</pre>
|
217
221
|
<p>
|
218
|
-
See also <tt>AssetHat
|
219
|
-
<tt>AssetHat::JAVASCRIPTS_DIR</tt>.
|
222
|
+
See also <tt><a href="AssetHat.html#M000006">AssetHat.assets_dir</a></tt>.
|
220
223
|
</p>
|
221
224
|
</div>
|
222
225
|
<div class='source'>
|
223
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
226
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
|
224
227
|
[show source]
|
225
228
|
</a>
|
226
|
-
<pre id='
|
229
|
+
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 127</span>
127: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">asset_exists?</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">type</span>)
128: <span class="ruby-comment cmt"># Process arguments</span>
129: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
130: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
131: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
132: <span class="ruby-keyword kw">return</span>
133: <span class="ruby-keyword kw">end</span>
134: 
135: <span class="ruby-comment cmt"># Default to `{:css => {}, :js => {}}`</span>
136: <span class="ruby-ivar">@asset_exists</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">hsh</span>, <span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">t</span> =<span class="ruby-operator">></span> {}) }
137: 
138: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>].<span class="ruby-identifier">nil?</span>
139: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>] =
140: <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">assets_dir</span>(<span class="ruby-identifier">type</span>), <span class="ruby-identifier">filename</span>))
141: <span class="ruby-keyword kw">end</span>
142: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>]
143: <span class="ruby-keyword kw">end</span></pre>
|
227
230
|
</div>
|
228
231
|
</div>
|
229
|
-
<div class='method public-class' id='method-
|
230
|
-
<a name='
|
232
|
+
<div class='method public-class' id='method-M000006'>
|
233
|
+
<a name='M000006'></a>
|
231
234
|
<div class='synopsis'>
|
232
235
|
<span class='name'>assets_dir</span>
|
233
236
|
<span class='arguments'>(type)</span>
|
234
237
|
</div>
|
235
238
|
<div class='description'>
|
236
239
|
<p>
|
237
|
-
|
240
|
+
Returns the relative path to the directory where the original <a
|
241
|
+
href="AssetHat/CSS.html">CSS</a> or <a href="AssetHat/JS.html">JS</a> files
|
242
|
+
are stored.
|
238
243
|
</p>
|
239
244
|
<p>
|
240
|
-
|
241
|
-
or <a href="AssetHat/JS.html">JS</a> files are stored.
|
245
|
+
<tt>type</tt> argument: <tt>:css</tt> or <tt>:js</tt>
|
242
246
|
</p>
|
243
247
|
</div>
|
244
248
|
<div class='source'>
|
245
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
249
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
|
246
250
|
[show source]
|
247
251
|
</a>
|
248
|
-
<pre id='
|
252
|
+
<pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 76</span>
76: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">assets_dir</span>(<span class="ruby-identifier">type</span>)
77: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
78: 
79: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
80: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
81: <span class="ruby-keyword kw">return</span>
82: <span class="ruby-keyword kw">end</span>
83: 
84: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>
85: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:css</span> ; <span class="ruby-constant">STYLESHEETS_DIR</span>
86: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:js</span> ; <span class="ruby-constant">JAVASCRIPTS_DIR</span>
87: <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">nil</span>
88: <span class="ruby-keyword kw">end</span>
89: <span class="ruby-keyword kw">end</span></pre>
|
249
253
|
</div>
|
250
254
|
</div>
|
251
|
-
<div class='method public-class' id='method-
|
252
|
-
<a name='
|
255
|
+
<div class='method public-class' id='method-M000011'>
|
256
|
+
<a name='M000011'></a>
|
253
257
|
<div class='synopsis'>
|
254
258
|
<span class='name'>bundle_filenames</span>
|
255
259
|
<span class='arguments'>(bundle, type)</span>
|
@@ -261,14 +265,14 @@
|
|
261
265
|
<pre>AssetHat.bundle_filenames('application', :css)
 # => ['reset', 'application', 'clearfix']
AssetHat.bundle_filenames('non-existent-file', :css)
 # => nil</pre>
|
262
266
|
</div>
|
263
267
|
<div class='source'>
|
264
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
268
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
|
265
269
|
[show source]
|
266
270
|
</a>
|
267
|
-
<pre id='
|
271
|
+
<pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 169</span>
169: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bundle_filenames</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>)
170: <span class="ruby-comment cmt"># Process arguments</span>
171: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>)
172: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
173: <span class="ruby-keyword kw">return</span>
174: <span class="ruby-keyword kw">end</span>
175: 
176: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config</span>[<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>][<span class="ruby-value str">'bundles'</span>][<span class="ruby-identifier">bundle</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
177: <span class="ruby-keyword kw">end</span></pre>
|
268
272
|
</div>
|
269
273
|
</div>
|
270
|
-
<div class='method public-class' id='method-
|
271
|
-
<a name='
|
274
|
+
<div class='method public-class' id='method-M000012'>
|
275
|
+
<a name='M000012'></a>
|
272
276
|
<div class='synopsis'>
|
273
277
|
<span class='name'>bundle_filepaths</span>
|
274
278
|
<span class='arguments'>(bundle, type)</span>
|
@@ -280,14 +284,47 @@
|
|
280
284
|
<pre>AssetHat.bundle_filenames('application', :css)
 # => ['/path/to/app/public/stylesheets/reset.css',
 '/path/to/app/public/stylesheets/application.css',
 '/path/to/app/public/stylesheets/clearfix.css']
AssetHat.bundle_filenames('non-existent-file', :css)
 # => nil</pre>
|
281
285
|
</div>
|
282
286
|
<div class='source'>
|
283
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
287
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
|
284
288
|
[show source]
|
285
289
|
</a>
|
286
|
-
<pre id='
|
290
|
+
<pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 187</span>
187: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bundle_filepaths</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>)
188: <span class="ruby-comment cmt"># Process arguments</span>
189: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>)
190: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
191: <span class="ruby-keyword kw">return</span>
192: <span class="ruby-keyword kw">end</span>
193: 
194: <span class="ruby-identifier">dir</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">assets_dir</span>(<span class="ruby-identifier">type</span>)
195: <span class="ruby-identifier">filenames</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bundle_filenames</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>)
196: <span class="ruby-identifier">filepaths</span> = <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">present?</span> <span class="ruby-value">?
197: </span> <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">fn</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-node">"#{fn}.#{type}"</span>) } <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
198: <span class="ruby-keyword kw">end</span></pre>
|
287
291
|
</div>
|
288
292
|
</div>
|
289
293
|
<div class='method public-class' id='method-M000007'>
|
290
294
|
<a name='M000007'></a>
|
295
|
+
<div class='synopsis'>
|
296
|
+
<span class='name'>bundles_dir</span>
|
297
|
+
<span class='arguments'>(*args)</span>
|
298
|
+
</div>
|
299
|
+
<div class='description'>
|
300
|
+
<p>
|
301
|
+
Returns the relative path to the directory where <a
|
302
|
+
href="AssetHat/CSS.html">CSS</a> or <a href="AssetHat/JS.html">JS</a>
|
303
|
+
bundles are stored.
|
304
|
+
</p>
|
305
|
+
<p>
|
306
|
+
Usage:
|
307
|
+
</p>
|
308
|
+
<pre>AssetHat.bundles_dir
 # => 'bundles'
AssetHat.bundles_dir(:ssl => true)
 # => 'bundles/ssl'
AssetHat.bundles_dir(:css)
 # => 'public/stylesheets/bundles'
AssetHat.bundles_dir(:js, :ssl => true)
 # => 'public/javascripts/bundles/ssl</pre>
|
309
|
+
<p>
|
310
|
+
Options:
|
311
|
+
</p>
|
312
|
+
<dl>
|
313
|
+
<dt>ssl</dt><dd>Set this to <tt>true</tt> if the stylesheet references images via SSL.
|
314
|
+
Defaults to <tt>false</tt>.
|
315
|
+
|
316
|
+
</dd>
|
317
|
+
</dl>
|
318
|
+
</div>
|
319
|
+
<div class='source'>
|
320
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
|
321
|
+
[show source]
|
322
|
+
</a>
|
323
|
+
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 109</span>
109: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bundles_dir</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
110: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
111: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys!</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>)
112: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
113: 
114: <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">present?</span> <span class="ruby-value">? </span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">assets_dir</span>(<span class="ruby-identifier">type</span>), <span class="ruby-value str">'bundles'</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">'bundles'</span>
115: <span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-value str">'ssl'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ssl</span>]
116: <span class="ruby-identifier">dir</span>
117: <span class="ruby-keyword kw">end</span></pre>
|
324
|
+
</div>
|
325
|
+
</div>
|
326
|
+
<div class='method public-class' id='method-M000009'>
|
327
|
+
<a name='M000009'></a>
|
291
328
|
<div class='synopsis'>
|
292
329
|
<span class='name'>cache?</span>
|
293
330
|
<span class='arguments'>()</span>
|
@@ -302,27 +339,85 @@
|
|
302
339
|
</p>
|
303
340
|
</div>
|
304
341
|
<div class='source'>
|
305
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
342
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
|
306
343
|
[show source]
|
307
344
|
</a>
|
308
|
-
<pre id='
|
345
|
+
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 150</span>
150: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache?</span> ; <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">perform_caching</span> ; <span class="ruby-keyword kw">end</span></pre>
|
309
346
|
</div>
|
310
347
|
</div>
|
311
|
-
<div class='method public-class' id='method-
|
312
|
-
<a name='
|
348
|
+
<div class='method public-class' id='method-M000003'>
|
349
|
+
<a name='M000003'></a>
|
350
|
+
<div class='synopsis'>
|
351
|
+
<span class='name'>cache_last_commit_ids</span>
|
352
|
+
<span class='arguments'>()</span>
|
353
|
+
</div>
|
354
|
+
<div class='description'>
|
355
|
+
<p>
|
356
|
+
Precomputes and caches the last commit ID for all bundles. Your web server
|
357
|
+
process(es) should run this at boot to avoid overhead during user runtime.
|
358
|
+
</p>
|
359
|
+
</div>
|
360
|
+
<div class='source'>
|
361
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
|
362
|
+
[show source]
|
363
|
+
</a>
|
364
|
+
<pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/asset_hat/vcs.rb, line 74</span>
74: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_last_commit_ids</span>
75: <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
76: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">config</span>[<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>].<span class="ruby-identifier">blank?</span> <span class="ruby-operator">||</span>
77: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">config</span>[<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>][<span class="ruby-value str">'bundles'</span>].<span class="ruby-identifier">blank?</span>
78: 
79: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">config</span>[<span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span>][<span class="ruby-value str">'bundles'</span>].<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bundle</span><span class="ruby-operator">|</span>
80: <span class="ruby-comment cmt"># Memoize commit ID for this bundle</span>
81: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">last_bundle_commit_id</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">cache?</span>
82: 
83: <span class="ruby-comment cmt"># Memoize commit IDs for each file in this bundle</span>
84: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">bundle_filepaths</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filepath</span><span class="ruby-operator">|</span>
85: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">last_commit_id</span>(<span class="ruby-identifier">filepath</span>)
86: <span class="ruby-keyword kw">end</span>
87: <span class="ruby-keyword kw">end</span>
88: <span class="ruby-keyword kw">end</span>
89: <span class="ruby-keyword kw">end</span></pre>
|
365
|
+
</div>
|
366
|
+
</div>
|
367
|
+
<div class='method public-class' id='method-M000015'>
|
368
|
+
<a name='M000015'></a>
|
313
369
|
<div class='synopsis'>
|
314
370
|
<span class='name'>clear_html_cache</span>
|
315
371
|
<span class='arguments'>()</span>
|
316
372
|
</div>
|
317
373
|
<div class='source'>
|
318
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
374
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
|
319
375
|
[show source]
|
320
376
|
</a>
|
321
|
-
<pre id='
|
377
|
+
<pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 249</span>
249: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clear_html_cache</span>
250: <span class="ruby-identifier">html_cache</span> = {}
251: <span class="ruby-keyword kw">end</span></pre>
|
322
378
|
</div>
|
323
379
|
</div>
|
324
|
-
<div class='method public-class' id='method-
|
325
|
-
<a name='
|
380
|
+
<div class='method public-class' id='method-M000013'>
|
381
|
+
<a name='M000013'></a>
|
382
|
+
<div class='synopsis'>
|
383
|
+
<span class='name'>compute_asset_host</span>
|
384
|
+
<span class='arguments'>(asset_host, source, options={})</span>
|
385
|
+
</div>
|
386
|
+
<div class='description'>
|
387
|
+
<p>
|
388
|
+
Reads <tt>ActionController::Base.asset_host</tt>, which can be a String or
|
389
|
+
Proc, and returns a String. Should behave just like Rails 2.3.x’s
|
390
|
+
private `<a href="AssetHat.html#M000013">compute_asset_host</a>` method,
|
391
|
+
but with a simulated request.
|
392
|
+
</p>
|
393
|
+
<p>
|
394
|
+
Example environment config for CDN support via SSL:
|
395
|
+
</p>
|
396
|
+
<pre># In config/environments/production.rb:
config.action_controller.asset_host = Proc.new do |source, request|
 "#{request.protocol}cdn#{source.hash % 4}.example.com"
 # => 'http://cdn0.example.com', 'https://cdn1.example.com', etc.
end</pre>
|
397
|
+
<p>
|
398
|
+
If your CDN doesn’t have SSL support, you can instead revert SSL
|
399
|
+
pages to serving assets from your web server:
|
400
|
+
</p>
|
401
|
+
<pre>config.action_controller.asset_host = Proc.new do |source, request|
 request.ssl? ? nil : "http://cdn#{source.hash % 4}.example.com"
end</pre>
|
402
|
+
<p>
|
403
|
+
Options:
|
404
|
+
</p>
|
405
|
+
<dl>
|
406
|
+
<dt>ssl</dt><dd>Set to <tt>true</tt> to simulate a request via SSL. Defaults to
|
407
|
+
<tt>false</tt>.
|
408
|
+
|
409
|
+
</dd>
|
410
|
+
</dl>
|
411
|
+
</div>
|
412
|
+
<div class='source'>
|
413
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
|
414
|
+
[show source]
|
415
|
+
</a>
|
416
|
+
<pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 223</span>
223: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compute_asset_host</span>(<span class="ruby-identifier">asset_host</span>, <span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>={})
224: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">asset_host</span>
225: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Proc</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:call</span>)
226: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Proc</span>) <span class="ruby-operator">?</span>
227: <span class="ruby-identifier">host</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">:call</span>).<span class="ruby-identifier">arity</span>
228: <span class="ruby-keyword kw">when</span> <span class="ruby-value">2</span>
229: <span class="ruby-identifier">request</span> = <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(
230: <span class="ruby-value str">'HTTPS'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ssl</span>] <span class="ruby-operator">?</span> <span class="ruby-value str">'on'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'off'</span>)
231: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">host</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">request</span>)
232: <span class="ruby-keyword kw">else</span>
233: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">host</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">source</span>)
234: <span class="ruby-keyword kw">end</span>
235: <span class="ruby-keyword kw">else</span>
236: <span class="ruby-identifier">host</span> <span class="ruby-operator">%=</span> (<span class="ruby-identifier">source</span>.<span class="ruby-identifier">hash</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">host</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/%d/</span>
237: <span class="ruby-keyword kw">end</span>
238: <span class="ruby-identifier">host</span>
239: <span class="ruby-keyword kw">end</span></pre>
|
417
|
+
</div>
|
418
|
+
</div>
|
419
|
+
<div class='method public-class' id='method-M000005'>
|
420
|
+
<a name='M000005'></a>
|
326
421
|
<div class='synopsis'>
|
327
422
|
<span class='name'>config</span>
|
328
423
|
<span class='arguments'>()</span>
|
@@ -333,14 +428,14 @@
|
|
333
428
|
</p>
|
334
429
|
</div>
|
335
430
|
<div class='source'>
|
336
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
431
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
|
337
432
|
[show source]
|
338
433
|
</a>
|
339
|
-
<pre id='
|
434
|
+
<pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 65</span>
65: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config</span>
66: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">cache?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">blank?</span>
67: <span class="ruby-ivar">@config</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-constant">CONFIG_FILEPATH</span>)).<span class="ruby-identifier">result</span>)
68: <span class="ruby-keyword kw">end</span>
69: <span class="ruby-ivar">@config</span>
70: <span class="ruby-keyword kw">end</span></pre>
|
340
435
|
</div>
|
341
436
|
</div>
|
342
|
-
<div class='method public-class' id='method-
|
343
|
-
<a name='
|
437
|
+
<div class='method public-class' id='method-M000002'>
|
438
|
+
<a name='M000002'></a>
|
344
439
|
<div class='synopsis'>
|
345
440
|
<span class='name'>last_bundle_commit_id</span>
|
346
441
|
<span class='arguments'>(bundle, type)</span>
|
@@ -357,10 +452,10 @@
|
|
357
452
|
</p>
|
358
453
|
</div>
|
359
454
|
<div class='source'>
|
360
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
455
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
|
361
456
|
[show source]
|
362
457
|
</a>
|
363
|
-
<pre id='
|
458
|
+
<pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/asset_hat/vcs.rb, line 45</span>
45: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">last_bundle_commit_id</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>)
46: <span class="ruby-comment cmt"># Process arguments</span>
47: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
48: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>)
49: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
50: <span class="ruby-keyword kw">return</span>
51: <span class="ruby-keyword kw">end</span>
52: 
53: <span class="ruby-comment cmt"># Default to `{:css => {}, :js => {}}`</span>
54: <span class="ruby-ivar">@last_bundle_commit_ids</span> <span class="ruby-operator">||=</span>
55: <span class="ruby-constant">TYPES</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">hsh</span>, <span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">t</span> =<span class="ruby-operator">></span> {}) }
56: 
57: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_bundle_commit_ids</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">bundle</span>].<span class="ruby-identifier">blank?</span>
58: <span class="ruby-identifier">dir</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">assets_dir</span>(<span class="ruby-identifier">type</span>)
59: <span class="ruby-identifier">filepaths</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bundle_filepaths</span>(<span class="ruby-identifier">bundle</span>, <span class="ruby-identifier">type</span>)
60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filepaths</span>.<span class="ruby-identifier">present?</span>
61: <span class="ruby-ivar">@last_bundle_commit_ids</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">bundle</span>] = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">last_commit_id</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">filepaths</span>)
62: <span class="ruby-keyword kw">end</span>
63: <span class="ruby-keyword kw">end</span>
64: 
65: <span class="ruby-ivar">@last_bundle_commit_ids</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">bundle</span>]
66: <span class="ruby-keyword kw">end</span></pre>
|
364
459
|
</div>
|
365
460
|
</div>
|
366
461
|
<div class='method public-class' id='method-M000001'>
|
@@ -392,8 +487,8 @@
|
|
392
487
|
<pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/asset_hat/vcs.rb, line 18</span>
18: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">last_commit_id</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
19: <span class="ruby-comment cmt"># Process arguments</span>
20: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
21: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys</span>.<span class="ruby-identifier">reverse_merge</span>(<span class="ruby-identifier">:vcs</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:git</span>)
22: <span class="ruby-identifier">filepaths</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
23: 
24: <span class="ruby-comment cmt"># Validate options</span>
25: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:vcs</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">:git</span>
26: <span class="ruby-identifier">raise</span> <span class="ruby-value str">'Git is currently the only supported VCS.'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span>
27: <span class="ruby-keyword kw">end</span>
28: 
29: <span class="ruby-ivar">@last_commit_ids</span> <span class="ruby-operator">||=</span> {}
30: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_commit_ids</span>[<span class="ruby-identifier">filepaths</span>].<span class="ruby-identifier">blank?</span>
31: <span class="ruby-identifier">h</span> = <span class="ruby-node">`git log -1 --pretty=format:%h #{filepaths} 2>/dev/null`</span>
32: <span class="ruby-comment cmt"># `h` has either the abbreviated Git commit hash or an empty string</span>
33: <span class="ruby-ivar">@last_commit_ids</span>[<span class="ruby-identifier">filepaths</span>] = <span class="ruby-identifier">h</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">present?</span>
34: <span class="ruby-keyword kw">end</span>
35: <span class="ruby-ivar">@last_commit_ids</span>[<span class="ruby-identifier">filepaths</span>]
36: <span class="ruby-keyword kw">end</span></pre>
|
393
488
|
</div>
|
394
489
|
</div>
|
395
|
-
<div class='method public-class' id='method-
|
396
|
-
<a name='
|
490
|
+
<div class='method public-class' id='method-M000010'>
|
491
|
+
<a name='M000010'></a>
|
397
492
|
<div class='synopsis'>
|
398
493
|
<span class='name'>min_filepath</span>
|
399
494
|
<span class='arguments'>(filepath, extension)</span>
|
@@ -405,19 +500,38 @@
|
|
405
500
|
<pre>AssetHat.min_filepath('public/stylesheets/bundles/application.css', 'css')
 # => 'public/stylesheets/bundles/application.min.css'</pre>
|
406
501
|
<p>
|
407
502
|
See also <tt><a
|
408
|
-
href="AssetHat/CSS.html#
|
409
|
-
<tt><a href="AssetHat/JS.html#
|
503
|
+
href="AssetHat/CSS.html#M000016">AssetHat::CSS.min_filepath</a></tt> and
|
504
|
+
<tt><a href="AssetHat/JS.html#M000022">AssetHat::JS.min_filepath</a></tt>.
|
410
505
|
</p>
|
411
506
|
</div>
|
412
507
|
<div class='source'>
|
413
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
508
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
|
414
509
|
[show source]
|
415
510
|
</a>
|
416
|
-
<pre id='
|
511
|
+
<pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 159</span>
159: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">min_filepath</span>(<span class="ruby-identifier">filepath</span>, <span class="ruby-identifier">extension</span>)
160: <span class="ruby-identifier">filepath</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-node">/([^\.]*).#{extension}$/</span>, <span class="ruby-node">"\\1.min.#{extension}"</span>)
161: <span class="ruby-keyword kw">end</span></pre>
|
417
512
|
</div>
|
418
513
|
</div>
|
419
|
-
<div class='method public-class' id='method-
|
420
|
-
<a name='
|
514
|
+
<div class='method public-class' id='method-M000014'>
|
515
|
+
<a name='M000014'></a>
|
516
|
+
<div class='synopsis'>
|
517
|
+
<span class='name'>ssl_asset_host_differs?</span>
|
518
|
+
<span class='arguments'>()</span>
|
519
|
+
</div>
|
520
|
+
<div class='description'>
|
521
|
+
<p>
|
522
|
+
Returns <tt>true</tt> if the asset host differs between SSL and non-SSL
|
523
|
+
pages, or <tt>false</tt> if the asset host doesn’t change.
|
524
|
+
</p>
|
525
|
+
</div>
|
526
|
+
<div class='source'>
|
527
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
|
528
|
+
[show source]
|
529
|
+
</a>
|
530
|
+
<pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 243</span>
243: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ssl_asset_host_differs?</span>
244: <span class="ruby-identifier">asset_host</span> = <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">asset_host</span>
245: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">compute_asset_host</span>(<span class="ruby-identifier">asset_host</span>, <span class="ruby-value str">'x.png'</span>) <span class="ruby-operator">!=</span>
246: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">compute_asset_host</span>(<span class="ruby-identifier">asset_host</span>, <span class="ruby-value str">'x.png'</span>, <span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
247: <span class="ruby-keyword kw">end</span></pre>
|
531
|
+
</div>
|
532
|
+
</div>
|
533
|
+
<div class='method public-class' id='method-M000004'>
|
534
|
+
<a name='M000004'></a>
|
421
535
|
<div class='synopsis'>
|
422
536
|
<span class='name'>version</span>
|
423
537
|
<span class='arguments'>()</span>
|
@@ -428,10 +542,10 @@
|
|
428
542
|
</p>
|
429
543
|
</div>
|
430
544
|
<div class='source'>
|
431
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
545
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
|
432
546
|
[show source]
|
433
547
|
</a>
|
434
|
-
<pre id='
|
548
|
+
<pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/asset_hat/version.rb, line 3</span>
3: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">version</span>
4: <span class="ruby-identifier">data_filepath</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>), <span class="ruby-node">%w[.. .. VERSION.yml]</span>)
5: <span class="ruby-identifier">data</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">data_filepath</span>, <span class="ruby-value str">'r'</span>))
6: [<span class="ruby-identifier">:major</span>, <span class="ruby-identifier">:minor</span>, <span class="ruby-identifier">:patch</span>, <span class="ruby-identifier">:build</span>].
7: <span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">data</span>[<span class="ruby-identifier">x</span>] }.<span class="ruby-identifier">reject</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">:blank?</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'.'</span>)
8: <span class="ruby-keyword kw">end</span></pre>
|
435
549
|
</div>
|
436
550
|
</div>
|
437
551
|
</div>
|