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.
- data/HISTORY +13 -14
- data/README.rdoc +171 -0
- data/Rakefile +24 -2
- data/VERSION.yml +3 -3
- data/app/helpers/asset_hat_helper.rb +67 -61
- data/asset_hat.gemspec +42 -8
- data/doc/classes/AssetHat/CSS/Engines.html +118 -0
- data/doc/classes/AssetHat/CSS.html +194 -0
- data/doc/classes/AssetHat/JS/Engines.html +122 -0
- data/doc/classes/AssetHat/JS/Vendors.html +110 -0
- data/doc/classes/AssetHat/JS.html +151 -0
- data/doc/classes/AssetHat.html +446 -0
- data/doc/classes/AssetHatHelper.html +161 -0
- data/doc/created.rid +1 -0
- data/doc/files/HISTORY.html +116 -0
- data/doc/files/LICENSE.html +76 -0
- data/doc/files/README_rdoc.html +234 -0
- data/doc/files/app/helpers/asset_hat_helper_rb.html +55 -0
- data/doc/files/lib/asset_hat/capistrano_rb.html +49 -0
- data/doc/files/lib/asset_hat/css_rb.html +57 -0
- data/doc/files/lib/asset_hat/js/vendors_rb.html +49 -0
- data/doc/files/lib/asset_hat/js_rb.html +57 -0
- data/doc/files/lib/asset_hat/tasks/css_rb.html +49 -0
- data/doc/files/lib/asset_hat/tasks/js_rb.html +49 -0
- data/doc/files/lib/asset_hat/tasks_rb.html +58 -0
- data/doc/files/lib/asset_hat/vcs_rb.html +49 -0
- data/doc/files/lib/asset_hat/version_rb.html +49 -0
- data/doc/files/lib/asset_hat_rb.html +49 -0
- data/doc/fr_class_index.html +23 -0
- data/doc/fr_file_index.html +33 -0
- data/doc/fr_method_index.html +4455 -0
- data/doc/index.html +15 -0
- data/doc/rdoc-style.css +328 -0
- data/lib/asset_hat/capistrano.rb +14 -0
- data/lib/asset_hat/css.rb +40 -10
- data/lib/asset_hat/js/vendors.rb +85 -0
- data/lib/asset_hat/js.rb +28 -29
- data/lib/asset_hat/tasks/css.rb +151 -0
- data/lib/asset_hat/tasks/js.rb +100 -0
- data/lib/asset_hat/tasks.rb +4 -272
- data/lib/asset_hat/vcs.rb +23 -20
- data/lib/asset_hat/version.rb +2 -0
- data/lib/asset_hat.rb +94 -19
- data/tasks/asset_hat.rake +1 -1
- data/test/asset_hat_helper_test.rb +63 -9
- data/test/test_helper.rb +5 -1
- metadata +94 -26
- 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’ 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’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><%= include_css :bundle => 'application' %>
 # => <link href="/stylesheets/bundles/application.min.css"
 # media="screen,projection" rel="stylesheet" type="text/css" />

<%= include_js :bundles => ['plugins', 'common'] %>
 # => <script src="/javascripts/bundles/plugins.min.js"
 # type="text/javascript"></script>
 # <script src="/javascripts/bundles/common.min.js"
 # type="text/javascript"></script></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> </td>
|
133
|
+
<td class='context-item-desc'>
|
134
|
+
|
135
|
+
This gem’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> </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> </td>
|
153
|
+
<td class='context-item-desc'>
|
154
|
+
|
155
|
+
Base directory in which all assets are kept, e.g., ‘public/’.
|
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'>"#{ASSETS_DIR}/stylesheets"</td>
|
162
|
+
<td> </td>
|
163
|
+
<td class='context-item-desc'>
|
164
|
+
|
165
|
+
Directory in which all stylesheets are kept, e.g.,
|
166
|
+
‘public/stylesheets/’.
|
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'>"#{ASSETS_DIR}/javascripts"</td>
|
173
|
+
<td> </td>
|
174
|
+
<td class='context-item-desc'>
|
175
|
+
|
176
|
+
Directory in which all JavaScripts are kept, e.g.,
|
177
|
+
‘public/javascripts/’.
|
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> </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> </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)
 # => true if /public/stylesheets/application.css exists
AssetHat.asset_exists?('some-plugin', :js)
 # => 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>
 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>)
 93: <span class="ruby-comment cmt"># Process arguments</span>
 94: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
 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>)
 96: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
 97: <span class="ruby-keyword kw">return</span>
 98: <span class="ruby-keyword kw">end</span>
 99: 
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>
101: <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">known_type</span> =<span class="ruby-operator">></span> {})
102: <span class="ruby-keyword kw">end</span>
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>
104: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>] =
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>))
106: <span class="ruby-keyword kw">end</span>
107: <span class="ruby-ivar">@asset_exists</span>[<span class="ruby-identifier">type</span>][<span class="ruby-identifier">filename</span>]
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>
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>)
76: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
77: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:css</span> ; <span class="ruby-constant">STYLESHEETS_DIR</span>
78: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:js</span> ; <span class="ruby-constant">JAVASCRIPTS_DIR</span>
79: <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">nil</span>
80: <span class="ruby-keyword kw">end</span>
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)
 # => ['reset', 'application', 'clearfix']
AssetHat.bundle_filenames('non-existent-file', :css)
 # => 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>
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>)
135: <span class="ruby-comment cmt"># Process arguments</span>
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>)
137: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
138: <span class="ruby-keyword kw">return</span>
139: <span class="ruby-keyword kw">end</span>
140: 
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>
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)
 # => ['/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>
|
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>
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>)
153: <span class="ruby-comment cmt"># Process arguments</span>
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>)
155: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."</span>
156: <span class="ruby-keyword kw">return</span>
157: <span class="ruby-keyword kw">end</span>
158: 
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>)
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>)
161: <span class="ruby-identifier">filepaths</span> = <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">present?</span> <span class="ruby-value">?
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">"#{fn}.#{type}"</span>) } <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
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>
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>
165: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clear_html_cache</span>
166: <span class="ruby-identifier">html_cache</span> = {}
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>
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">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">CONFIG_FILEPATH</span>, <span class="ruby-value str">'r'</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>
|
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>
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>
|
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')
AssetHat.last_commit_id('public/stylesheets/ie.css',
 'public/stylesheets/ie7.css',
 '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>
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>
|
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')
 # => '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>
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>)
125: <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>)
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’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>
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>
|
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>
|