rubyserif 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Makefile ADDED
@@ -0,0 +1,14 @@
1
+ GEM_FILE=js-0.1.gem
2
+ SPEC_FILE=javascript.gemspec
3
+
4
+ all: gem
5
+ @gem install $(GEM_FILE)
6
+
7
+ gem:
8
+ @gem build $(SPEC_FILE)
9
+
10
+ install:
11
+ @gem install $(GEM_FILE)
12
+
13
+ test: gem
14
+ @ruby test/test.rb
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ JavaScript
2
+ ==========
3
+
4
+ _swarley's poor excuse for JavaScript like features_
5
+
6
+ Create JSON objects and functions with the JavaScript module.
7
+
8
+ > Module JavaScript
9
+ > |
10
+ > - class Object
11
+ > |
12
+ > - class Function
13
+
14
+ I may add more. Who knows?
@@ -0,0 +1,242 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: JavaScript::Function</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="class">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/js_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/js.rb">lib/js.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-new">::new</a></li>
69
+
70
+ <li><a href="#method-i-5B-5D">#[]</a></li>
71
+
72
+ </ul>
73
+ </div>
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="project-metadata">
80
+
81
+
82
+ <div id="fileindex-section" class="section project-section">
83
+ <h3 class="section-header">Files</h3>
84
+ <ul>
85
+
86
+ <li class="file"><a href="../Makefile.html">Makefile</a></li>
87
+
88
+ </ul>
89
+ </div>
90
+
91
+
92
+ <div id="classindex-section" class="section project-section">
93
+ <h3 class="section-header">Class/Module Index
94
+ <span class="search-toggle"><img src="../images/find.png"
95
+ height="16" width="16" alt="[+]"
96
+ title="show/hide quicksearch" /></span></h3>
97
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
98
+ <fieldset>
99
+ <legend>Quicksearch</legend>
100
+ <input type="text" name="quicksearch" value=""
101
+ class="quicksearch-field" />
102
+ </fieldset>
103
+ </form>
104
+
105
+ <ul class="link-list">
106
+
107
+ <li><a href="../JavaScript.html">JavaScript</a></li>
108
+
109
+ <li><a href="../JavaScript/Function.html">JavaScript::Function</a></li>
110
+
111
+ <li><a href="../JavaScript/Object.html">JavaScript::Object</a></li>
112
+
113
+ </ul>
114
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
115
+ </div>
116
+
117
+
118
+ </div>
119
+ </div>
120
+
121
+ <div id="documentation">
122
+ <h1 class="class">JavaScript::Function</h1>
123
+
124
+ <div id="description" class="description">
125
+
126
+ </div><!-- description -->
127
+
128
+
129
+
130
+
131
+ <div id="5Buntitled-5D" class="documentation-section">
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+ <!-- Methods -->
141
+
142
+ <div id="public-class-method-details" class="method-section section">
143
+ <h3 class="section-header">Public Class Methods</h3>
144
+
145
+
146
+ <div id="new-method" class="method-detail ">
147
+ <a name="method-c-new"></a>
148
+
149
+
150
+ <div class="method-heading">
151
+ <span class="method-name">new</span><span
152
+ class="method-args">(&code)</span>
153
+ <span class="method-click-advice">click to toggle source</span>
154
+ </div>
155
+
156
+
157
+ <div class="method-description">
158
+
159
+
160
+
161
+
162
+
163
+ <div class="method-source-code" id="new-source">
164
+ <pre>
165
+ <span class="ruby-comment"># File lib/js.rb, line 30</span>
166
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(&amp;<span class="ruby-identifier">code</span>)
167
+ <span class="ruby-ivar">@code</span> = <span class="ruby-identifier">code</span>
168
+ <span class="ruby-keyword">end</span></pre>
169
+ </div><!-- new-source -->
170
+
171
+ </div>
172
+
173
+
174
+
175
+
176
+ </div><!-- new-method -->
177
+
178
+
179
+ </div><!-- public-class-method-details -->
180
+
181
+ <div id="public-instance-method-details" class="method-section section">
182
+ <h3 class="section-header">Public Instance Methods</h3>
183
+
184
+
185
+ <div id="5B-5D-method" class="method-detail ">
186
+ <a name="method-i-5B-5D"></a>
187
+
188
+
189
+ <div class="method-heading">
190
+ <span class="method-name">[]</span><span
191
+ class="method-args">(*args)</span>
192
+ <span class="method-click-advice">click to toggle source</span>
193
+ </div>
194
+
195
+
196
+ <div class="method-description">
197
+
198
+
199
+
200
+
201
+
202
+ <div class="method-source-code" id="5B-5D-source">
203
+ <pre>
204
+ <span class="ruby-comment"># File lib/js.rb, line 34</span>
205
+ <span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(*<span class="ruby-identifier">args</span>)
206
+ <span class="ruby-identifier">i</span>=<span class="ruby-string">'a'</span>; <span class="ruby-identifier">string</span>=<span class="ruby-string">''</span>
207
+ <span class="ruby-keyword">while</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>)
208
+ <span class="ruby-ivar">@temp</span> = {}
209
+ <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;@temp[:#{i}] = arg&quot;</span>
210
+ <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;, @temp[:#{i}]&quot;</span>
211
+ <span class="ruby-identifier">i</span>.<span class="ruby-identifier">next!</span>
212
+ <span class="ruby-keyword">end</span>
213
+ <span class="ruby-identifier">string</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/\,/</span>,<span class="ruby-string">''</span>)
214
+ <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;@code.call #{string}&quot;</span>
215
+ <span class="ruby-ivar">@temp</span> = <span class="ruby-keyword">nil</span>
216
+ <span class="ruby-keyword">end</span></pre>
217
+ </div><!-- 5B-5D-source -->
218
+
219
+ </div>
220
+
221
+
222
+
223
+
224
+ </div><!-- 5B-5D-method -->
225
+
226
+
227
+ </div><!-- public-instance-method-details -->
228
+
229
+ </div><!-- 5Buntitled-5D -->
230
+
231
+
232
+ </div><!-- documentation -->
233
+
234
+ <div id="validator-badges">
235
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
236
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
237
+ Rdoc Generator</a> 2</small>.</p>
238
+ </div>
239
+
240
+ </body>
241
+ </html>
242
+
@@ -0,0 +1,282 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: JavaScript::Object</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="class">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/js_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/js.rb">lib/js.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-new">::new</a></li>
69
+
70
+ <li><a href="#method-i-2F">#/</a></li>
71
+
72
+ <li><a href="#method-i-method_missing">#method_missing</a></li>
73
+
74
+ </ul>
75
+ </div>
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <div id="project-metadata">
82
+
83
+
84
+ <div id="fileindex-section" class="section project-section">
85
+ <h3 class="section-header">Files</h3>
86
+ <ul>
87
+
88
+ <li class="file"><a href="../Makefile.html">Makefile</a></li>
89
+
90
+ </ul>
91
+ </div>
92
+
93
+
94
+ <div id="classindex-section" class="section project-section">
95
+ <h3 class="section-header">Class/Module Index
96
+ <span class="search-toggle"><img src="../images/find.png"
97
+ height="16" width="16" alt="[+]"
98
+ title="show/hide quicksearch" /></span></h3>
99
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
100
+ <fieldset>
101
+ <legend>Quicksearch</legend>
102
+ <input type="text" name="quicksearch" value=""
103
+ class="quicksearch-field" />
104
+ </fieldset>
105
+ </form>
106
+
107
+ <ul class="link-list">
108
+
109
+ <li><a href="../JavaScript.html">JavaScript</a></li>
110
+
111
+ <li><a href="../JavaScript/Function.html">JavaScript::Function</a></li>
112
+
113
+ <li><a href="../JavaScript/Object.html">JavaScript::Object</a></li>
114
+
115
+ </ul>
116
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
117
+ </div>
118
+
119
+
120
+ </div>
121
+ </div>
122
+
123
+ <div id="documentation">
124
+ <h1 class="class">JavaScript::Object</h1>
125
+
126
+ <div id="description" class="description">
127
+
128
+ </div><!-- description -->
129
+
130
+
131
+
132
+
133
+ <div id="5Buntitled-5D" class="documentation-section">
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <!-- Methods -->
143
+
144
+ <div id="public-class-method-details" class="method-section section">
145
+ <h3 class="section-header">Public Class Methods</h3>
146
+
147
+
148
+ <div id="new-method" class="method-detail ">
149
+ <a name="method-c-new"></a>
150
+
151
+
152
+ <div class="method-heading">
153
+ <span class="method-name">new</span><span
154
+ class="method-args">(hash={}, constants=[])</span>
155
+ <span class="method-click-advice">click to toggle source</span>
156
+ </div>
157
+
158
+
159
+ <div class="method-description">
160
+
161
+
162
+
163
+
164
+
165
+ <div class="method-source-code" id="new-source">
166
+ <pre>
167
+ <span class="ruby-comment"># File lib/js.rb, line 4</span>
168
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hash</span>={}, <span class="ruby-identifier">constants</span>=[]) <span class="ruby-comment">#Put keys into constants that you want to be read only</span>
169
+ <span class="ruby-ivar">@hash</span>,<span class="ruby-ivar">@constants</span>=<span class="ruby-identifier">hash</span>,<span class="ruby-identifier">constants</span>
170
+ <span class="ruby-keyword">end</span></pre>
171
+ </div><!-- new-source -->
172
+
173
+ </div>
174
+
175
+
176
+
177
+
178
+ </div><!-- new-method -->
179
+
180
+
181
+ </div><!-- public-class-method-details -->
182
+
183
+ <div id="public-instance-method-details" class="method-section section">
184
+ <h3 class="section-header">Public Instance Methods</h3>
185
+
186
+
187
+ <div id="2F-method" class="method-detail ">
188
+ <a name="method-i-2F"></a>
189
+
190
+
191
+ <div class="method-heading">
192
+ <span class="method-name">/</span><span
193
+ class="method-args">(args=:elements)</span>
194
+ <span class="method-click-advice">click to toggle source</span>
195
+ </div>
196
+
197
+
198
+ <div class="method-description">
199
+
200
+
201
+
202
+
203
+
204
+ <div class="method-source-code" id="2F-source">
205
+ <pre>
206
+ <span class="ruby-comment"># File lib/js.rb, line 17</span>
207
+ <span class="ruby-keyword">def</span> <span class="ruby-operator">/</span>(<span class="ruby-identifier">args</span>=<span class="ruby-value">:elements</span>) <span class="ruby-comment">#/</span>
208
+ <span class="ruby-keyword">case</span> <span class="ruby-identifier">args</span>
209
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:elements</span>
210
+ <span class="ruby-keyword">return</span> <span class="ruby-ivar">@hash</span>.<span class="ruby-identifier">keys</span>
211
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:constants</span>
212
+ <span class="ruby-keyword">return</span> <span class="ruby-ivar">@constants</span>.<span class="ruby-identifier">keys</span>
213
+ <span class="ruby-keyword">else</span>
214
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
215
+ <span class="ruby-keyword">end</span>
216
+ <span class="ruby-keyword">end</span></pre>
217
+ </div><!-- 2F-source -->
218
+
219
+ </div>
220
+
221
+
222
+
223
+
224
+ </div><!-- 2F-method -->
225
+
226
+
227
+ <div id="method_missing-method" class="method-detail ">
228
+ <a name="method-i-method_missing"></a>
229
+
230
+
231
+ <div class="method-heading">
232
+ <span class="method-name">method_missing</span><span
233
+ class="method-args">(name, *args, &block)</span>
234
+ <span class="method-click-advice">click to toggle source</span>
235
+ </div>
236
+
237
+
238
+ <div class="method-description">
239
+
240
+
241
+
242
+
243
+
244
+ <div class="method-source-code" id="method_missing-source">
245
+ <pre>
246
+ <span class="ruby-comment"># File lib/js.rb, line 7</span>
247
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">block</span>)
248
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/=$/</span>
249
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Cannot modify object constant - #{name.to_s.sub(/=/,'')}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@constants</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/=/</span>,<span class="ruby-string">''</span>).<span class="ruby-identifier">to_sym</span>
250
+ <span class="ruby-ivar">@hash</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/=/</span>,<span class="ruby-string">''</span>).<span class="ruby-identifier">to_sym</span>] = ((<span class="ruby-identifier">args</span><span class="ruby-operator">==</span>[]) <span class="ruby-operator">?</span> ((<span class="ruby-identifier">block</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">block</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
251
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^\/(.+?)$/</span>
252
+ <span class="ruby-node">/($1.to_sym) #/</span>
253
+ <span class="ruby-keyword">else</span>
254
+ <span class="ruby-keyword">return</span> <span class="ruby-ivar">@hash</span>[<span class="ruby-identifier">name</span>]
255
+ <span class="ruby-keyword">end</span>
256
+ <span class="ruby-keyword">end</span></pre>
257
+ </div><!-- method_missing-source -->
258
+
259
+ </div>
260
+
261
+
262
+
263
+
264
+ </div><!-- method_missing-method -->
265
+
266
+
267
+ </div><!-- public-instance-method-details -->
268
+
269
+ </div><!-- 5Buntitled-5D -->
270
+
271
+
272
+ </div><!-- documentation -->
273
+
274
+ <div id="validator-badges">
275
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
276
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
277
+ Rdoc Generator</a> 2</small>.</p>
278
+ </div>
279
+
280
+ </body>
281
+ </html>
282
+