doc/classes/AssetHat.html in asset_hat-0.2.1 vs doc/classes/AssetHat.html in asset_hat-0.3.0
- old
+ new
@@ -81,11 +81,11 @@
<strong>CDN subdomains</strong>, not just the current host.
</li>
<li>Add an image’s last <a href="http://git-scm.com/">Git</a> commit ID
to its <a href="AssetHat/CSS.html">CSS</a> URLs to <strong>bust browser
- caches</strong> (e.g., <tt>/images/foo.png?ab12cd34e</tt>).
+ caches</strong> (e.g., <tt>/images/foo.png?ab12cd3</tt>).
</li>
</ul>
<p>
After setup, you can use these in your layouts and views:
@@ -101,21 +101,25 @@
</div>
<div id='method-list'>
<h2>Methods</h2>
<h3>public class</h3>
<ol>
- <li><a href="#M000006">asset_exists?</a></li>
- <li><a href="#M000005">assets_dir</a></li>
- <li><a href="#M000009">bundle_filenames</a></li>
- <li><a href="#M000010">bundle_filepaths</a></li>
- <li><a href="#M000007">cache?</a></li>
- <li><a href="#M000011">clear_html_cache</a></li>
- <li><a href="#M000004">config</a></li>
- <li><a href="#M000003">last_bundle_commit_id</a></li>
+ <li><a href="#M000008">asset_exists?</a></li>
+ <li><a href="#M000006">assets_dir</a></li>
+ <li><a href="#M000011">bundle_filenames</a></li>
+ <li><a href="#M000012">bundle_filepaths</a></li>
+ <li><a href="#M000007">bundles_dir</a></li>
+ <li><a href="#M000009">cache?</a></li>
+ <li><a href="#M000003">cache_last_commit_ids</a></li>
+ <li><a href="#M000015">clear_html_cache</a></li>
+ <li><a href="#M000013">compute_asset_host</a></li>
+ <li><a href="#M000005">config</a></li>
+ <li><a href="#M000002">last_bundle_commit_id</a></li>
<li><a href="#M000001">last_commit_id</a></li>
- <li><a href="#M000008">min_filepath</a></li>
- <li><a href="#M000002">version</a></li>
+ <li><a href="#M000010">min_filepath</a></li>
+ <li><a href="#M000014">ssl_asset_host_differs?</a></li>
+ <li><a href="#M000004">version</a></li>
</ol>
</div>
<div id='section'>
<div id='class-list'>
<h2>Classes and Modules</h2>
@@ -157,22 +161,22 @@
</td>
</tr>
<tr class='top-aligned-row context-row'>
<td class='context-item-name'>STYLESHEETS_DIR</td>
<td>=</td>
- <td class='context-item-value'>"#{ASSETS_DIR}/stylesheets"</td>
+ <td class='context-item-value'>File.join(ASSETS_DIR, 'stylesheets')</td>
<td> </td>
<td class='context-item-desc'>
Directory in which all stylesheets are kept, e.g.,
‘public/stylesheets/’.
</td>
</tr>
<tr class='top-aligned-row context-row'>
<td class='context-item-name'>JAVASCRIPTS_DIR</td>
<td>=</td>
- <td class='context-item-value'>"#{ASSETS_DIR}/javascripts"</td>
+ <td class='context-item-value'>File.join(ASSETS_DIR, 'javascripts')</td>
<td> </td>
<td class='context-item-desc'>
Directory in which all JavaScripts are kept, e.g.,
‘public/javascripts/’.
@@ -201,57 +205,57 @@
</table>
</div>
</div>
<div id='methods'>
<h2>Public class methods</h2>
- <div class='method public-class' id='method-M000006'>
- <a name='M000006'></a>
+ <div class='method public-class' id='method-M000008'>
+ <a name='M000008'></a>
<div class='synopsis'>
<span class='name'>asset_exists?</span>
<span class='arguments'>(filename, type)</span>
</div>
<div class='description'>
<p>
Returns true if the specified asset exists in the file system:
</p>
- <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>
+ <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>
<p>
- See also <tt>AssetHat::STYLESHEETS_DIR</tt> and
- <tt>AssetHat::JAVASCRIPTS_DIR</tt>.
+ See also <tt><a href="AssetHat.html#M000006">AssetHat.assets_dir</a></tt>.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000005'>
- <a name='M000005'></a>
+ <div class='method public-class' id='method-M000006'>
+ <a name='M000006'></a>
<div class='synopsis'>
<span class='name'>assets_dir</span>
<span class='arguments'>(type)</span>
</div>
<div class='description'>
<p>
- Argument: <tt>:css</tt> or <tt>:js</tt>
+ Returns the relative path to the directory where the original <a
+ href="AssetHat/CSS.html">CSS</a> or <a href="AssetHat/JS.html">JS</a> files
+ are stored.
</p>
<p>
- Returns the path to the directory where <a href="AssetHat/CSS.html">CSS</a>
- or <a href="AssetHat/JS.html">JS</a> files are stored.
+ <tt>type</tt> argument: <tt>:css</tt> or <tt>:js</tt>
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000009'>
- <a name='M000009'></a>
+ <div class='method public-class' id='method-M000011'>
+ <a name='M000011'></a>
<div class='synopsis'>
<span class='name'>bundle_filenames</span>
<span class='arguments'>(bundle, type)</span>
</div>
<div class='description'>
@@ -259,18 +263,18 @@
Returns the extension-less names of files in the given bundle:
</p>
<pre>AssetHat.bundle_filenames('application', :css)
 # => ['reset', 'application', 'clearfix']
AssetHat.bundle_filenames('non-existent-file', :css)
 # => nil</pre>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000010'>
- <a name='M000010'></a>
+ <div class='method public-class' id='method-M000012'>
+ <a name='M000012'></a>
<div class='synopsis'>
<span class='name'>bundle_filepaths</span>
<span class='arguments'>(bundle, type)</span>
</div>
<div class='description'>
@@ -278,19 +282,52 @@
Returns the full paths of files in the given bundle:
</p>
<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>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
<div class='method public-class' id='method-M000007'>
<a name='M000007'></a>
<div class='synopsis'>
+ <span class='name'>bundles_dir</span>
+ <span class='arguments'>(*args)</span>
+ </div>
+ <div class='description'>
+ <p>
+ Returns the relative path to the directory where <a
+ href="AssetHat/CSS.html">CSS</a> or <a href="AssetHat/JS.html">JS</a>
+ bundles are stored.
+ </p>
+ <p>
+ Usage:
+ </p>
+ <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>
+ <p>
+ Options:
+ </p>
+ <dl>
+ <dt>ssl</dt><dd>Set this to <tt>true</tt> if the stylesheet references images via SSL.
+ Defaults to <tt>false</tt>.
+
+ </dd>
+ </dl>
+ </div>
+ <div class='source'>
+ <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
+ [show source]
+ </a>
+ <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>
+ </div>
+ </div>
+ <div class='method public-class' id='method-M000009'>
+ <a name='M000009'></a>
+ <div class='synopsis'>
<span class='name'>cache?</span>
<span class='arguments'>()</span>
</div>
<div class='description'>
<p>
@@ -300,49 +337,107 @@
this value, set <tt>config.action_controller.perform_caching = true</tt> in
your environment.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000011'>
- <a name='M000011'></a>
+ <div class='method public-class' id='method-M000003'>
+ <a name='M000003'></a>
<div class='synopsis'>
+ <span class='name'>cache_last_commit_ids</span>
+ <span class='arguments'>()</span>
+ </div>
+ <div class='description'>
+ <p>
+ Precomputes and caches the last commit ID for all bundles. Your web server
+ process(es) should run this at boot to avoid overhead during user runtime.
+ </p>
+ </div>
+ <div class='source'>
+ <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
+ [show source]
+ </a>
+ <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>
+ </div>
+ </div>
+ <div class='method public-class' id='method-M000015'>
+ <a name='M000015'></a>
+ <div class='synopsis'>
<span class='name'>clear_html_cache</span>
<span class='arguments'>()</span>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000004'>
- <a name='M000004'></a>
+ <div class='method public-class' id='method-M000013'>
+ <a name='M000013'></a>
<div class='synopsis'>
+ <span class='name'>compute_asset_host</span>
+ <span class='arguments'>(asset_host, source, options={})</span>
+ </div>
+ <div class='description'>
+ <p>
+ Reads <tt>ActionController::Base.asset_host</tt>, which can be a String or
+ Proc, and returns a String. Should behave just like Rails 2.3.x’s
+ private `<a href="AssetHat.html#M000013">compute_asset_host</a>` method,
+ but with a simulated request.
+ </p>
+ <p>
+ Example environment config for CDN support via SSL:
+ </p>
+ <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>
+ <p>
+ If your CDN doesn’t have SSL support, you can instead revert SSL
+ pages to serving assets from your web server:
+ </p>
+ <pre>config.action_controller.asset_host = Proc.new do |source, request|
 request.ssl? ? nil : "http://cdn#{source.hash % 4}.example.com"
end</pre>
+ <p>
+ Options:
+ </p>
+ <dl>
+ <dt>ssl</dt><dd>Set to <tt>true</tt> to simulate a request via SSL. Defaults to
+ <tt>false</tt>.
+
+ </dd>
+ </dl>
+ </div>
+ <div class='source'>
+ <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
+ [show source]
+ </a>
+ <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>
+ </div>
+ </div>
+ <div class='method public-class' id='method-M000005'>
+ <a name='M000005'></a>
+ <div class='synopsis'>
<span class='name'>config</span>
<span class='arguments'>()</span>
</div>
<div class='description'>
<p>
Nested-hash version of <tt>config/assets.yml</tt>.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000003'>
- <a name='M000003'></a>
+ <div class='method public-class' id='method-M000002'>
+ <a name='M000002'></a>
<div class='synopsis'>
<span class='name'>last_bundle_commit_id</span>
<span class='arguments'>(bundle, type)</span>
</div>
<div class='description'>
@@ -355,14 +450,14 @@
which of its files were most recently modified in the repository. If no ID
can be found, `nil` is returned.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
[show source]
</a>
- <pre id='M000003-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>
+ <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>
</div>
</div>
<div class='method public-class' id='method-M000001'>
<a name='M000001'></a>
<div class='synopsis'>
@@ -390,12 +485,12 @@
[show source]
</a>
<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>
</div>
</div>
- <div class='method public-class' id='method-M000008'>
- <a name='M000008'></a>
+ <div class='method public-class' id='method-M000010'>
+ <a name='M000010'></a>
<div class='synopsis'>
<span class='name'>min_filepath</span>
<span class='arguments'>(filepath, extension)</span>
</div>
<div class='description'>
@@ -403,36 +498,55 @@
Returns the expected path for the minified version of an asset:
</p>
<pre>AssetHat.min_filepath('public/stylesheets/bundles/application.css', 'css')
 # => 'public/stylesheets/bundles/application.min.css'</pre>
<p>
See also <tt><a
- href="AssetHat/CSS.html#M000012">AssetHat::CSS.min_filepath</a></tt> and
- <tt><a href="AssetHat/JS.html#M000018">AssetHat::JS.min_filepath</a></tt>.
+ href="AssetHat/CSS.html#M000016">AssetHat::CSS.min_filepath</a></tt> and
+ <tt><a href="AssetHat/JS.html#M000022">AssetHat::JS.min_filepath</a></tt>.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
[show source]
</a>
- <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>
+ <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>
</div>
</div>
- <div class='method public-class' id='method-M000002'>
- <a name='M000002'></a>
+ <div class='method public-class' id='method-M000014'>
+ <a name='M000014'></a>
<div class='synopsis'>
+ <span class='name'>ssl_asset_host_differs?</span>
+ <span class='arguments'>()</span>
+ </div>
+ <div class='description'>
+ <p>
+ Returns <tt>true</tt> if the asset host differs between SSL and non-SSL
+ pages, or <tt>false</tt> if the asset host doesn’t change.
+ </p>
+ </div>
+ <div class='source'>
+ <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
+ [show source]
+ </a>
+ <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>
+ </div>
+ </div>
+ <div class='method public-class' id='method-M000004'>
+ <a name='M000004'></a>
+ <div class='synopsis'>
<span class='name'>version</span>
<span class='arguments'>()</span>
</div>
<div class='description'>
<p>
Returns this gem’s version number. See also VERSION.
</p>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
[show source]
</a>
- <pre id='M000002-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>
+ <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>
</div>
</div>
</div>
</div>
</div>