asset_hat 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/HISTORY +13 -14
  2. data/README.rdoc +171 -0
  3. data/Rakefile +24 -2
  4. data/VERSION.yml +3 -3
  5. data/app/helpers/asset_hat_helper.rb +67 -61
  6. data/asset_hat.gemspec +42 -8
  7. data/doc/classes/AssetHat/CSS/Engines.html +118 -0
  8. data/doc/classes/AssetHat/CSS.html +194 -0
  9. data/doc/classes/AssetHat/JS/Engines.html +122 -0
  10. data/doc/classes/AssetHat/JS/Vendors.html +110 -0
  11. data/doc/classes/AssetHat/JS.html +151 -0
  12. data/doc/classes/AssetHat.html +446 -0
  13. data/doc/classes/AssetHatHelper.html +161 -0
  14. data/doc/created.rid +1 -0
  15. data/doc/files/HISTORY.html +116 -0
  16. data/doc/files/LICENSE.html +76 -0
  17. data/doc/files/README_rdoc.html +234 -0
  18. data/doc/files/app/helpers/asset_hat_helper_rb.html +55 -0
  19. data/doc/files/lib/asset_hat/capistrano_rb.html +49 -0
  20. data/doc/files/lib/asset_hat/css_rb.html +57 -0
  21. data/doc/files/lib/asset_hat/js/vendors_rb.html +49 -0
  22. data/doc/files/lib/asset_hat/js_rb.html +57 -0
  23. data/doc/files/lib/asset_hat/tasks/css_rb.html +49 -0
  24. data/doc/files/lib/asset_hat/tasks/js_rb.html +49 -0
  25. data/doc/files/lib/asset_hat/tasks_rb.html +58 -0
  26. data/doc/files/lib/asset_hat/vcs_rb.html +49 -0
  27. data/doc/files/lib/asset_hat/version_rb.html +49 -0
  28. data/doc/files/lib/asset_hat_rb.html +49 -0
  29. data/doc/fr_class_index.html +23 -0
  30. data/doc/fr_file_index.html +33 -0
  31. data/doc/fr_method_index.html +4455 -0
  32. data/doc/index.html +15 -0
  33. data/doc/rdoc-style.css +328 -0
  34. data/lib/asset_hat/capistrano.rb +14 -0
  35. data/lib/asset_hat/css.rb +40 -10
  36. data/lib/asset_hat/js/vendors.rb +85 -0
  37. data/lib/asset_hat/js.rb +28 -29
  38. data/lib/asset_hat/tasks/css.rb +151 -0
  39. data/lib/asset_hat/tasks/js.rb +100 -0
  40. data/lib/asset_hat/tasks.rb +4 -272
  41. data/lib/asset_hat/vcs.rb +23 -20
  42. data/lib/asset_hat/version.rb +2 -0
  43. data/lib/asset_hat.rb +94 -19
  44. data/tasks/asset_hat.rake +1 -1
  45. data/test/asset_hat_helper_test.rb +63 -9
  46. data/test/test_helper.rb +5 -1
  47. metadata +94 -26
  48. data/README.markdown +0 -154
@@ -0,0 +1,194 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>: AssetHat::CSS [AssetHat]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ AssetHat::CSS
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../files/lib/asset_hat/css_rb.html">lib/asset_hat/css.rb</a>
35
+ </li>
36
+ </ol>
37
+ </div>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <p>
42
+ Methods for minifying and optimizing <a href="CSS.html">CSS</a>.
43
+ </p>
44
+ </div>
45
+ <div id='method-list'>
46
+ <h2>Methods</h2>
47
+ <h3>public class</h3>
48
+ <ol>
49
+ <li><a href="#M000014">add_asset_commit_ids</a></li>
50
+ <li><a href="#M000015">add_asset_hosts</a></li>
51
+ <li><a href="#M000012">min_filepath</a></li>
52
+ <li><a href="#M000013">minify</a></li>
53
+ </ol>
54
+ </div>
55
+ <div id='section'>
56
+ <div id='class-list'>
57
+ <h2>Classes and Modules</h2>
58
+ Module <a href="CSS/Engines.html" class="link">AssetHat::CSS::Engines</a><br />
59
+ </div>
60
+ <div id='constants-list'>
61
+ <h2>Constants</h2>
62
+ <div class='name-list'>
63
+ <table summary='Constants'>
64
+ <tr class='top-aligned-row context-row'>
65
+ <td class='context-item-name'>ENGINES</td>
66
+ <td>=</td>
67
+ <td class='context-item-value'>[:weak, :cssmin]</td>
68
+ <td>&nbsp;</td>
69
+ <td class='context-item-desc'>
70
+
71
+ A list of supported minification <a href=CSS/Engines.html>engine</a> names.
72
+ </td>
73
+ </tr>
74
+ </table>
75
+ </div>
76
+ </div>
77
+ <div id='methods'>
78
+ <h2>Public class methods</h2>
79
+ <div class='method public-class' id='method-M000014'>
80
+ <a name='M000014'></a>
81
+ <div class='synopsis'>
82
+ <span class='name'>add_asset_commit_ids</span>
83
+ <span class='arguments'>(css)</span>
84
+ </div>
85
+ <div class='description'>
86
+ <p>
87
+ Given a string containing <a href="CSS.html">CSS</a>, appends each
88
+ referenced asset&#8217;s last commit ID to its URL, e.g., <tt>background:
89
+ url(/images/foo.png?ab12cd34e)</tt>. This enables cache busting: If the
90
+ user&#8217;s browser has cached a copy of foo.png from a previous
91
+ deployment, this new URL forces the browser to ignore that cache and
92
+ request the latest version.
93
+ </p>
94
+ </div>
95
+ <div class='source'>
96
+ <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
97
+ [show source]
98
+ </a>
99
+ <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 43</span>&#x000A;43: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add_asset_commit_ids</span>(<span class="ruby-identifier">css</span>)&#x000A;44: <span class="ruby-identifier">css</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/url[\s]*\((\/(images|htc)\/[^)]+)\)/</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>&#x000A;45: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">$1</span>&#x000A;46: &#x000A;47: <span class="ruby-comment cmt"># Get absolute path</span>&#x000A;48: <span class="ruby-identifier">filepath</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">ASSETS_DIR</span>, <span class="ruby-identifier">src</span>)&#x000A;49: &#x000A;50: <span class="ruby-comment cmt"># Convert to relative path</span>&#x000A;51: <span class="ruby-identifier">filepath</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-node">/^#{FileUtils.pwd}#{File::SEPARATOR}/</span>, <span class="ruby-value str">''</span>)&#x000A;52: &#x000A;53: <span class="ruby-identifier">commit_id</span> = <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">last_commit_id</span>(<span class="ruby-identifier">filepath</span>)&#x000A;54: <span class="ruby-identifier">commit_id</span>.<span class="ruby-identifier">present?</span> <span class="ruby-value">? </span><span class="ruby-node">&quot;url(#{src}?#{commit_id})&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;url(#{src})&quot;</span>&#x000A;55: <span class="ruby-keyword kw">end</span>&#x000A;56: <span class="ruby-keyword kw">end</span></pre>
100
+ </div>
101
+ </div>
102
+ <div class='method public-class' id='method-M000015'>
103
+ <a name='M000015'></a>
104
+ <div class='synopsis'>
105
+ <span class='name'>add_asset_hosts</span>
106
+ <span class='arguments'>(css, asset_host)</span>
107
+ </div>
108
+ <div class='description'>
109
+ <p>
110
+ Arguments:
111
+ </p>
112
+ <ul>
113
+ <li>A string containing <a href="CSS.html">CSS</a>;
114
+
115
+ </li>
116
+ <li>A string containing the app&#8217;s asset host, e.g.,
117
+ &#8216;http://assets%d.example.com&#8217;. This value is typically taken
118
+ from <tt>config.action_controller.asset_host</tt> in the app&#8217;s
119
+ <tt>config/environments/production.rb</tt>.
120
+
121
+ </li>
122
+ </ul>
123
+ <p>
124
+ An asset host is added to every asset URL in the <a
125
+ href="CSS.html">CSS</a>, e.g., <tt>background:
126
+ url(http://assets2.example.com/images/foo.png)</tt>; if <tt>%d</tt> in the
127
+ asset host, it is replaced with an arbitrary number in 0-3, inclusive.
128
+ </p>
129
+ </div>
130
+ <div class='source'>
131
+ <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
132
+ [show source]
133
+ </a>
134
+ <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 70</span>&#x000A;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>)&#x000A;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>&#x000A;72: <span class="ruby-identifier">css</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/url[\s]*\((\/(images|htc)\/[^)]+)\)/</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>&#x000A;73: <span class="ruby-identifier">src</span> = <span class="ruby-identifier">$1</span>&#x000A;74: <span class="ruby-node">&quot;url(#{(asset_host =~ /%d/) ? asset_host % (src.hash % 4) : asset_host}#{src})&quot;</span>&#x000A;75: <span class="ruby-keyword kw">end</span>&#x000A;76: <span class="ruby-keyword kw">end</span></pre>
135
+ </div>
136
+ </div>
137
+ <div class='method public-class' id='method-M000012'>
138
+ <a name='M000012'></a>
139
+ <div class='synopsis'>
140
+ <span class='name'>min_filepath</span>
141
+ <span class='arguments'>(filepath)</span>
142
+ </div>
143
+ <div class='description'>
144
+ <p>
145
+ Returns the expected path for the minified version of a <a
146
+ href="CSS.html">CSS</a> asset:
147
+ </p>
148
+ <pre>AssetHat::CSS.min_filepath('public/stylesheets/bundles/application.css')&#x000A; # =&gt; 'public/stylesheets/bundles/application.min.css'</pre>
149
+ </div>
150
+ <div class='source'>
151
+ <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
152
+ [show source]
153
+ </a>
154
+ <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 14</span>&#x000A;14: <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>)&#x000A;15: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">min_filepath</span>(<span class="ruby-identifier">filepath</span>, <span class="ruby-value str">'css'</span>)&#x000A;16: <span class="ruby-keyword kw">end</span></pre>
155
+ </div>
156
+ </div>
157
+ <div class='method public-class' id='method-M000013'>
158
+ <a name='M000013'></a>
159
+ <div class='synopsis'>
160
+ <span class='name'>minify</span>
161
+ <span class='arguments'>(input_string, options={})</span>
162
+ </div>
163
+ <div class='description'>
164
+ <p>
165
+ Accepts a string of <a href="CSS.html">CSS</a>, and returns that <a
166
+ href="CSS.html">CSS</a> minified. Options:
167
+ </p>
168
+ <dl>
169
+ <dt>engine</dt><dd>Default is <tt>:cssmin</tt>; see <a
170
+ href=CSS/Engines.html#method-c-cssmin><a
171
+ href="CSS/Engines.html#M000017">Engines.cssmin</a></a>. Allowed values are
172
+ in ENGINES.
173
+
174
+ </dd>
175
+ </dl>
176
+ </div>
177
+ <div class='source'>
178
+ <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
179
+ [show source]
180
+ </a>
181
+ <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 23</span>&#x000A;23: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minify</span>(<span class="ruby-identifier">input_string</span>, <span class="ruby-identifier">options</span>={})&#x000A;24: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:engine</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:cssmin</span>)&#x000A;25: &#x000A;26: <span class="ruby-identifier">engine</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:engine</span>].<span class="ruby-identifier">to_sym</span>&#x000A;27: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ENGINES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">engine</span>)&#x000A;28: <span class="ruby-identifier">raise</span> <span class="ruby-node">%Q{&#x000A;29: Unknown CSS minification engine '#{engine}'.&#x000A;30: Allowed: #{ENGINES.map{ |e| &quot;'#{e}'&quot; }.join(', ')}&#x000A;31: }</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s+/</span>, <span class="ruby-value str">' '</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span>&#x000A;32: <span class="ruby-keyword kw">end</span>&#x000A;33: &#x000A;34: <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">CSS</span><span class="ruby-operator">::</span><span class="ruby-constant">Engines</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">engine</span>, <span class="ruby-identifier">input_string</span>)&#x000A;35: <span class="ruby-keyword kw">end</span></pre>
182
+ </div>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ </div>
187
+ </div>
188
+ <div id='footer-push'></div>
189
+ </div>
190
+ <div id='footer'>
191
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
192
+ </div>
193
+ </body>
194
+ </html>
@@ -0,0 +1,122 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>: AssetHat::JS::Engines [AssetHat]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ AssetHat::JS::Engines
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../../files/lib/asset_hat/js_rb.html">lib/asset_hat/js.rb</a>
35
+ </li>
36
+ </ol>
37
+ </div>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <p>
42
+ Swappable JavaScript minification engines.
43
+ </p>
44
+ </div>
45
+ <div id='method-list'>
46
+ <h2>Methods</h2>
47
+ <h3>public class</h3>
48
+ <ol>
49
+ <li><a href="#M000022">jsmin</a></li>
50
+ <li><a href="#M000021">weak</a></li>
51
+ </ol>
52
+ </div>
53
+ <div id='section'>
54
+ <div id='methods'>
55
+ <h2>Public class methods</h2>
56
+ <div class='method public-class' id='method-M000022'>
57
+ <a name='M000022'></a>
58
+ <div class='synopsis'>
59
+ <span class='name'>jsmin</span>
60
+ <span class='arguments'>(input_string)</span>
61
+ </div>
62
+ <div class='description'>
63
+ <p>
64
+ JavaScript minification engine that simply uses the JSMin gem, a Ruby port
65
+ of Crockford&#8217;s JSMin.
66
+ </p>
67
+ <p>
68
+ Sources:
69
+ </p>
70
+ <ul>
71
+ <li><a href="http://github.com/rgrove/jsmin">github.com/rgrove/jsmin</a>
72
+
73
+ </li>
74
+ <li><a href="http://rubygems.org/gems/jsmin">rubygems.org/gems/jsmin</a>
75
+
76
+ </li>
77
+ </ul>
78
+ </div>
79
+ <div class='source'>
80
+ <a class='source-toggle' href='#' onclick="toggleCode('M000022-source'); return false">
81
+ [show source]
82
+ </a>
83
+ <pre id='M000022-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js.rb, line 79</span>&#x000A;79: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">jsmin</span>(<span class="ruby-identifier">input_string</span>)&#x000A;80: <span class="ruby-constant">JSMin</span>.<span class="ruby-identifier">minify</span>(<span class="ruby-identifier">input_string</span>)&#x000A;81: <span class="ruby-keyword kw">end</span></pre>
84
+ </div>
85
+ </div>
86
+ <div class='method public-class' id='method-M000021'>
87
+ <a name='M000021'></a>
88
+ <div class='synopsis'>
89
+ <span class='name'>weak</span>
90
+ <span class='arguments'>(input_string)</span>
91
+ </div>
92
+ <div class='description'>
93
+ <p>
94
+ Barebones JavaScript minification engine that:
95
+ </p>
96
+ <ul>
97
+ <li>Skips leading/trailing whitespace for each line, excluding line breaks; and
98
+
99
+ </li>
100
+ <li>Removes one-line comments that had no actual code on that line.
101
+
102
+ </li>
103
+ </ul>
104
+ </div>
105
+ <div class='source'>
106
+ <a class='source-toggle' href='#' onclick="toggleCode('M000021-source'); return false">
107
+ [show source]
108
+ </a>
109
+ <pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js.rb, line 48</span>&#x000A;48: <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>)&#x000A;49: <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>)&#x000A;50: <span class="ruby-identifier">output</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>&#x000A;51: &#x000A;52: <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>&#x000A;53: <span class="ruby-comment cmt"># Remove indentation and trailing whitespace</span>&#x000A;54: <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip!</span>&#x000A;55: <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>&#x000A;56: &#x000A;57: <span class="ruby-comment cmt"># Skip single-line comments</span>&#x000A;58: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^\/\//</span>).<span class="ruby-identifier">nil?</span>&#x000A;59: <span class="ruby-comment cmt"># TODO: Also skip single-line comments that began mid-line, but not</span>&#x000A;60: <span class="ruby-comment cmt"># inside a string or regex</span>&#x000A;61: &#x000A;62: <span class="ruby-comment cmt"># TODO: Skip multi-line comments</span>&#x000A;63: <span class="ruby-comment cmt"># - Should not strip from within a string or regex</span>&#x000A;64: <span class="ruby-comment cmt"># - Should not strip comments that begin with `/*!` (e.g., licenses)</span>&#x000A;65: &#x000A;66: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">line</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n&quot;</span>)&#x000A;67: <span class="ruby-keyword kw">end</span>&#x000A;68: &#x000A;69: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">rewind</span>&#x000A;70: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">read</span>&#x000A;71: <span class="ruby-keyword kw">end</span></pre>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ <div id='footer-push'></div>
117
+ </div>
118
+ <div id='footer'>
119
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
120
+ </div>
121
+ </body>
122
+ </html>
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>: AssetHat::JS::Vendors [AssetHat]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ AssetHat::JS::Vendors
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../../files/lib/asset_hat/js/vendors_rb.html">lib/asset_hat/js/vendors.rb</a>
35
+ </li>
36
+ </ol>
37
+ </div>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <p>
42
+ For working with supported 3rd-party JavaScript plugin/framework/library
43
+ vendors.
44
+ </p>
45
+ </div>
46
+ <div id='method-list'>
47
+ <h2>Methods</h2>
48
+ <h3>public class</h3>
49
+ <ol>
50
+ <li><a href="#M000020">source_for</a></li>
51
+ </ol>
52
+ </div>
53
+ <div id='section'>
54
+ <div id='constants-list'>
55
+ <h2>Constants</h2>
56
+ <div class='name-list'>
57
+ <table summary='Constants'>
58
+ <tr class='top-aligned-row context-row'>
59
+ <td class='context-item-name'>VENDORS</td>
60
+ <td>=</td>
61
+ <td class='context-item-value'>[ :jquery, :jquery_ui, :prototype, :scriptaculous, :mootools, :dojo, :swfobject, :yui, :ext_core ]</td>
62
+ <td>&nbsp;</td>
63
+ <td class='context-item-desc'>
64
+
65
+ A list of supported 3rd-party JavaScript plugin/vendor names.
66
+ </td>
67
+ </tr>
68
+ </table>
69
+ </div>
70
+ </div>
71
+ <div id='methods'>
72
+ <h2>Public class methods</h2>
73
+ <div class='method public-class' id='method-M000020'>
74
+ <a name='M000020'></a>
75
+ <div class='synopsis'>
76
+ <span class='name'>source_for</span>
77
+ <span class='arguments'>(vendor, options={})</span>
78
+ </div>
79
+ <div class='description'>
80
+ <p>
81
+ Accepts an item from VENDORS, and returns the URL at which that vendor
82
+ asset can be found. The URL is either local (relative) or external
83
+ depending on the environment configuration. Options:
84
+ </p>
85
+ <dl>
86
+ <dt>version</dt><dd>The vendor version, e.g., &#8216;1.4.0&#8217; for jQuery 1.4. By default,
87
+ each vendor version is taken from <tt>config/assets.yml</tt>; use this
88
+ option to override the configuration.
89
+
90
+ </dd>
91
+ </dl>
92
+ </div>
93
+ <div class='source'>
94
+ <a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
95
+ [show source]
96
+ </a>
97
+ <pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js/vendors.rb, line 25</span>&#x000A;25: <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>={})&#x000A;26: <span class="ruby-identifier">vendor_config</span> =&#x000A;27: <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>&#x000A;28: <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>&#x000A;29: <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>&#x000A;30: &#x000A;31: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">use_local</span>&#x000A;32: <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>&#x000A;33: <span class="ruby-keyword kw">end</span>&#x000A;34: &#x000A;35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">src</span>.<span class="ruby-identifier">blank?</span>&#x000A;36: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">vendor</span>&#x000A;37: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:jquery</span>&#x000A;38: <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">?&#x000A;39: </span> <span class="ruby-node">&quot;#{['jquery', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;40: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js&quot;</span>&#x000A;41: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:jquery_ui</span>&#x000A;42: <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">?&#x000A;43: </span> <span class="ruby-node">&quot;#{['jquery-ui', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;44: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/#{version}/jquery-ui.min.js&quot;</span>&#x000A;45: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:prototype</span>&#x000A;46: <span class="ruby-comment cmt"># Prototype currently doesn't provide an official minified version.</span>&#x000A;47: <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">?&#x000A;48: </span> <span class="ruby-node">&quot;#{['prototype', version].compact.join('-')}.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;49: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/prototype/#{version}/prototype.js&quot;</span>&#x000A;50: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:scriptaculous</span>&#x000A;51: <span class="ruby-comment cmt"># script.aculo.us currently doesn't provide an official minified version.</span>&#x000A;52: <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">?&#x000A;53: </span> <span class="ruby-node">&quot;#{['scriptaculous', version].compact.join('-')}.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;54: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/scriptaculous/#{version}/scriptaculous.js&quot;</span>&#x000A;55: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:mootools</span>&#x000A;56: <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">?&#x000A;57: </span> <span class="ruby-node">&quot;#{['mootools', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;58: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/mootools/#{version}/mootools-yui-compressed.js&quot;</span>&#x000A;59: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:dojo</span>&#x000A;60: <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">?&#x000A;61: </span> <span class="ruby-node">&quot;#{['dojo', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;62: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/dojo/#{version}/dojo/dojo.xd.js&quot;</span>&#x000A;63: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:swfobject</span>&#x000A;64: <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">?&#x000A;65: </span> <span class="ruby-node">&quot;#{['swfobject', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;66: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/swfobject/#{version}/swfobject.js&quot;</span>&#x000A;67: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:yui</span>&#x000A;68: <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">?&#x000A;69: </span> <span class="ruby-node">&quot;#{['yui', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;70: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/yui/#{version}/build/yuiloader/yuiloader-min.js&quot;</span>&#x000A;71: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:ext_core</span>&#x000A;72: <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">?&#x000A;73: </span> <span class="ruby-node">&quot;#{['ext_core', version].compact.join('-')}.min.js&quot;</span> <span class="ruby-operator">:</span>&#x000A;74: <span class="ruby-node">&quot;http://ajax.googleapis.com/ajax/libs/ext-core/#{version}/ext-core.js&quot;</span>&#x000A;75: <span class="ruby-keyword kw">else</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># TODO: Write to log</span>&#x000A;76: <span class="ruby-keyword kw">end</span>&#x000A;77: <span class="ruby-keyword kw">end</span>&#x000A;78: &#x000A;79: <span class="ruby-identifier">src</span>&#x000A;80: <span class="ruby-keyword kw">end</span></pre>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div id='footer-push'></div>
105
+ </div>
106
+ <div id='footer'>
107
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
108
+ </div>
109
+ </body>
110
+ </html>
@@ -0,0 +1,151 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>: AssetHat::JS [AssetHat]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ AssetHat::JS
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../files/lib/asset_hat/js/vendors_rb.html">lib/asset_hat/js/vendors.rb</a>
35
+ </li>
36
+ <li class='other'>
37
+ <a href="../../files/lib/asset_hat/js_rb.html">lib/asset_hat/js.rb</a>
38
+ </li>
39
+ <li>
40
+ <a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
41
+ </li>
42
+ </ol>
43
+ </div>
44
+ <div id='content'>
45
+ <div id='text'>
46
+ <div id='description'>
47
+ <p>
48
+ Methods for minifying JavaScript.
49
+ </p>
50
+ </div>
51
+ <div id='method-list'>
52
+ <h2>Methods</h2>
53
+ <h3>public class</h3>
54
+ <ol>
55
+ <li><a href="#M000018">min_filepath</a></li>
56
+ <li><a href="#M000019">minify</a></li>
57
+ </ol>
58
+ </div>
59
+ <div id='section'>
60
+ <div id='class-list'>
61
+ <h2>Classes and Modules</h2>
62
+ Module <a href="JS/Engines.html" class="link">AssetHat::JS::Engines</a><br />
63
+ Module <a href="JS/Vendors.html" class="link">AssetHat::JS::Vendors</a><br />
64
+ </div>
65
+ <div id='constants-list'>
66
+ <h2>Constants</h2>
67
+ <div class='name-list'>
68
+ <table summary='Constants'>
69
+ <tr class='top-aligned-row context-row'>
70
+ <td class='context-item-name'>ENGINES</td>
71
+ <td>=</td>
72
+ <td class='context-item-value'>[:weak, :jsmin]</td>
73
+ <td>&nbsp;</td>
74
+ <td class='context-item-desc'>
75
+
76
+ A list of supported minification <a href=JS/Engines.html>engine</a> names.
77
+ </td>
78
+ </tr>
79
+ <tr class='top-aligned-row context-row'>
80
+ <td class='context-item-name'>VENDORS</td>
81
+ <td>=</td>
82
+ <td class='context-item-value'>Vendors::VENDORS</td>
83
+ <td>&nbsp;</td>
84
+ <td class='context-item-desc'>
85
+
86
+ A list of supported <a href=JS/Vendors.html>3rd-party JavaScript
87
+ plugin/vendor</a> names.
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ </div>
92
+ </div>
93
+ <div id='methods'>
94
+ <h2>Public class methods</h2>
95
+ <div class='method public-class' id='method-M000018'>
96
+ <a name='M000018'></a>
97
+ <div class='synopsis'>
98
+ <span class='name'>min_filepath</span>
99
+ <span class='arguments'>(filepath)</span>
100
+ </div>
101
+ <div class='description'>
102
+ <p>
103
+ Returns the expected path for the minified version of a <a
104
+ href="JS.html">JS</a> asset:
105
+ </p>
106
+ <pre>AssetHat::JS.min_filepath('public/javascripts/bundles/application.js')&#x000A; # =&gt; 'public/javascripts/bundles/application.min.js'</pre>
107
+ </div>
108
+ <div class='source'>
109
+ <a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false">
110
+ [show source]
111
+ </a>
112
+ <pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js.rb, line 19</span>&#x000A;19: <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>)&#x000A;20: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">min_filepath</span>(<span class="ruby-identifier">filepath</span>, <span class="ruby-value str">'js'</span>)&#x000A;21: <span class="ruby-keyword kw">end</span></pre>
113
+ </div>
114
+ </div>
115
+ <div class='method public-class' id='method-M000019'>
116
+ <a name='M000019'></a>
117
+ <div class='synopsis'>
118
+ <span class='name'>minify</span>
119
+ <span class='arguments'>(input_string, options={})</span>
120
+ </div>
121
+ <div class='description'>
122
+ <p>
123
+ Accepts a string of <a href="JS.html">JS</a>, and returns that <a
124
+ href="JS.html">JS</a> minified. Options:
125
+ </p>
126
+ <dl>
127
+ <dt>engine</dt><dd>Default is <tt>:jsmin</tt>; see <a href=JS/Engines.html#method-c-jsmin><a
128
+ href="JS/Engines.html#M000022">Engines.jsmin</a></a>. Allowed values are in
129
+ ENGINES.
130
+
131
+ </dd>
132
+ </dl>
133
+ </div>
134
+ <div class='source'>
135
+ <a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false">
136
+ [show source]
137
+ </a>
138
+ <pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/asset_hat/js.rb, line 28</span>&#x000A;28: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">minify</span>(<span class="ruby-identifier">input_string</span>, <span class="ruby-identifier">options</span>={})&#x000A;29: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:engine</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:jsmin</span>)&#x000A;30: &#x000A;31: <span class="ruby-identifier">engine</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:engine</span>].<span class="ruby-identifier">to_sym</span>&#x000A;32: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ENGINES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">engine</span>)&#x000A;33: <span class="ruby-identifier">raise</span> <span class="ruby-node">%Q{&#x000A;34: Unknown JS minification engine '#{engine}'.&#x000A;35: Allowed: #{ENGINES.map{ |e| &quot;'#{e}'&quot; }.join(', ')}&#x000A;36: }</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s+/</span>, <span class="ruby-value str">' '</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span>&#x000A;37: <span class="ruby-keyword kw">end</span>&#x000A;38: &#x000A;39: <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">Engines</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">engine</span>, <span class="ruby-identifier">input_string</span>)&#x000A;40: <span class="ruby-keyword kw">end</span></pre>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ <div id='footer-push'></div>
146
+ </div>
147
+ <div id='footer'>
148
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
149
+ </div>
150
+ </body>
151
+ </html>