closure 1.3.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +142 -9
- data/bin/closure-script +19 -0
- data/closure-compiler/README +18 -4
- data/closure-compiler/compiler.jar +0 -0
- data/closure-templates/SoyToJsSrcCompiler.jar +0 -0
- data/closure-templates/soydata.js +163 -0
- data/closure-templates/soyutils.js +1191 -159
- data/closure-templates/soyutils_usegoog.js +1107 -60
- data/docs/closure/Closure.html +58 -52
- data/docs/closure/Closure/BeanShell.html +6 -3
- data/docs/closure/Closure/Compiler.html +18 -15
- data/docs/closure/Closure/Compiler/Compilation.html +9 -3
- data/docs/closure/Closure/Compiler/Error.html +3 -3
- data/docs/closure/Closure/FileResponse.html +13 -7
- data/docs/closure/Closure/Goog.html +49 -85
- data/docs/closure/Closure/Middleware.html +5 -3
- data/docs/closure/Closure/Script.html +14 -5
- data/docs/closure/Closure/Script/NotFound.html +3 -3
- data/docs/closure/Closure/Script/RenderStackOverflow.html +3 -3
- data/docs/closure/Closure/Server.html +6 -3
- data/docs/closure/Closure/ShowExceptions.html +5 -3
- data/docs/closure/Closure/Sources.html +145 -37
- data/docs/closure/Closure/Templates.html +11 -10
- data/docs/closure/Closure/Templates/Error.html +3 -3
- data/docs/closure/_index.html +4 -4
- data/docs/closure/css/full_list.css +2 -0
- data/docs/closure/css/style.css +2 -0
- data/docs/closure/file.LICENSE.html +3 -3
- data/docs/closure/file.README.html +151 -10
- data/docs/closure/frames.html +1 -1
- data/docs/closure/index.html +151 -10
- data/docs/closure/js/full_list.js +23 -6
- data/docs/closure/method_list.html +91 -83
- data/docs/closure/top-level-namespace.html +3 -3
- data/lib/closure.rb +3 -16
- data/lib/closure/compiler.rb +135 -53
- data/lib/closure/goog.rb +5 -29
- data/lib/closure/sources.rb +22 -9
- data/lib/closure/version.rb +1 -1
- data/scripts/config.ru +0 -1
- data/scripts/hello/compiler_build.js +5 -5
- data/scripts/hello/compiler_build.map +518 -522
- data/scripts/hello/compiler_debug.js +7 -13
- data/scripts/hello/legume.js +2 -2
- data/scripts/index.erb +0 -3
- data/scripts/modules/compiler_build.js +3 -3
- data/scripts/modules/compiler_build.map +11569 -11476
- data/scripts/modules/compiler_build_api.js +1 -1
- data/scripts/modules/compiler_build_app.js +71 -70
- data/scripts/modules/compiler_build_settings.js +2 -2
- data/scripts/modules/compiler_debug.js +3 -3
- data/scripts/modules/compiler_debug_api.js +2 -2
- data/scripts/modules/compiler_debug_app.js +926 -1382
- data/scripts/modules/compiler_debug_settings.js +21 -24
- metadata +8 -18
- data/externs/chrome_extensions.externs +0 -968
- data/externs/jquery-1.3.2.externs +0 -718
- data/externs/jquery-1.4.3.externs +0 -1289
- data/externs/jquery-1.4.4.externs +0 -1302
- data/externs/jquery-1.5.externs +0 -1697
- data/externs/jquery-ui.externs +0 -10
- data/externs/jquery.externs +0 -4
- data/scripts/jquery/compiler.js.erb +0 -7
- data/scripts/jquery/compiler_out.js +0 -1
- data/scripts/jquery/index.erb +0 -25
- data/scripts/jquery/jquery_1.4.4.js +0 -167
- data/scripts/jquery/jquery_test.js +0 -8
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Closure::Templates
|
8
8
|
|
9
|
-
— Documentation by YARD 0.7.
|
9
|
+
— Documentation by YARD 0.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -172,13 +172,13 @@ on source filename arguments.
|
|
172
172
|
|
173
173
|
<h4><div class='inline'></div></h4>
|
174
174
|
<pre class="example code"><span class='const'>Closure</span><span class='op'>::</span><span class='const'>Templates</span><span class='period'>.</span><span class='id compile'>compile</span> <span class='qwords_beg'>%w{
|
175
|
-
</span><span class='
|
176
|
-
</span><span class='
|
177
|
-
</span><span class='
|
178
|
-
</span><span class='
|
179
|
-
</span><span class='
|
180
|
-
</span><span class='
|
181
|
-
</span><span class='
|
175
|
+
</span><span class='tstring_content'> --shouldProvideRequireSoyNamespaces</span><span class='words_sep'>
|
176
|
+
</span><span class='tstring_content'> --cssHandlingScheme</span><span class='words_sep'> </span><span class='tstring_content'>goog</span><span class='words_sep'>
|
177
|
+
</span><span class='tstring_content'> --shouldGenerateJsdoc</span><span class='words_sep'>
|
178
|
+
</span><span class='tstring_content'> --outputPathFormat</span><span class='words_sep'> </span><span class='tstring_content'>{INPUT_DIRECTORY}{INPUT_FILE_NAME_NO_EXT}.js</span><span class='words_sep'>
|
179
|
+
</span><span class='tstring_content'> app/javascripts/**/*.soy</span><span class='words_sep'>
|
180
|
+
</span><span class='tstring_content'> vendor/javascripts/**/*.soy</span><span class='words_sep'>
|
181
|
+
</span><span class='tstring_end'>}</span></span></pre>
|
182
182
|
|
183
183
|
</div>
|
184
184
|
<h3>Parameters:</h3>
|
@@ -222,6 +222,7 @@ All source filenames will be expanded to this location.
|
|
222
222
|
|
223
223
|
</ul>
|
224
224
|
|
225
|
+
|
225
226
|
</div><table class="source_code">
|
226
227
|
<tr>
|
227
228
|
<td>
|
@@ -352,9 +353,9 @@ All source filenames will be expanded to this location.
|
|
352
353
|
</div>
|
353
354
|
|
354
355
|
<div id="footer">
|
355
|
-
Generated on
|
356
|
+
Generated on Sun Oct 23 22:43:17 2011 by
|
356
357
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
357
|
-
0.7.
|
358
|
+
0.7.3 (ruby-1.9.2).
|
358
359
|
</div>
|
359
360
|
|
360
361
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Closure::Templates::Error
|
8
8
|
|
9
|
-
— Documentation by YARD 0.7.
|
9
|
+
— Documentation by YARD 0.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -107,9 +107,9 @@
|
|
107
107
|
</div>
|
108
108
|
|
109
109
|
<div id="footer">
|
110
|
-
Generated on
|
110
|
+
Generated on Sun Oct 23 22:43:17 2011 by
|
111
111
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
112
|
-
0.7.
|
112
|
+
0.7.3 (ruby-1.9.2).
|
113
113
|
</div>
|
114
114
|
|
115
115
|
</body>
|
data/docs/closure/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.7.
|
7
|
+
Documentation by YARD 0.7.3
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
<iframe id="search_frame"></iframe>
|
54
54
|
|
55
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.7.
|
55
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.7.3</h1>
|
56
56
|
<div id="listing">
|
57
57
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
58
58
|
|
@@ -280,9 +280,9 @@
|
|
280
280
|
</div>
|
281
281
|
|
282
282
|
<div id="footer">
|
283
|
-
Generated on
|
283
|
+
Generated on Sun Oct 23 22:43:16 2011 by
|
284
284
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
285
|
-
0.7.
|
285
|
+
0.7.3 (ruby-1.9.2).
|
286
286
|
</div>
|
287
287
|
|
288
288
|
</body>
|
@@ -16,6 +16,8 @@ h1 { padding: 12px 10px; padding-bottom: 0; margin: 0; font-size: 1.4em; }
|
|
16
16
|
#noresults { padding: 7px 12px; }
|
17
17
|
#content.insearch #noresults { margin-left: 7px; }
|
18
18
|
ul.collapsed ul, ul.collapsed li { display: none; }
|
19
|
+
ul.collapsed.search_uncollapsed { display: block; }
|
20
|
+
ul.collapsed.search_uncollapsed li { display: list-item; }
|
19
21
|
li a.toggle { cursor: default; position: relative; left: -5px; top: 4px; text-indent: -999px; width: 10px; height: 9px; margin-left: -10px; display: block; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAMy8xNC8wOeNZPpQAAAE2SURBVDiNrZTBccIwEEXfelIAHUA6CZ24BGaWO+FuzZAK4k6gg5QAdGAq+Bxs2Yqx7BzyL7Llp/VfzZeQhCTc/ezuGzKKnKSzpCxXJM8fwNXda3df5RZETlIt6YUzSQDs93sl8w3wBZxCCE10GM1OcWbWjB2mWgEH4Mfdyxm3PSepBHibgQE2wLe7r4HjEidpnXMYdQPKEMJcsZ4zs2POYQOcaPfwMVOo58zsAdMt18BuoVDPxUJRacELbXv3hUIX2vYmOUvi8C8ydz/ThjXrqKqqLbDIAdsCKBd+Wo7GWa7o9qzOQHVVVXeAbs+yHHCH4aTsaCOQqunmUy1yBUAXkdMIfMlgF5EXLo2OpV/c/Up7jG4hhHcYLgWzAZXUc2b2ixsfvc/RmNNfOXD3Q/oeL9axJE1yT9IOoUu6MGUkAAAAAElFTkSuQmCC) no-repeat bottom left; }
|
20
22
|
li.collapsed a.toggle { opacity: 0.5; cursor: default; background-position: top left; }
|
21
23
|
li { color: #888; cursor: pointer; }
|
data/docs/closure/css/style.css
CHANGED
@@ -24,6 +24,8 @@ h2 small { font-weight: normal; font-size: 0.7em; display: block; float: right;
|
|
24
24
|
.docstring h2 { font-size: 1.1em; }
|
25
25
|
.docstring h3, .docstring h4 { font-size: 1em; border-bottom: 0; padding-top: 10px; }
|
26
26
|
.summary_desc .object_link, .docstring .object_link { font-family: monospace; }
|
27
|
+
.rdoc-term { padding-right: 25px; font-weight: bold; }
|
28
|
+
.rdoc-list p { margin: 0; padding: 0; margin-bottom: 4px; }
|
27
29
|
|
28
30
|
/* style for <ul> */
|
29
31
|
#filecontents li > p, .docstring li > p { margin: 0px; }
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: LICENSE
|
8
8
|
|
9
|
-
— Documentation by YARD 0.7.
|
9
|
+
— Documentation by YARD 0.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -257,9 +257,9 @@
|
|
257
257
|
limitations under the License.</pre></div></div>
|
258
258
|
|
259
259
|
<div id="footer">
|
260
|
-
Generated on
|
260
|
+
Generated on Sun Oct 23 22:43:16 2011 by
|
261
261
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
262
|
-
0.7.
|
262
|
+
0.7.3 (ruby-1.9.2).
|
263
263
|
</div>
|
264
264
|
|
265
265
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.7.
|
9
|
+
— Documentation by YARD 0.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -54,25 +54,166 @@
|
|
54
54
|
|
55
55
|
<iframe id="search_frame"></iframe>
|
56
56
|
|
57
|
-
<div id="content"><div id='filecontents'><
|
57
|
+
<div id="content"><div id='filecontents'><h1 id="closure-script">Closure Script</h1>
|
58
|
+
|
59
|
+
<p>A development environment for Google Closure Tools.</p>
|
58
60
|
|
59
61
|
<p>Licensed under the Apache License, Version 2.0 (the “License”);
|
60
62
|
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
|
61
63
|
|
62
|
-
<
|
63
|
-
|
64
|
+
<h1 id="installing">Installing</h1>
|
65
|
+
|
66
|
+
<p>Everything you need for advanced Google Closure development is available in a
|
67
|
+
single .jar for the Java Virtual Machine. You may also run the tools on any
|
68
|
+
Ruby platform (>=1.8.6) including JRuby (JVM), Rubinius (LLVM), and Ruby 1.9 (YARV).</p>
|
69
|
+
|
70
|
+
<p>It is generally easier to get started with the .jar distribution, especially
|
71
|
+
under Windows. Mac OSX and most Linux will have a compatible Ruby by default.</p>
|
72
|
+
|
73
|
+
<h2 id="java-jar">Java (.jar)</h2>
|
74
|
+
|
75
|
+
<h3 id="step-1-download-to-a-new-folder">Step 1: Download to a new folder</h3>
|
76
|
+
|
77
|
+
<pre class="code">cd ~/empty-dir
|
78
|
+
curl -LO https://github.com/downloads/dturnbull/closure-script/closure-1.4.0.jar
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
<h3 id="step-2-start-server-from-the-new-folder">Step 2: Start server from the new folder</h3>
|
82
|
+
|
83
|
+
<pre class="code">java -jar closure-1.4.0.jar
|
84
|
+
</pre>
|
85
|
+
|
86
|
+
<h3 id="step-3-open-a-web-browser">Step 3: Open a web browser</h3>
|
87
|
+
|
88
|
+
<pre class="code">http://localhost:8080/
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
<h2 id="ruby-gem">Ruby (.gem)</h2>
|
92
|
+
|
93
|
+
<h3 id="step-1-install-the-gem">Step 1: Install the gem</h3>
|
94
|
+
|
95
|
+
<pre class="code"><span class='id gem'>gem</span> <span class='id install'>install</span> <span class='id closure'>closure</span>
|
96
|
+
</pre>
|
97
|
+
|
98
|
+
<h3 id="step-2-start-server-from-a-new-folder">Step 2: Start server from a new folder</h3>
|
99
|
+
|
100
|
+
<pre class="code"><span class='id cd'>cd</span> <span class='op'>~</span><span class='tstring'><span class='regexp_beg'>/</span><span class='regexp_end'>empty-dir
|
101
|
+
</span></span></pre>
|
102
|
+
|
103
|
+
<h3 id="step-3-open-a-web-browser-1">Step 3: Open a web browser</h3>
|
104
|
+
|
105
|
+
<pre class="code">http://localhost:8080/
|
106
|
+
</pre>
|
107
|
+
|
108
|
+
<h1 id="the-closure-script-method">The Closure Script Method</h1>
|
109
|
+
|
110
|
+
<p>When you start the server for the first time in an empty folder, the home page
|
111
|
+
will prompt you to install scaffolding. This includes three example projects to
|
112
|
+
demonstrate soy, modules, and unobtrusive markup. Dissecting and working with
|
113
|
+
these examples is the fast track to understanding The Closure Script Method.</p>
|
114
|
+
|
115
|
+
<h2 id="the-server">The Server</h2>
|
116
|
+
|
117
|
+
<p>Closure Script is a high-performance, multi-threaded web application engineered
|
118
|
+
exclusively for the needs of Google Closure Javascript development.</p>
|
119
|
+
|
120
|
+
<p>You will be freed from the command line. All error output from the compiler
|
121
|
+
will show on the Javascript console. This avoids lost time from not being
|
122
|
+
in the correct log and missing an important error. Javascript compilation
|
123
|
+
is done just-in-time and only when source files have changed.
|
124
|
+
No need for a separate build step; just refresh the browser. Not working?
|
125
|
+
Check your Javascript console. Then back to your editor.</p>
|
126
|
+
|
127
|
+
<h2 id="easy-configuration">Easy Configuration</h2>
|
128
|
+
|
129
|
+
<p>You’ll need to supply the directories where you have source Javascript and static files.
|
130
|
+
Ruby developers will recognize that Closure Script is Rack middleware. This makes it trivial
|
131
|
+
to include the Closure Script build tool in a Rails application. If you’re not developing a
|
132
|
+
Ruby application, your <code>config.ru</code> will probably never be more complex than the following:</p>
|
133
|
+
|
134
|
+
<pre class="code"><span class='id require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>closure</span><span class='tstring_end'>'</span></span>
|
135
|
+
<span class='const'>Closure</span><span class='period'>.</span><span class='id add_source'>add_source</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span>
|
136
|
+
<span class='id use'>use</span> <span class='const'>Closure</span><span class='op'>::</span><span class='const'>Middleware</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>index</span><span class='tstring_end'>'</span></span>
|
137
|
+
<span class='id run'>run</span> <span class='const'>Rack</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span>
|
138
|
+
</pre>
|
139
|
+
|
140
|
+
<p>The add_source command may be duplicated for each source Javascript folder you want to
|
141
|
+
serve. The first argument is the local filesystem path, the second is the mount point
|
142
|
+
for the http server. Make sure not to accidentally serve more than one copy of
|
143
|
+
Closure Library per Closure Script server or you’ll get an error.</p>
|
144
|
+
|
145
|
+
<h2 id="cut-and-paste-ruby">Cut-and-Paste Ruby</h2>
|
146
|
+
|
147
|
+
<p>In practice, all you do with Ruby is adjust the arguments to compiler.jar by
|
148
|
+
analyzing options on the URL query string. If you can handle conditionally appending
|
149
|
+
strings to an array in Ruby, then you’re fully qualified to use Closure Script!
|
150
|
+
There’s enough example code in the scaffolding to cut-and-paste your way to victory.</p>
|
151
|
+
|
152
|
+
<h3 id="demo-scripts">Demo Scripts</h3>
|
153
|
+
|
154
|
+
<p>The Closure Script Method is to create various demo pages to drive development. You may
|
155
|
+
also choose to use your main application instead of Closure Script for your demo pages.</p>
|
156
|
+
|
157
|
+
<p>Files ending with .erb are Closure Scripts and will have their embedded Ruby evaluated
|
158
|
+
as they are served. Scripts may also render other Scripts and pass variables if you
|
159
|
+
need that complexity. Scripts default to a MIME type of text/html so <code>demo.erb</code> is
|
160
|
+
the same as <code>demo.html.erb</code>.</p>
|
161
|
+
|
162
|
+
<pre class="code"><html>
|
163
|
+
<head>
|
164
|
+
<script src='compiler.js?<%= query_string %>'></script>
|
165
|
+
</head>
|
166
|
+
</pre>
|
167
|
+
|
168
|
+
<h3 id="compiler-scripts">Compiler Scripts</h3>
|
169
|
+
|
170
|
+
<p>Compilation is performed by requesting a file that generates Javascript instead of HTML.
|
171
|
+
The goog.compile() function of Closure Script handles everything for you.</p>
|
172
|
+
|
173
|
+
<p>Note that goog.compile() does not simply call the compiler. It will monitor your source
|
174
|
+
files and skip calling the compiler if everything is up to date. The Java process will
|
175
|
+
remain running on a REPL so subsequent compilations don’t pay the Java startup cost.
|
176
|
+
The dependency tree for all your sources is known so you can build from namespaces
|
177
|
+
(–ns) as well as files (–js). Modules have been automated to find common dependencies,
|
178
|
+
like plovr, and work from namespaces so you don’t need to use filenames and counts.
|
179
|
+
The luxurious goog.compile() can serve up a loader for the raw, uncompiled files,
|
180
|
+
even when working with modules.</p>
|
181
|
+
|
182
|
+
<p>A very simple compiler.js.erb is as follows. Check the scaffold for practical examples
|
183
|
+
that use the query string.</p>
|
184
|
+
|
185
|
+
<pre class="code"><%
|
186
|
+
args = %w{
|
187
|
+
--compilation_level ADVANCED_OPTIMIZATIONS
|
188
|
+
--js_output_file compiler_build.js
|
189
|
+
--ns myapp.helloWorld
|
190
|
+
}
|
191
|
+
@response = goog.compile(args).to_response
|
192
|
+
%>
|
193
|
+
</pre>
|
194
|
+
|
195
|
+
<h3 id="testing">Testing</h3>
|
196
|
+
|
197
|
+
<p>Closure Script helps with testing because it can see your data in ways that
|
198
|
+
browsers are not allowed to. The <code>alltests.js</code> file in Closure Library is
|
199
|
+
generated by a program that scans the filesystem. Here’s a replacement in
|
200
|
+
Closure Script so that a manual build step never has to be executed again:</p>
|
64
201
|
|
65
|
-
<
|
66
|
-
|
202
|
+
<pre class="code"><% all_test_files = Dir.glob expand_path '**/*_test.html'
|
203
|
+
json_strings = all_test_files.map { |x| relative_src(x).dump }
|
204
|
+
-%>var _allTests = [<%= json_strings.join(',') %>];
|
205
|
+
</pre>
|
67
206
|
|
68
|
-
<p>
|
69
|
-
|
207
|
+
<p>Since all of Ruby is at your disposal, you could even pull fixture data from SQL
|
208
|
+
or a web service. Perhaps a fixture refresh happens when the developer pushes a
|
209
|
+
form button. The svn.erb tool is a complex example that uses threads and a
|
210
|
+
background process. You’re only limited by your imagination.</p>
|
70
211
|
</div></div>
|
71
212
|
|
72
213
|
<div id="footer">
|
73
|
-
Generated on
|
214
|
+
Generated on Sun Oct 23 22:43:16 2011 by
|
74
215
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
75
|
-
0.7.
|
216
|
+
0.7.3 (ruby-1.9.2).
|
76
217
|
</div>
|
77
218
|
|
78
219
|
</body>
|
data/docs/closure/frames.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
-
<title>Documentation by YARD 0.7.
|
7
|
+
<title>Documentation by YARD 0.7.3</title>
|
8
8
|
</head>
|
9
9
|
<frameset cols="20%,*">
|
10
10
|
<frame name="list" src="class_list.html" />
|
data/docs/closure/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.7.
|
9
|
+
— Documentation by YARD 0.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -54,25 +54,166 @@
|
|
54
54
|
|
55
55
|
<iframe id="search_frame"></iframe>
|
56
56
|
|
57
|
-
<div id="content"><div id='filecontents'><
|
57
|
+
<div id="content"><div id='filecontents'><h1 id="closure-script">Closure Script</h1>
|
58
|
+
|
59
|
+
<p>A development environment for Google Closure Tools.</p>
|
58
60
|
|
59
61
|
<p>Licensed under the Apache License, Version 2.0 (the “License”);
|
60
62
|
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
|
61
63
|
|
62
|
-
<
|
63
|
-
|
64
|
+
<h1 id="installing">Installing</h1>
|
65
|
+
|
66
|
+
<p>Everything you need for advanced Google Closure development is available in a
|
67
|
+
single .jar for the Java Virtual Machine. You may also run the tools on any
|
68
|
+
Ruby platform (>=1.8.6) including JRuby (JVM), Rubinius (LLVM), and Ruby 1.9 (YARV).</p>
|
69
|
+
|
70
|
+
<p>It is generally easier to get started with the .jar distribution, especially
|
71
|
+
under Windows. Mac OSX and most Linux will have a compatible Ruby by default.</p>
|
72
|
+
|
73
|
+
<h2 id="java-jar">Java (.jar)</h2>
|
74
|
+
|
75
|
+
<h3 id="step-1-download-to-a-new-folder">Step 1: Download to a new folder</h3>
|
76
|
+
|
77
|
+
<pre class="code">cd ~/empty-dir
|
78
|
+
curl -LO https://github.com/downloads/dturnbull/closure-script/closure-1.4.0.jar
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
<h3 id="step-2-start-server-from-the-new-folder">Step 2: Start server from the new folder</h3>
|
82
|
+
|
83
|
+
<pre class="code">java -jar closure-1.4.0.jar
|
84
|
+
</pre>
|
85
|
+
|
86
|
+
<h3 id="step-3-open-a-web-browser">Step 3: Open a web browser</h3>
|
87
|
+
|
88
|
+
<pre class="code">http://localhost:8080/
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
<h2 id="ruby-gem">Ruby (.gem)</h2>
|
92
|
+
|
93
|
+
<h3 id="step-1-install-the-gem">Step 1: Install the gem</h3>
|
94
|
+
|
95
|
+
<pre class="code"><span class='id gem'>gem</span> <span class='id install'>install</span> <span class='id closure'>closure</span>
|
96
|
+
</pre>
|
97
|
+
|
98
|
+
<h3 id="step-2-start-server-from-a-new-folder">Step 2: Start server from a new folder</h3>
|
99
|
+
|
100
|
+
<pre class="code"><span class='id cd'>cd</span> <span class='op'>~</span><span class='tstring'><span class='regexp_beg'>/</span><span class='regexp_end'>empty-dir
|
101
|
+
</span></span></pre>
|
102
|
+
|
103
|
+
<h3 id="step-3-open-a-web-browser-1">Step 3: Open a web browser</h3>
|
104
|
+
|
105
|
+
<pre class="code">http://localhost:8080/
|
106
|
+
</pre>
|
107
|
+
|
108
|
+
<h1 id="the-closure-script-method">The Closure Script Method</h1>
|
109
|
+
|
110
|
+
<p>When you start the server for the first time in an empty folder, the home page
|
111
|
+
will prompt you to install scaffolding. This includes three example projects to
|
112
|
+
demonstrate soy, modules, and unobtrusive markup. Dissecting and working with
|
113
|
+
these examples is the fast track to understanding The Closure Script Method.</p>
|
114
|
+
|
115
|
+
<h2 id="the-server">The Server</h2>
|
116
|
+
|
117
|
+
<p>Closure Script is a high-performance, multi-threaded web application engineered
|
118
|
+
exclusively for the needs of Google Closure Javascript development.</p>
|
119
|
+
|
120
|
+
<p>You will be freed from the command line. All error output from the compiler
|
121
|
+
will show on the Javascript console. This avoids lost time from not being
|
122
|
+
in the correct log and missing an important error. Javascript compilation
|
123
|
+
is done just-in-time and only when source files have changed.
|
124
|
+
No need for a separate build step; just refresh the browser. Not working?
|
125
|
+
Check your Javascript console. Then back to your editor.</p>
|
126
|
+
|
127
|
+
<h2 id="easy-configuration">Easy Configuration</h2>
|
128
|
+
|
129
|
+
<p>You’ll need to supply the directories where you have source Javascript and static files.
|
130
|
+
Ruby developers will recognize that Closure Script is Rack middleware. This makes it trivial
|
131
|
+
to include the Closure Script build tool in a Rails application. If you’re not developing a
|
132
|
+
Ruby application, your <code>config.ru</code> will probably never be more complex than the following:</p>
|
133
|
+
|
134
|
+
<pre class="code"><span class='id require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>closure</span><span class='tstring_end'>'</span></span>
|
135
|
+
<span class='const'>Closure</span><span class='period'>.</span><span class='id add_source'>add_source</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span>
|
136
|
+
<span class='id use'>use</span> <span class='const'>Closure</span><span class='op'>::</span><span class='const'>Middleware</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>index</span><span class='tstring_end'>'</span></span>
|
137
|
+
<span class='id run'>run</span> <span class='const'>Rack</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span>
|
138
|
+
</pre>
|
139
|
+
|
140
|
+
<p>The add_source command may be duplicated for each source Javascript folder you want to
|
141
|
+
serve. The first argument is the local filesystem path, the second is the mount point
|
142
|
+
for the http server. Make sure not to accidentally serve more than one copy of
|
143
|
+
Closure Library per Closure Script server or you’ll get an error.</p>
|
144
|
+
|
145
|
+
<h2 id="cut-and-paste-ruby">Cut-and-Paste Ruby</h2>
|
146
|
+
|
147
|
+
<p>In practice, all you do with Ruby is adjust the arguments to compiler.jar by
|
148
|
+
analyzing options on the URL query string. If you can handle conditionally appending
|
149
|
+
strings to an array in Ruby, then you’re fully qualified to use Closure Script!
|
150
|
+
There’s enough example code in the scaffolding to cut-and-paste your way to victory.</p>
|
151
|
+
|
152
|
+
<h3 id="demo-scripts">Demo Scripts</h3>
|
153
|
+
|
154
|
+
<p>The Closure Script Method is to create various demo pages to drive development. You may
|
155
|
+
also choose to use your main application instead of Closure Script for your demo pages.</p>
|
156
|
+
|
157
|
+
<p>Files ending with .erb are Closure Scripts and will have their embedded Ruby evaluated
|
158
|
+
as they are served. Scripts may also render other Scripts and pass variables if you
|
159
|
+
need that complexity. Scripts default to a MIME type of text/html so <code>demo.erb</code> is
|
160
|
+
the same as <code>demo.html.erb</code>.</p>
|
161
|
+
|
162
|
+
<pre class="code"><html>
|
163
|
+
<head>
|
164
|
+
<script src='compiler.js?<%= query_string %>'></script>
|
165
|
+
</head>
|
166
|
+
</pre>
|
167
|
+
|
168
|
+
<h3 id="compiler-scripts">Compiler Scripts</h3>
|
169
|
+
|
170
|
+
<p>Compilation is performed by requesting a file that generates Javascript instead of HTML.
|
171
|
+
The goog.compile() function of Closure Script handles everything for you.</p>
|
172
|
+
|
173
|
+
<p>Note that goog.compile() does not simply call the compiler. It will monitor your source
|
174
|
+
files and skip calling the compiler if everything is up to date. The Java process will
|
175
|
+
remain running on a REPL so subsequent compilations don’t pay the Java startup cost.
|
176
|
+
The dependency tree for all your sources is known so you can build from namespaces
|
177
|
+
(–ns) as well as files (–js). Modules have been automated to find common dependencies,
|
178
|
+
like plovr, and work from namespaces so you don’t need to use filenames and counts.
|
179
|
+
The luxurious goog.compile() can serve up a loader for the raw, uncompiled files,
|
180
|
+
even when working with modules.</p>
|
181
|
+
|
182
|
+
<p>A very simple compiler.js.erb is as follows. Check the scaffold for practical examples
|
183
|
+
that use the query string.</p>
|
184
|
+
|
185
|
+
<pre class="code"><%
|
186
|
+
args = %w{
|
187
|
+
--compilation_level ADVANCED_OPTIMIZATIONS
|
188
|
+
--js_output_file compiler_build.js
|
189
|
+
--ns myapp.helloWorld
|
190
|
+
}
|
191
|
+
@response = goog.compile(args).to_response
|
192
|
+
%>
|
193
|
+
</pre>
|
194
|
+
|
195
|
+
<h3 id="testing">Testing</h3>
|
196
|
+
|
197
|
+
<p>Closure Script helps with testing because it can see your data in ways that
|
198
|
+
browsers are not allowed to. The <code>alltests.js</code> file in Closure Library is
|
199
|
+
generated by a program that scans the filesystem. Here’s a replacement in
|
200
|
+
Closure Script so that a manual build step never has to be executed again:</p>
|
64
201
|
|
65
|
-
<
|
66
|
-
|
202
|
+
<pre class="code"><% all_test_files = Dir.glob expand_path '**/*_test.html'
|
203
|
+
json_strings = all_test_files.map { |x| relative_src(x).dump }
|
204
|
+
-%>var _allTests = [<%= json_strings.join(',') %>];
|
205
|
+
</pre>
|
67
206
|
|
68
|
-
<p>
|
69
|
-
|
207
|
+
<p>Since all of Ruby is at your disposal, you could even pull fixture data from SQL
|
208
|
+
or a web service. Perhaps a fixture refresh happens when the developer pushes a
|
209
|
+
form button. The svn.erb tool is a complex example that uses threads and a
|
210
|
+
background process. You’re only limited by your imagination.</p>
|
70
211
|
</div></div>
|
71
212
|
|
72
213
|
<div id="footer">
|
73
|
-
Generated on
|
214
|
+
Generated on Sun Oct 23 22:43:16 2011 by
|
74
215
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
75
|
-
0.7.
|
216
|
+
0.7.3 (ruby-1.9.2).
|
76
217
|
</div>
|
77
218
|
|
78
219
|
</body>
|