asset_hat 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/HISTORY +5 -0
- data/README.rdoc +2 -2
- data/VERSION.yml +2 -2
- data/asset_hat.gemspec +2 -2
- data/doc/classes/AssetHat/CSS/Engines.html +2 -2
- data/doc/classes/AssetHat/CSS.html +2 -2
- data/doc/classes/AssetHat/JS/Vendors.html +40 -4
- data/doc/classes/AssetHat.html +13 -12
- data/doc/created.rid +1 -1
- data/doc/files/HISTORY.html +13 -1
- data/doc/files/LICENSE.html +1 -1
- data/doc/files/README_rdoc.html +3 -3
- data/doc/files/app/helpers/asset_hat_helper_rb.html +1 -1
- data/doc/files/lib/asset_hat/capistrano_rb.html +1 -1
- data/doc/files/lib/asset_hat/css_rb.html +1 -1
- data/doc/files/lib/asset_hat/js/vendors_rb.html +1 -1
- data/doc/files/lib/asset_hat/js_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks/css_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks/js_rb.html +1 -1
- data/doc/files/lib/asset_hat/tasks_rb.html +1 -1
- data/doc/files/lib/asset_hat/vcs_rb.html +1 -1
- data/doc/files/lib/asset_hat/version_rb.html +1 -1
- data/doc/files/lib/asset_hat_rb.html +1 -1
- data/doc/fr_method_index.html +4 -4
- data/lib/asset_hat/css.rb +5 -2
- data/lib/asset_hat/js/vendors.rb +21 -2
- data/lib/asset_hat.rb +2 -2
- data/test/asset_hat_test.rb +2 -2
- metadata +3 -3
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
_site/
|
2
|
+
pkg/
|
data/HISTORY
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= HISTORY
|
2
2
|
|
3
|
+
== Version 0.2.1 (2010-07-21)
|
4
|
+
* Added WebFont Loader to supported JS vendors.
|
5
|
+
* Stopped adding asset hosts to `url(/htc/...)` URLs because IE 6, by default,
|
6
|
+
refuses to run .htc files from other domains, including CDN subdomains.
|
7
|
+
|
3
8
|
== Version 0.2.0 (2010-06-10)
|
4
9
|
* Added support for loading many more JS vendors from Google's CDN, including
|
5
10
|
Prototype, MooTools, and SWFObject.
|
data/README.rdoc
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
Your assets are covered.
|
4
4
|
|
5
5
|
With Rails' default asset caching, CSS and JS are concatenated (not even
|
6
|
-
minified)
|
7
|
-
can automatically:
|
6
|
+
minified) at runtime when that bundle is first requested. Not good enough.
|
7
|
+
AssetHat can automatically:
|
8
8
|
|
9
9
|
* Easily *minify* and *bundle* CSS and JS on deploy to reduce file sizes and
|
10
10
|
HTTP requests.
|
data/VERSION.yml
CHANGED
data/asset_hat.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{asset_hat}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ron DeVera", "Mint Digital"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-07-21}
|
13
13
|
s.description = %q{Minify, bundle, and optimize CSS/JS assets.}
|
14
14
|
s.email = %q{ronald.devera@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -81,7 +81,7 @@
|
|
81
81
|
<a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
|
82
82
|
[show source]
|
83
83
|
</a>
|
84
|
-
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line
|
84
|
+
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 108</span>
108: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cssmin</span>(<span class="ruby-identifier">input_string</span>)
109: <span class="ruby-constant">CSSMin</span>.<span class="ruby-identifier">minify</span>(<span class="ruby-identifier">input_string</span>)
110: <span class="ruby-keyword kw">end</span></pre>
|
85
85
|
</div>
|
86
86
|
</div>
|
87
87
|
<div class='method public-class' id='method-M000016'>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
<a class='source-toggle' href='#' onclick="toggleCode('M000016-source'); return false">
|
103
103
|
[show source]
|
104
104
|
</a>
|
105
|
-
<pre id='M000016-source'>
|
105
|
+
<pre id='M000016-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 86</span>
 86: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">weak</span>(<span class="ruby-identifier">input_string</span>)
 87: <span class="ruby-identifier">input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input_string</span>)
 88: <span class="ruby-identifier">output</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
 89: 
 90: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
 91: <span class="ruby-comment cmt"># Remove indentation and trailing whitespace (including line breaks)</span>
 92: <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip!</span>
 93: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">blank?</span>
 94: 
 95: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">line</span>
 96: <span class="ruby-keyword kw">end</span>
 97: 
 98: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">rewind</span>
 99: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">read</span>
100: <span class="ruby-keyword kw">end</span></pre>
|
106
106
|
</div>
|
107
107
|
</div>
|
108
108
|
</div>
|
@@ -121,7 +121,7 @@
|
|
121
121
|
</li>
|
122
122
|
</ul>
|
123
123
|
<p>
|
124
|
-
An asset host is added to every
|
124
|
+
An asset host is added to every image URL in the <a
|
125
125
|
href="CSS.html">CSS</a>, e.g., <tt>background:
|
126
126
|
url(http://assets2.example.com/images/foo.png)</tt>; if <tt>%d</tt> in the
|
127
127
|
asset host, it is replaced with an arbitrary number in 0-3, inclusive.
|
@@ -131,7 +131,7 @@
|
|
131
131
|
<a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
|
132
132
|
[show source]
|
133
133
|
</a>
|
134
|
-
<pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 70</span>
70: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add_asset_hosts</span>(<span class="ruby-identifier">css</span>, <span class="ruby-identifier">asset_host</span>)
71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">asset_host</span>.<span class="ruby-identifier">blank?</span>
72: <span class="ruby-identifier">css</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/url[\s]*\((\/
|
134
|
+
<pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 70</span>
70: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add_asset_hosts</span>(<span class="ruby-identifier">css</span>, <span class="ruby-identifier">asset_host</span>)
71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">asset_host</span>.<span class="ruby-identifier">blank?</span>
72: <span class="ruby-identifier">css</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/url[\s]*\((\/images\/[^)]+)\)/</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>
73: <span class="ruby-comment cmt"># N.B.: The `/htc/` directory is excluded because IE 6, by default,</span>
74: <span class="ruby-comment cmt"># refuses to run .htc files (e.g., TwinHelix's iepngfix.htc) from</span>
75: <span class="ruby-comment cmt"># other domains, including CDN subdomains.</span>
76: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">$1</span>
77: <span class="ruby-node">"url(#{(asset_host =~ /%d/) ? asset_host % (src.hash % 4) : asset_host}#{src})"</span>
78: <span class="ruby-keyword kw">end</span>
79: <span class="ruby-keyword kw">end</span></pre>
|
135
135
|
</div>
|
136
136
|
</div>
|
137
137
|
<div class='method public-class' id='method-M000012'>
|
@@ -58,11 +58,46 @@
|
|
58
58
|
<tr class='top-aligned-row context-row'>
|
59
59
|
<td class='context-item-name'>VENDORS</td>
|
60
60
|
<td>=</td>
|
61
|
-
<td class='context-item-value'>[ :jquery, :jquery_ui, :prototype, :scriptaculous, :mootools, :dojo, :swfobject, :yui, :ext_core ]</td>
|
61
|
+
<td class='context-item-value'>[ :jquery, :jquery_ui, :prototype, :scriptaculous, :mootools, :dojo, :swfobject, :yui, :ext_core, :webfont ]</td>
|
62
62
|
<td> </td>
|
63
63
|
<td class='context-item-desc'>
|
64
64
|
|
65
|
-
A list of supported 3rd-party JavaScript plugin/vendor names.
|
65
|
+
A list of supported 3rd-party JavaScript plugin/vendor names. Homepages:
|
66
|
+
|
67
|
+
<ul>
|
68
|
+
<li><a href="http://jquery.com/">jQuery</a>
|
69
|
+
|
70
|
+
</li>
|
71
|
+
<li><a href="http://jqueryui.com/">jQuery UI</a>
|
72
|
+
|
73
|
+
</li>
|
74
|
+
<li><a href="http://www.prototypejs.org/">Prototype</a>
|
75
|
+
|
76
|
+
</li>
|
77
|
+
<li><a href="http://script.aculo.us/">script.aculo.us</a>
|
78
|
+
|
79
|
+
</li>
|
80
|
+
<li><a href="http://mootools.net/">MooTools</a>
|
81
|
+
|
82
|
+
</li>
|
83
|
+
<li><a href="http://dojotoolkit.org/">Dojo</a>
|
84
|
+
|
85
|
+
</li>
|
86
|
+
<li><a href="http://code.google.com/p/swfobject/">SWFObject</a>
|
87
|
+
|
88
|
+
</li>
|
89
|
+
<li><a href="http://developer.yahoo.com/yui/">YUI</a>
|
90
|
+
|
91
|
+
</li>
|
92
|
+
<li><a href="http://extjs.com/products/extcore/">Ext Core</a>
|
93
|
+
|
94
|
+
</li>
|
95
|
+
<li><a
|
96
|
+
href="http://code.google.com/apis/webfonts/docs/webfont_loader.html">WebFont
|
97
|
+
Loader</a>
|
98
|
+
|
99
|
+
</li>
|
100
|
+
</ul>
|
66
101
|
</td>
|
67
102
|
</tr>
|
68
103
|
</table>
|
@@ -80,7 +115,8 @@
|
|
80
115
|
<p>
|
81
116
|
Accepts an item from VENDORS, and returns the URL at which that vendor
|
82
117
|
asset can be found. The URL is either local (relative) or external
|
83
|
-
depending on the environment configuration.
|
118
|
+
depending on the environment configuration. If external, the URL points to
|
119
|
+
<a href="http://code.google.com/apis/ajaxlibs/">Google's CDN</a>. Options:
|
84
120
|
</p>
|
85
121
|
<dl>
|
86
122
|
<dt>version</dt><dd>The vendor version, e.g., ‘1.4.0’ for jQuery 1.4. By default,
|
@@ -94,7 +130,7 @@
|
|
94
130
|
<a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
|
95
131
|
[show source]
|
96
132
|
</a>
|
97
|
-
<pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js/vendors.rb, line
|
133
|
+
<pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js/vendors.rb, line 40</span>
40: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">source_for</span>(<span class="ruby-identifier">vendor</span>, <span class="ruby-identifier">options</span>={})
41: <span class="ruby-identifier">vendor_config</span> =
42: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">config</span>[<span class="ruby-value str">'js'</span>][<span class="ruby-value str">'vendors'</span>][<span class="ruby-identifier">vendor</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
43: <span class="ruby-identifier">use_local</span> = <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">consider_all_requests_local</span>
44: <span class="ruby-identifier">version</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:version</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">vendor_config</span>[<span class="ruby-value str">'version'</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
45: 
46: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">use_local</span>
47: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">vendor_config</span>[<span class="ruby-value str">'remote_url'</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
48: <span class="ruby-keyword kw">end</span>
49: 
50: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">src</span>.<span class="ruby-identifier">blank?</span>
51: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">vendor</span>
52: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:jquery</span>
53: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
54: </span> <span class="ruby-node">"#{['jquery', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
55: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js"</span>
56: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:jquery_ui</span>
57: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
58: </span> <span class="ruby-node">"#{['jquery-ui', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
59: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/jqueryui/#{version}/jquery-ui.min.js"</span>
60: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:prototype</span>
61: <span class="ruby-comment cmt"># Prototype currently doesn't provide an official minified version.</span>
62: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
63: </span> <span class="ruby-node">"#{['prototype', version].compact.join('-')}.js"</span> <span class="ruby-operator">:</span>
64: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/prototype/#{version}/prototype.js"</span>
65: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:scriptaculous</span>
66: <span class="ruby-comment cmt"># script.aculo.us currently doesn't provide an official minified version.</span>
67: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
68: </span> <span class="ruby-node">"#{['scriptaculous', version].compact.join('-')}.js"</span> <span class="ruby-operator">:</span>
69: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/scriptaculous/#{version}/scriptaculous.js"</span>
70: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:mootools</span>
71: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
72: </span> <span class="ruby-node">"#{['mootools', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
73: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/mootools/#{version}/mootools-yui-compressed.js"</span>
74: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:dojo</span>
75: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
76: </span> <span class="ruby-node">"#{['dojo', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
77: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/dojo/#{version}/dojo/dojo.xd.js"</span>
78: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:swfobject</span>
79: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
80: </span> <span class="ruby-node">"#{['swfobject', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
81: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/swfobject/#{version}/swfobject.js"</span>
82: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:yui</span>
83: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
84: </span> <span class="ruby-node">"#{['yui', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
85: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/yui/#{version}/build/yuiloader/yuiloader-min.js"</span>
86: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:ext_core</span>
87: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
88: </span> <span class="ruby-node">"#{['ext_core', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
89: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/ext-core/#{version}/ext-core.js"</span>
90: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:webfont</span>
91: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">use_local</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">?
92: </span> <span class="ruby-node">"#{['webfont', version].compact.join('-')}.min.js"</span> <span class="ruby-operator">:</span>
93: <span class="ruby-node">"http://ajax.googleapis.com/ajax/libs/webfont/#{version}/webfont.js"</span>
94: <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># TODO: Write to log</span>
95: <span class="ruby-keyword kw">end</span>
96: <span class="ruby-keyword kw">end</span>
97: 
98: <span class="ruby-identifier">src</span>
99: <span class="ruby-keyword kw">end</span></pre>
|
98
134
|
</div>
|
99
135
|
</div>
|
100
136
|
</div>
|
data/doc/classes/AssetHat.html
CHANGED
@@ -62,8 +62,9 @@
|
|
62
62
|
<p>
|
63
63
|
With Rails’ default asset caching, <a
|
64
64
|
href="AssetHat/CSS.html">CSS</a> and <a href="AssetHat/JS.html">JS</a> are
|
65
|
-
concatenated (not even minified)
|
66
|
-
Not good enough. <a href="AssetHat.html">AssetHat</a> can
|
65
|
+
concatenated (not even minified) at runtime when that bundle is first
|
66
|
+
requested. Not good enough. <a href="AssetHat.html">AssetHat</a> can
|
67
|
+
automatically:
|
67
68
|
</p>
|
68
69
|
<ul>
|
69
70
|
<li>Easily <b>minify</b> and <b>bundle</b> <a href="AssetHat/CSS.html">CSS</a>
|
@@ -109,10 +110,10 @@
|
|
109
110
|
<li><a href="#M000007">cache?</a></li>
|
110
111
|
<li><a href="#M000011">clear_html_cache</a></li>
|
111
112
|
<li><a href="#M000004">config</a></li>
|
112
|
-
<li><a href="#
|
113
|
+
<li><a href="#M000003">last_bundle_commit_id</a></li>
|
113
114
|
<li><a href="#M000001">last_commit_id</a></li>
|
114
115
|
<li><a href="#M000008">min_filepath</a></li>
|
115
|
-
<li><a href="#
|
116
|
+
<li><a href="#M000002">version</a></li>
|
116
117
|
</ol>
|
117
118
|
</div>
|
118
119
|
<div id='section'>
|
@@ -338,8 +339,8 @@
|
|
338
339
|
<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
340
|
</div>
|
340
341
|
</div>
|
341
|
-
<div class='method public-class' id='method-
|
342
|
-
<a name='
|
342
|
+
<div class='method public-class' id='method-M000003'>
|
343
|
+
<a name='M000003'></a>
|
343
344
|
<div class='synopsis'>
|
344
345
|
<span class='name'>last_bundle_commit_id</span>
|
345
346
|
<span class='arguments'>(bundle, type)</span>
|
@@ -356,10 +357,10 @@
|
|
356
357
|
</p>
|
357
358
|
</div>
|
358
359
|
<div class='source'>
|
359
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
360
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
|
360
361
|
[show source]
|
361
362
|
</a>
|
362
|
-
<pre id='
|
363
|
+
<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>
|
363
364
|
</div>
|
364
365
|
</div>
|
365
366
|
<div class='method public-class' id='method-M000001'>
|
@@ -415,8 +416,8 @@
|
|
415
416
|
<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
417
|
</div>
|
417
418
|
</div>
|
418
|
-
<div class='method public-class' id='method-
|
419
|
-
<a name='
|
419
|
+
<div class='method public-class' id='method-M000002'>
|
420
|
+
<a name='M000002'></a>
|
420
421
|
<div class='synopsis'>
|
421
422
|
<span class='name'>version</span>
|
422
423
|
<span class='arguments'>()</span>
|
@@ -427,10 +428,10 @@
|
|
427
428
|
</p>
|
428
429
|
</div>
|
429
430
|
<div class='source'>
|
430
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
431
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
|
431
432
|
[show source]
|
432
433
|
</a>
|
433
|
-
<pre id='
|
434
|
+
<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>
|
434
435
|
</div>
|
435
436
|
</div>
|
436
437
|
</div>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Wed, 21 Jul 2010 11:52:26 -0400
|
data/doc/files/HISTORY.html
CHANGED
@@ -31,13 +31,25 @@
|
|
31
31
|
</div>
|
32
32
|
<div class='last-update'>
|
33
33
|
Last Update:
|
34
|
-
<span class='datetime'>
|
34
|
+
<span class='datetime'>Wed Jul 21 11:51:58 -0400 2010</span>
|
35
35
|
</div>
|
36
36
|
</div>
|
37
37
|
<div id='content'>
|
38
38
|
<div id='text'>
|
39
39
|
<div id='description'>
|
40
40
|
<h1><a href="HISTORY.html">HISTORY</a></h1>
|
41
|
+
<h2>Version 0.2.1 (2010-07-21)</h2>
|
42
|
+
<ul>
|
43
|
+
<li>Added WebFont Loader to supported JS vendors.
|
44
|
+
|
45
|
+
</li>
|
46
|
+
<li>Stopped adding asset hosts to `url(/htc/...)` URLs because IE 6, by
|
47
|
+
default, refuses to run .htc files from other domains, including CDN
|
48
|
+
subdomains.
|
49
|
+
|
50
|
+
</li>
|
51
|
+
</ul>
|
52
|
+
<h2>Version 0.2.0 (2010-06-10)</h2>
|
41
53
|
<ul>
|
42
54
|
<li>Added support for loading many more JS vendors from Google’s CDN,
|
43
55
|
including Prototype, MooTools, and SWFObject.
|
data/doc/files/LICENSE.html
CHANGED
data/doc/files/README_rdoc.html
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
</div>
|
32
32
|
<div class='last-update'>
|
33
33
|
Last Update:
|
34
|
-
<span class='datetime'>
|
34
|
+
<span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
|
35
35
|
</div>
|
36
36
|
</div>
|
37
37
|
<div id='content'>
|
@@ -43,8 +43,8 @@
|
|
43
43
|
</p>
|
44
44
|
<p>
|
45
45
|
With Rails’ default asset caching, CSS and JS are concatenated (not
|
46
|
-
even minified)
|
47
|
-
href="../classes/AssetHat.html">AssetHat</a> can automatically:
|
46
|
+
even minified) at runtime when that bundle is first requested. Not good
|
47
|
+
enough. <a href="../classes/AssetHat.html">AssetHat</a> can automatically:
|
48
48
|
</p>
|
49
49
|
<ul>
|
50
50
|
<li>Easily <b>minify</b> and <b>bundle</b> CSS and JS on deploy to reduce file
|
data/doc/fr_method_index.html
CHANGED
@@ -4344,7 +4344,7 @@
|
|
4344
4344
|
{ method: 'include_css', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000023"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a>' },
|
4345
4345
|
{ method: 'include_js', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000024"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a>' },
|
4346
4346
|
{ method: 'jsmin', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000022"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
|
4347
|
-
{ method: 'last_bundle_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#
|
4347
|
+
{ method: 'last_bundle_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#M000003"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a>' },
|
4348
4348
|
{ method: 'last_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#M000001"><span class="method_name">last_commit_id</span> <span class="module_name">(AssetHat)</span></a>' },
|
4349
4349
|
{ method: 'min_filepath', module: 'assethat', html: '<a href="classes/AssetHat.html#M000008"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a>' },
|
4350
4350
|
{ method: 'min_filepath', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000012"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
|
@@ -4352,7 +4352,7 @@
|
|
4352
4352
|
{ method: 'minify', module: 'assethat::js', html: '<a href="classes/AssetHat/JS.html#M000019"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a>' },
|
4353
4353
|
{ method: 'minify', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000013"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
|
4354
4354
|
{ method: 'source_for', module: 'assethat::js::vendors', html: '<a href="classes/AssetHat/JS/Vendors.html#M000020"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a>' },
|
4355
|
-
{ method: 'version', module: 'assethat', html: '<a href="classes/AssetHat.html#
|
4355
|
+
{ method: 'version', module: 'assethat', html: '<a href="classes/AssetHat.html#M000002"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a>' },
|
4356
4356
|
{ method: 'weak', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000021"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
|
4357
4357
|
{ method: 'weak', module: 'assethat::css::engines', html: '<a href="classes/AssetHat/CSS/Engines.html#M000016"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a>' },
|
4358
4358
|
]
|
@@ -4438,7 +4438,7 @@
|
|
4438
4438
|
<li><a href="classes/AssetHatHelper.html#M000023"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a></li>
|
4439
4439
|
<li><a href="classes/AssetHatHelper.html#M000024"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a></li>
|
4440
4440
|
<li><a href="classes/AssetHat/JS/Engines.html#M000022"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
|
4441
|
-
<li><a href="classes/AssetHat.html#
|
4441
|
+
<li><a href="classes/AssetHat.html#M000003"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a></li>
|
4442
4442
|
<li><a href="classes/AssetHat.html#M000001"><span class="method_name">last_commit_id</span> <span class="module_name">(AssetHat)</span></a></li>
|
4443
4443
|
<li><a href="classes/AssetHat.html#M000008"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a></li>
|
4444
4444
|
<li><a href="classes/AssetHat/CSS.html#M000012"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
|
@@ -4446,7 +4446,7 @@
|
|
4446
4446
|
<li><a href="classes/AssetHat/JS.html#M000019"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a></li>
|
4447
4447
|
<li><a href="classes/AssetHat/CSS.html#M000013"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
|
4448
4448
|
<li><a href="classes/AssetHat/JS/Vendors.html#M000020"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a></li>
|
4449
|
-
<li><a href="classes/AssetHat.html#
|
4449
|
+
<li><a href="classes/AssetHat.html#M000002"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a></li>
|
4450
4450
|
<li><a href="classes/AssetHat/JS/Engines.html#M000021"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
|
4451
4451
|
<li><a href="classes/AssetHat/CSS/Engines.html#M000016"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a></li>
|
4452
4452
|
</ol>
|
data/lib/asset_hat/css.rb
CHANGED
@@ -63,13 +63,16 @@ module AssetHat
|
|
63
63
|
# <code>config.action_controller.asset_host</code> in
|
64
64
|
# the app's <code>config/environments/production.rb</code>.
|
65
65
|
#
|
66
|
-
# An asset host is added to every
|
66
|
+
# An asset host is added to every image URL in the CSS, e.g.,
|
67
67
|
# <code>background: url(http\://assets2.example.com/images/foo.png)</code>;
|
68
68
|
# if <code>%d</code> in the asset host, it is replaced with an arbitrary
|
69
69
|
# number in 0-3, inclusive.
|
70
70
|
def self.add_asset_hosts(css, asset_host)
|
71
71
|
return if asset_host.blank?
|
72
|
-
css.gsub(/url[\s]*\((\/
|
72
|
+
css.gsub(/url[\s]*\((\/images\/[^)]+)\)/) do |match|
|
73
|
+
# N.B.: The `/htc/` directory is excluded because IE 6, by default,
|
74
|
+
# refuses to run .htc files (e.g., TwinHelix's iepngfix.htc) from
|
75
|
+
# other domains, including CDN subdomains.
|
73
76
|
src = $1
|
74
77
|
"url(#{(asset_host =~ /%d/) ? asset_host % (src.hash % 4) : asset_host}#{src})"
|
75
78
|
end
|
data/lib/asset_hat/js/vendors.rb
CHANGED
@@ -4,6 +4,18 @@ module AssetHat
|
|
4
4
|
# plugin/framework/library vendors.
|
5
5
|
module Vendors
|
6
6
|
# A list of supported 3rd-party JavaScript plugin/vendor names.
|
7
|
+
# Homepages:
|
8
|
+
#
|
9
|
+
# * {jQuery}[http://jquery.com/]
|
10
|
+
# * {jQuery UI}[http://jqueryui.com/]
|
11
|
+
# * {Prototype}[http://www.prototypejs.org/]
|
12
|
+
# * {script.aculo.us}[http://script.aculo.us/]
|
13
|
+
# * {MooTools}[http://mootools.net/]
|
14
|
+
# * {Dojo}[http://dojotoolkit.org/]
|
15
|
+
# * {SWFObject}[http://code.google.com/p/swfobject/]
|
16
|
+
# * {YUI}[http://developer.yahoo.com/yui/]
|
17
|
+
# * {Ext Core}[http://extjs.com/products/extcore/]
|
18
|
+
# * {WebFont Loader}[http://code.google.com/apis/webfonts/docs/webfont_loader.html]
|
7
19
|
VENDORS = [
|
8
20
|
:jquery, :jquery_ui,
|
9
21
|
:prototype, :scriptaculous,
|
@@ -11,12 +23,15 @@ module AssetHat
|
|
11
23
|
:dojo,
|
12
24
|
:swfobject,
|
13
25
|
:yui,
|
14
|
-
:ext_core
|
26
|
+
:ext_core,
|
27
|
+
:webfont
|
15
28
|
]
|
16
29
|
|
17
30
|
# Accepts an item from VENDORS, and returns the URL at which that vendor
|
18
31
|
# asset can be found. The URL is either local (relative) or external
|
19
|
-
# depending on the environment configuration.
|
32
|
+
# depending on the environment configuration. If external, the URL
|
33
|
+
# points to {Google's CDN}[http://code.google.com/apis/ajaxlibs/].
|
34
|
+
# Options:
|
20
35
|
#
|
21
36
|
# [version] The vendor version, e.g., '1.4.0' for jQuery 1.4. By
|
22
37
|
# default, each vendor version is taken from
|
@@ -72,6 +87,10 @@ module AssetHat
|
|
72
87
|
src = use_local || version.blank? ?
|
73
88
|
"#{['ext_core', version].compact.join('-')}.min.js" :
|
74
89
|
"http://ajax.googleapis.com/ajax/libs/ext-core/#{version}/ext-core.js"
|
90
|
+
when :webfont
|
91
|
+
src = use_local || version.blank? ?
|
92
|
+
"#{['webfont', version].compact.join('-')}.min.js" :
|
93
|
+
"http://ajax.googleapis.com/ajax/libs/webfont/#{version}/webfont.js"
|
75
94
|
else nil # TODO: Write to log
|
76
95
|
end
|
77
96
|
end
|
data/lib/asset_hat.rb
CHANGED
@@ -5,8 +5,8 @@ end
|
|
5
5
|
# Your assets are covered.
|
6
6
|
#
|
7
7
|
# With Rails' default asset caching, CSS and JS are concatenated (not even
|
8
|
-
# minified)
|
9
|
-
# can automatically:
|
8
|
+
# minified) at runtime when that bundle is first requested. Not good enough.
|
9
|
+
# AssetHat can automatically:
|
10
10
|
#
|
11
11
|
# * Easily *minify* and *bundle* CSS and JS on deploy to reduce file sizes and
|
12
12
|
# HTTP requests.
|
data/test/asset_hat_test.rb
CHANGED
@@ -62,10 +62,10 @@ class AssetHatTest < ActiveSupport::TestCase
|
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
|
-
should 'add .htc asset hosts' do
|
65
|
+
should 'not add .htc asset hosts' do
|
66
66
|
asset_host = 'http://media%d.example.com'
|
67
67
|
assert_match(
|
68
|
-
/^p\{background:url\(
|
68
|
+
/^p\{background:url\(\/htc\/iepngfix.htc\)\}$/,
|
69
69
|
AssetHat::CSS.add_asset_hosts(
|
70
70
|
'p{background:url(/htc/iepngfix.htc)}', asset_host)
|
71
71
|
)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ron DeVera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-21 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|