asset_hat 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/HISTORY +13 -14
  2. data/README.rdoc +171 -0
  3. data/Rakefile +24 -2
  4. data/VERSION.yml +3 -3
  5. data/app/helpers/asset_hat_helper.rb +67 -61
  6. data/asset_hat.gemspec +42 -8
  7. data/doc/classes/AssetHat/CSS/Engines.html +118 -0
  8. data/doc/classes/AssetHat/CSS.html +194 -0
  9. data/doc/classes/AssetHat/JS/Engines.html +122 -0
  10. data/doc/classes/AssetHat/JS/Vendors.html +110 -0
  11. data/doc/classes/AssetHat/JS.html +151 -0
  12. data/doc/classes/AssetHat.html +446 -0
  13. data/doc/classes/AssetHatHelper.html +161 -0
  14. data/doc/created.rid +1 -0
  15. data/doc/files/HISTORY.html +116 -0
  16. data/doc/files/LICENSE.html +76 -0
  17. data/doc/files/README_rdoc.html +234 -0
  18. data/doc/files/app/helpers/asset_hat_helper_rb.html +55 -0
  19. data/doc/files/lib/asset_hat/capistrano_rb.html +49 -0
  20. data/doc/files/lib/asset_hat/css_rb.html +57 -0
  21. data/doc/files/lib/asset_hat/js/vendors_rb.html +49 -0
  22. data/doc/files/lib/asset_hat/js_rb.html +57 -0
  23. data/doc/files/lib/asset_hat/tasks/css_rb.html +49 -0
  24. data/doc/files/lib/asset_hat/tasks/js_rb.html +49 -0
  25. data/doc/files/lib/asset_hat/tasks_rb.html +58 -0
  26. data/doc/files/lib/asset_hat/vcs_rb.html +49 -0
  27. data/doc/files/lib/asset_hat/version_rb.html +49 -0
  28. data/doc/files/lib/asset_hat_rb.html +49 -0
  29. data/doc/fr_class_index.html +23 -0
  30. data/doc/fr_file_index.html +33 -0
  31. data/doc/fr_method_index.html +4455 -0
  32. data/doc/index.html +15 -0
  33. data/doc/rdoc-style.css +328 -0
  34. data/lib/asset_hat/capistrano.rb +14 -0
  35. data/lib/asset_hat/css.rb +40 -10
  36. data/lib/asset_hat/js/vendors.rb +85 -0
  37. data/lib/asset_hat/js.rb +28 -29
  38. data/lib/asset_hat/tasks/css.rb +151 -0
  39. data/lib/asset_hat/tasks/js.rb +100 -0
  40. data/lib/asset_hat/tasks.rb +4 -272
  41. data/lib/asset_hat/vcs.rb +23 -20
  42. data/lib/asset_hat/version.rb +2 -0
  43. data/lib/asset_hat.rb +94 -19
  44. data/tasks/asset_hat.rake +1 -1
  45. data/test/asset_hat_helper_test.rb +63 -9
  46. data/test/test_helper.rb +5 -1
  47. metadata +94 -26
  48. data/README.markdown +0 -154
@@ -0,0 +1,446 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>: AssetHat [AssetHat]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ AssetHat
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../files/lib/asset_hat/css_rb.html">lib/asset_hat/css.rb</a>
35
+ </li>
36
+ <li class='other'>
37
+ <a href="../files/lib/asset_hat/js/vendors_rb.html">lib/asset_hat/js/vendors.rb</a>
38
+ </li>
39
+ <li class='other'>
40
+ <a href="../files/lib/asset_hat/js_rb.html">lib/asset_hat/js.rb</a>
41
+ </li>
42
+ <li class='other'>
43
+ <a href="../files/lib/asset_hat/vcs_rb.html">lib/asset_hat/vcs.rb</a>
44
+ </li>
45
+ <li class='other'>
46
+ <a href="../files/lib/asset_hat/version_rb.html">lib/asset_hat/version.rb</a>
47
+ </li>
48
+ <li class='other'>
49
+ <a href="../files/lib/asset_hat_rb.html">lib/asset_hat.rb</a>
50
+ </li>
51
+ <li>
52
+ <a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
53
+ </li>
54
+ </ol>
55
+ </div>
56
+ <div id='content'>
57
+ <div id='text'>
58
+ <div id='description'>
59
+ <p>
60
+ Your assets are covered.
61
+ </p>
62
+ <p>
63
+ With Rails&#8217; default asset caching, <a
64
+ href="AssetHat/CSS.html">CSS</a> and <a href="AssetHat/JS.html">JS</a> are
65
+ concatenated (not even minified) the first time that bundle is requested.
66
+ Not good enough. <a href="AssetHat.html">AssetHat</a> can automatically:
67
+ </p>
68
+ <ul>
69
+ <li>Easily <b>minify</b> and <b>bundle</b> <a href="AssetHat/CSS.html">CSS</a>
70
+ and <a href="AssetHat/JS.html">JS</a> on deploy to reduce file sizes and
71
+ HTTP requests.
72
+
73
+ </li>
74
+ <li>Load popular <strong>third-party JS</strong> (like jQuery and Prototype)
75
+ from <a href="http://code.google.com/apis/ajaxlibs/"><strong>Google's
76
+ CDN</strong></a> when in production, or from localhost in development.
77
+
78
+ </li>
79
+ <li>Force image URLs in your <a href="AssetHat/CSS.html">CSS</a> to use
80
+ <strong>CDN subdomains</strong>, not just the current host.
81
+
82
+ </li>
83
+ <li>Add an image&#8217;s last <a href="http://git-scm.com/">Git</a> commit ID
84
+ to its <a href="AssetHat/CSS.html">CSS</a> URLs to <strong>bust browser
85
+ caches</strong> (e.g., <tt>/images/foo.png?ab12cd34e</tt>).
86
+
87
+ </li>
88
+ </ul>
89
+ <p>
90
+ After setup, you can use these in your layouts and views:
91
+ </p>
92
+ <pre>&lt;%= include_css :bundle =&gt; 'application' %&gt;&#x000A; # =&gt; &lt;link href=&quot;/stylesheets/bundles/application.min.css&quot;&#x000A; # media=&quot;screen,projection&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;&#x000A;&#x000A;&lt;%= include_js :bundles =&gt; ['plugins', 'common'] %&gt;&#x000A; # =&gt; &lt;script src=&quot;/javascripts/bundles/plugins.min.js&quot;&#x000A; # type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&#x000A; # &lt;script src=&quot;/javascripts/bundles/common.min.js&quot;&#x000A; # type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
93
+ <p>
94
+ And this in your deploy script:
95
+ </p>
96
+ <pre>rake asset_hat:minify</pre>
97
+ <p>
98
+ See <a href="../files/README_rdoc.html">README.rdoc</a> for more.
99
+ </p>
100
+ </div>
101
+ <div id='method-list'>
102
+ <h2>Methods</h2>
103
+ <h3>public class</h3>
104
+ <ol>
105
+ <li><a href="#M000006">asset_exists?</a></li>
106
+ <li><a href="#M000005">assets_dir</a></li>
107
+ <li><a href="#M000009">bundle_filenames</a></li>
108
+ <li><a href="#M000010">bundle_filepaths</a></li>
109
+ <li><a href="#M000007">cache?</a></li>
110
+ <li><a href="#M000011">clear_html_cache</a></li>
111
+ <li><a href="#M000004">config</a></li>
112
+ <li><a href="#M000002">last_bundle_commit_id</a></li>
113
+ <li><a href="#M000001">last_commit_id</a></li>
114
+ <li><a href="#M000008">min_filepath</a></li>
115
+ <li><a href="#M000003">version</a></li>
116
+ </ol>
117
+ </div>
118
+ <div id='section'>
119
+ <div id='class-list'>
120
+ <h2>Classes and Modules</h2>
121
+ Module <a href="AssetHat/CSS.html" class="link">AssetHat::CSS</a><br />
122
+ Module <a href="AssetHat/JS.html" class="link">AssetHat::JS</a><br />
123
+ </div>
124
+ <div id='constants-list'>
125
+ <h2>Constants</h2>
126
+ <div class='name-list'>
127
+ <table summary='Constants'>
128
+ <tr class='top-aligned-row context-row'>
129
+ <td class='context-item-name'>VERSION</td>
130
+ <td>=</td>
131
+ <td class='context-item-value'>self.version</td>
132
+ <td>&nbsp;</td>
133
+ <td class='context-item-desc'>
134
+
135
+ This gem&#8217;s version number.
136
+ </td>
137
+ </tr>
138
+ <tr class='top-aligned-row context-row'>
139
+ <td class='context-item-name'>TYPES</td>
140
+ <td>=</td>
141
+ <td class='context-item-value'>[:css, :js]</td>
142
+ <td>&nbsp;</td>
143
+ <td class='context-item-desc'>
144
+
145
+ Types of supported assets; currently <tt>[:css, :js]</tt>.
146
+ </td>
147
+ </tr>
148
+ <tr class='top-aligned-row context-row'>
149
+ <td class='context-item-name'>ASSETS_DIR</td>
150
+ <td>=</td>
151
+ <td class='context-item-value'>defined?(Rails.public_path) ? Rails.public_path : 'public'</td>
152
+ <td>&nbsp;</td>
153
+ <td class='context-item-desc'>
154
+
155
+ Base directory in which all assets are kept, e.g., &#8216;public/&#8217;.
156
+ </td>
157
+ </tr>
158
+ <tr class='top-aligned-row context-row'>
159
+ <td class='context-item-name'>STYLESHEETS_DIR</td>
160
+ <td>=</td>
161
+ <td class='context-item-value'>&quot;#{ASSETS_DIR}/stylesheets&quot;</td>
162
+ <td>&nbsp;</td>
163
+ <td class='context-item-desc'>
164
+
165
+ Directory in which all stylesheets are kept, e.g.,
166
+ &#8216;public/stylesheets/&#8217;.
167
+ </td>
168
+ </tr>
169
+ <tr class='top-aligned-row context-row'>
170
+ <td class='context-item-name'>JAVASCRIPTS_DIR</td>
171
+ <td>=</td>
172
+ <td class='context-item-value'>&quot;#{ASSETS_DIR}/javascripts&quot;</td>
173
+ <td>&nbsp;</td>
174
+ <td class='context-item-desc'>
175
+
176
+ Directory in which all JavaScripts are kept, e.g.,
177
+ &#8216;public/javascripts/&#8217;.
178
+ </td>
179
+ </tr>
180
+ <tr class='top-aligned-row context-row'>
181
+ <td class='context-item-name'>RELATIVE_CONFIG_FILEPATH</td>
182
+ <td>=</td>
183
+ <td class='context-item-value'>File.join('config', 'assets.yml')</td>
184
+ <td>&nbsp;</td>
185
+ <td class='context-item-desc'>
186
+
187
+ Relative path for the config file.
188
+ </td>
189
+ </tr>
190
+ <tr class='top-aligned-row context-row'>
191
+ <td class='context-item-name'>CONFIG_FILEPATH</td>
192
+ <td>=</td>
193
+ <td class='context-item-value'>File.join(RAILS_ROOT, RELATIVE_CONFIG_FILEPATH)</td>
194
+ <td>&nbsp;</td>
195
+ <td class='context-item-desc'>
196
+
197
+ Absolute path for the config file.
198
+ </td>
199
+ </tr>
200
+ </table>
201
+ </div>
202
+ </div>
203
+ <div id='methods'>
204
+ <h2>Public class methods</h2>
205
+ <div class='method public-class' id='method-M000006'>
206
+ <a name='M000006'></a>
207
+ <div class='synopsis'>
208
+ <span class='name'>asset_exists?</span>
209
+ <span class='arguments'>(filename, type)</span>
210
+ </div>
211
+ <div class='description'>
212
+ <p>
213
+ Returns true if the specified asset exists in the file system:
214
+ </p>
215
+ <pre>AssetHat.asset_exists?('application', :css)&#x000A; # =&gt; true if /public/stylesheets/application.css exists&#x000A;AssetHat.asset_exists?('some-plugin', :js)&#x000A; # =&gt; true if /public/javascripts/some-plugin.js exists</pre>
216
+ <p>
217
+ See also <tt>AssetHat::STYLESHEETS_DIR</tt> and
218
+ <tt>AssetHat::JAVASCRIPTS_DIR</tt>.
219
+ </p>
220
+ </div>
221
+ <div class='source'>
222
+ <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
223
+ [show source]
224
+ </a>
225
+ <pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 92</span>&#x000A; 92: <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>)&#x000A; 93: <span class="ruby-comment cmt"># Process arguments</span>&#x000A; 94: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>&#x000A; 95: <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>)&#x000A; 96: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown type \&quot;#{type}\&quot;; should be one of: #{TYPES.join(', ')}.&quot;</span>&#x000A; 97: <span class="ruby-keyword kw">return</span>&#x000A; 98: <span class="ruby-keyword kw">end</span>&#x000A; 99: &#x000A;100: <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-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hsh</span>, <span class="ruby-identifier">known_type</span><span class="ruby-operator">|</span>&#x000A;101: <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">known_type</span> =<span class="ruby-operator">&gt;</span> {})&#x000A;102: <span class="ruby-keyword kw">end</span>&#x000A;103: <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>&#x000A;104: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>] =&#x000A;105: <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>))&#x000A;106: <span class="ruby-keyword kw">end</span>&#x000A;107: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>]&#x000A;108: <span class="ruby-keyword kw">end</span></pre>
226
+ </div>
227
+ </div>
228
+ <div class='method public-class' id='method-M000005'>
229
+ <a name='M000005'></a>
230
+ <div class='synopsis'>
231
+ <span class='name'>assets_dir</span>
232
+ <span class='arguments'>(type)</span>
233
+ </div>
234
+ <div class='description'>
235
+ <p>
236
+ Argument: <tt>:css</tt> or <tt>:js</tt>
237
+ </p>
238
+ <p>
239
+ Returns the path to the directory where <a href="AssetHat/CSS.html">CSS</a>
240
+ or <a href="AssetHat/JS.html">JS</a> files are stored.
241
+ </p>
242
+ </div>
243
+ <div class='source'>
244
+ <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
245
+ [show source]
246
+ </a>
247
+ <pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 75</span>&#x000A;75: <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>)&#x000A;76: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>&#x000A;77: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:css</span> ; <span class="ruby-constant">STYLESHEETS_DIR</span>&#x000A;78: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:js</span> ; <span class="ruby-constant">JAVASCRIPTS_DIR</span>&#x000A;79: <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">nil</span>&#x000A;80: <span class="ruby-keyword kw">end</span>&#x000A;81: <span class="ruby-keyword kw">end</span></pre>
248
+ </div>
249
+ </div>
250
+ <div class='method public-class' id='method-M000009'>
251
+ <a name='M000009'></a>
252
+ <div class='synopsis'>
253
+ <span class='name'>bundle_filenames</span>
254
+ <span class='arguments'>(bundle, type)</span>
255
+ </div>
256
+ <div class='description'>
257
+ <p>
258
+ Returns the extension-less names of files in the given bundle:
259
+ </p>
260
+ <pre>AssetHat.bundle_filenames('application', :css)&#x000A; # =&gt; ['reset', 'application', 'clearfix']&#x000A;AssetHat.bundle_filenames('non-existent-file', :css)&#x000A; # =&gt; nil</pre>
261
+ </div>
262
+ <div class='source'>
263
+ <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
264
+ [show source]
265
+ </a>
266
+ <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 134</span>&#x000A;134: <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>)&#x000A;135: <span class="ruby-comment cmt"># Process arguments</span>&#x000A;136: <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>)&#x000A;137: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown type \&quot;#{type}\&quot;; should be one of: #{TYPES.join(', ')}.&quot;</span>&#x000A;138: <span class="ruby-keyword kw">return</span>&#x000A;139: <span class="ruby-keyword kw">end</span>&#x000A;140: &#x000A;141: <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>&#x000A;142: <span class="ruby-keyword kw">end</span></pre>
267
+ </div>
268
+ </div>
269
+ <div class='method public-class' id='method-M000010'>
270
+ <a name='M000010'></a>
271
+ <div class='synopsis'>
272
+ <span class='name'>bundle_filepaths</span>
273
+ <span class='arguments'>(bundle, type)</span>
274
+ </div>
275
+ <div class='description'>
276
+ <p>
277
+ Returns the full paths of files in the given bundle:
278
+ </p>
279
+ <pre>AssetHat.bundle_filenames('application', :css)&#x000A; # =&gt; ['/path/to/app/public/stylesheets/reset.css',&#x000A; '/path/to/app/public/stylesheets/application.css',&#x000A; '/path/to/app/public/stylesheets/clearfix.css']&#x000A;AssetHat.bundle_filenames('non-existent-file', :css)&#x000A; # =&gt; nil</pre>
280
+ </div>
281
+ <div class='source'>
282
+ <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
283
+ [show source]
284
+ </a>
285
+ <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 152</span>&#x000A;152: <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>)&#x000A;153: <span class="ruby-comment cmt"># Process arguments</span>&#x000A;154: <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>)&#x000A;155: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown type \&quot;#{type}\&quot;; should be one of: #{TYPES.join(', ')}.&quot;</span>&#x000A;156: <span class="ruby-keyword kw">return</span>&#x000A;157: <span class="ruby-keyword kw">end</span>&#x000A;158: &#x000A;159: <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>)&#x000A;160: <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>)&#x000A;161: <span class="ruby-identifier">filepaths</span> = <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">present?</span> <span class="ruby-value">?&#x000A;162: </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">&quot;#{fn}.#{type}&quot;</span>) } <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>&#x000A;163: <span class="ruby-keyword kw">end</span></pre>
286
+ </div>
287
+ </div>
288
+ <div class='method public-class' id='method-M000007'>
289
+ <a name='M000007'></a>
290
+ <div class='synopsis'>
291
+ <span class='name'>cache?</span>
292
+ <span class='arguments'>()</span>
293
+ </div>
294
+ <div class='description'>
295
+ <p>
296
+ Returns <tt>true</tt> if bundles should be included as single minified
297
+ files (e.g., in production), or <tt>false</tt> if bundles should be
298
+ included as separate, unminified files (e.g., in development). To modify
299
+ this value, set <tt>config.action_controller.perform_caching = true</tt> in
300
+ your environment.
301
+ </p>
302
+ </div>
303
+ <div class='source'>
304
+ <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
305
+ [show source]
306
+ </a>
307
+ <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 115</span>&#x000A;115: <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>
308
+ </div>
309
+ </div>
310
+ <div class='method public-class' id='method-M000011'>
311
+ <a name='M000011'></a>
312
+ <div class='synopsis'>
313
+ <span class='name'>clear_html_cache</span>
314
+ <span class='arguments'>()</span>
315
+ </div>
316
+ <div class='source'>
317
+ <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
318
+ [show source]
319
+ </a>
320
+ <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 165</span>&#x000A;165: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clear_html_cache</span>&#x000A;166: <span class="ruby-identifier">html_cache</span> = {}&#x000A;167: <span class="ruby-keyword kw">end</span></pre>
321
+ </div>
322
+ </div>
323
+ <div class='method public-class' id='method-M000004'>
324
+ <a name='M000004'></a>
325
+ <div class='synopsis'>
326
+ <span class='name'>config</span>
327
+ <span class='arguments'>()</span>
328
+ </div>
329
+ <div class='description'>
330
+ <p>
331
+ Nested-hash version of <tt>config/assets.yml</tt>.
332
+ </p>
333
+ </div>
334
+ <div class='source'>
335
+ <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
336
+ [show source]
337
+ </a>
338
+ <pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 65</span>&#x000A;65: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config</span>&#x000A;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>&#x000A;67: <span class="ruby-ivar">@config</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-constant">CONFIG_FILEPATH</span>, <span class="ruby-value str">'r'</span>))&#x000A;68: <span class="ruby-keyword kw">end</span>&#x000A;69: <span class="ruby-ivar">@config</span>&#x000A;70: <span class="ruby-keyword kw">end</span></pre>
339
+ </div>
340
+ </div>
341
+ <div class='method public-class' id='method-M000002'>
342
+ <a name='M000002'></a>
343
+ <div class='synopsis'>
344
+ <span class='name'>last_bundle_commit_id</span>
345
+ <span class='arguments'>(bundle, type)</span>
346
+ </div>
347
+ <div class='description'>
348
+ <p>
349
+ Usage:
350
+ </p>
351
+ <pre>AssetHat.last_bundle_commit_id('application', :css)</pre>
352
+ <p>
353
+ Returns a string of the latest commit ID for the given bundle, based on
354
+ which of its files were most recently modified in the repository. If no ID
355
+ can be found, `nil` is returned.
356
+ </p>
357
+ </div>
358
+ <div class='source'>
359
+ <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
360
+ [show source]
361
+ </a>
362
+ <pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/asset_hat/vcs.rb, line 45</span>&#x000A;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>)&#x000A;46: <span class="ruby-comment cmt"># Process arguments</span>&#x000A;47: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>&#x000A;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>)&#x000A;49: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown type \&quot;#{type}\&quot;; should be one of: #{TYPES.join(', ')}.&quot;</span>&#x000A;50: <span class="ruby-keyword kw">return</span>&#x000A;51: <span class="ruby-keyword kw">end</span>&#x000A;52: &#x000A;53: <span class="ruby-comment cmt"># Default to `{:css =&gt; {}, :js =&gt; {}}`</span>&#x000A;54: <span class="ruby-ivar">@last_bundle_commit_ids</span> <span class="ruby-operator">||=</span>&#x000A;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">&gt;</span> {}) }&#x000A;56: &#x000A;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>&#x000A;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>)&#x000A;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>)&#x000A;60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filepaths</span>.<span class="ruby-identifier">present?</span>&#x000A;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>)&#x000A;62: <span class="ruby-keyword kw">end</span>&#x000A;63: <span class="ruby-keyword kw">end</span>&#x000A;64: &#x000A;65: <span class="ruby-ivar">@last_bundle_commit_ids</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">bundle</span>]&#x000A;66: <span class="ruby-keyword kw">end</span></pre>
363
+ </div>
364
+ </div>
365
+ <div class='method public-class' id='method-M000001'>
366
+ <a name='M000001'></a>
367
+ <div class='synopsis'>
368
+ <span class='name'>last_commit_id</span>
369
+ <span class='arguments'>(*args)</span>
370
+ </div>
371
+ <div class='description'>
372
+ <p>
373
+ Usage:
374
+ </p>
375
+ <pre>AssetHat.last_commit_id('public/stylesheets/application.css')&#x000A;AssetHat.last_commit_id('public/stylesheets/ie.css',&#x000A; 'public/stylesheets/ie7.css',&#x000A; 'public/stylesheets/ie6.css')</pre>
376
+ <p>
377
+ Returns a string of the commit ID for the file with the most recent commit.
378
+ If the file(s) cannot be found, `nil` is returned. Options:
379
+ </p>
380
+ <dl>
381
+ <dt>vcs</dt><dd>Version control system. Currently, the only supported value is
382
+ <tt>:git</tt>.
383
+
384
+ </dd>
385
+ </dl>
386
+ </div>
387
+ <div class='source'>
388
+ <a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
389
+ [show source]
390
+ </a>
391
+ <pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/asset_hat/vcs.rb, line 18</span>&#x000A;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>)&#x000A;19: <span class="ruby-comment cmt"># Process arguments</span>&#x000A;20: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>&#x000A;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">&gt;</span> <span class="ruby-identifier">:git</span>)&#x000A;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>)&#x000A;23: &#x000A;24: <span class="ruby-comment cmt"># Validate options</span>&#x000A;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>&#x000A;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>&#x000A;27: <span class="ruby-keyword kw">end</span>&#x000A;28: &#x000A;29: <span class="ruby-ivar">@last_commit_ids</span> <span class="ruby-operator">||=</span> {}&#x000A;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>&#x000A;31: <span class="ruby-identifier">h</span> = <span class="ruby-node">`git log -1 --pretty=format:%h #{filepaths} 2&gt;/dev/null`</span>&#x000A;32: <span class="ruby-comment cmt"># `h` has either the abbreviated Git commit hash or an empty string</span>&#x000A;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>&#x000A;34: <span class="ruby-keyword kw">end</span>&#x000A;35: <span class="ruby-ivar">@last_commit_ids</span>[<span class="ruby-identifier">filepaths</span>]&#x000A;36: <span class="ruby-keyword kw">end</span></pre>
392
+ </div>
393
+ </div>
394
+ <div class='method public-class' id='method-M000008'>
395
+ <a name='M000008'></a>
396
+ <div class='synopsis'>
397
+ <span class='name'>min_filepath</span>
398
+ <span class='arguments'>(filepath, extension)</span>
399
+ </div>
400
+ <div class='description'>
401
+ <p>
402
+ Returns the expected path for the minified version of an asset:
403
+ </p>
404
+ <pre>AssetHat.min_filepath('public/stylesheets/bundles/application.css', 'css')&#x000A; # =&gt; 'public/stylesheets/bundles/application.min.css'</pre>
405
+ <p>
406
+ See also <tt><a
407
+ href="AssetHat/CSS.html#M000012">AssetHat::CSS.min_filepath</a></tt> and
408
+ <tt><a href="AssetHat/JS.html#M000018">AssetHat::JS.min_filepath</a></tt>.
409
+ </p>
410
+ </div>
411
+ <div class='source'>
412
+ <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
413
+ [show source]
414
+ </a>
415
+ <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/asset_hat.rb, line 124</span>&#x000A;124: <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>)&#x000A;125: <span class="ruby-identifier">filepath</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-node">/([^\.]*).#{extension}$/</span>, <span class="ruby-node">&quot;\\1.min.#{extension}&quot;</span>)&#x000A;126: <span class="ruby-keyword kw">end</span></pre>
416
+ </div>
417
+ </div>
418
+ <div class='method public-class' id='method-M000003'>
419
+ <a name='M000003'></a>
420
+ <div class='synopsis'>
421
+ <span class='name'>version</span>
422
+ <span class='arguments'>()</span>
423
+ </div>
424
+ <div class='description'>
425
+ <p>
426
+ Returns this gem&#8217;s version number. See also VERSION.
427
+ </p>
428
+ </div>
429
+ <div class='source'>
430
+ <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
431
+ [show source]
432
+ </a>
433
+ <pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/asset_hat/version.rb, line 3</span>&#x000A;3: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">version</span>&#x000A;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>)&#x000A;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>))&#x000A;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>].&#x000A;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">&amp;</span><span class="ruby-identifier">:blank?</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'.'</span>)&#x000A;8: <span class="ruby-keyword kw">end</span></pre>
434
+ </div>
435
+ </div>
436
+ </div>
437
+ </div>
438
+ </div>
439
+ </div>
440
+ <div id='footer-push'></div>
441
+ </div>
442
+ <div id='footer'>
443
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
444
+ </div>
445
+ </body>
446
+ </html>