iruby 0.2.8 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ubuntu.yml +62 -0
  3. data/CHANGES +76 -0
  4. data/Gemfile +3 -1
  5. data/LICENSE +1 -1
  6. data/README.md +130 -82
  7. data/Rakefile +36 -10
  8. data/ci/Dockerfile.base.erb +41 -0
  9. data/ci/Dockerfile.main.erb +7 -0
  10. data/ci/requirements.txt +1 -0
  11. data/docker/setup.sh +15 -0
  12. data/docker/test.sh +7 -0
  13. data/iruby.gemspec +13 -17
  14. data/lib/iruby.rb +14 -6
  15. data/lib/iruby/backend.rb +41 -7
  16. data/lib/iruby/command.rb +68 -12
  17. data/lib/iruby/display.rb +80 -39
  18. data/lib/iruby/event_manager.rb +40 -0
  19. data/lib/iruby/formatter.rb +5 -4
  20. data/lib/iruby/input.rb +41 -0
  21. data/lib/iruby/input/README.ipynb +502 -0
  22. data/lib/iruby/input/README.md +299 -0
  23. data/lib/iruby/input/autoload.rb +25 -0
  24. data/lib/iruby/input/builder.rb +67 -0
  25. data/lib/iruby/input/button.rb +47 -0
  26. data/lib/iruby/input/cancel.rb +32 -0
  27. data/lib/iruby/input/checkbox.rb +74 -0
  28. data/lib/iruby/input/date.rb +37 -0
  29. data/lib/iruby/input/field.rb +31 -0
  30. data/lib/iruby/input/file.rb +57 -0
  31. data/lib/iruby/input/form.rb +77 -0
  32. data/lib/iruby/input/label.rb +27 -0
  33. data/lib/iruby/input/multiple.rb +76 -0
  34. data/lib/iruby/input/popup.rb +41 -0
  35. data/lib/iruby/input/radio.rb +59 -0
  36. data/lib/iruby/input/select.rb +59 -0
  37. data/lib/iruby/input/textarea.rb +23 -0
  38. data/lib/iruby/input/widget.rb +34 -0
  39. data/lib/iruby/jupyter.rb +77 -0
  40. data/lib/iruby/kernel.rb +106 -27
  41. data/lib/iruby/ostream.rb +29 -8
  42. data/lib/iruby/session.rb +116 -0
  43. data/lib/iruby/session/{rbczmq.rb → cztop.rb} +25 -13
  44. data/lib/iruby/session/ffi_rzmq.rb +15 -2
  45. data/lib/iruby/session_adapter.rb +72 -0
  46. data/lib/iruby/session_adapter/cztop_adapter.rb +45 -0
  47. data/lib/iruby/session_adapter/ffirzmq_adapter.rb +55 -0
  48. data/lib/iruby/session_adapter/pyzmq_adapter.rb +77 -0
  49. data/lib/iruby/session_adapter/test_adapter.rb +49 -0
  50. data/lib/iruby/utils.rb +5 -2
  51. data/lib/iruby/version.rb +1 -1
  52. data/run-test.sh +12 -0
  53. data/tasks/ci.rake +65 -0
  54. data/test/helper.rb +133 -0
  55. data/test/integration_test.rb +22 -11
  56. data/test/iruby/backend_test.rb +37 -0
  57. data/test/iruby/command_test.rb +207 -0
  58. data/test/iruby/event_manager_test.rb +92 -0
  59. data/test/iruby/jupyter_test.rb +27 -0
  60. data/test/iruby/kernel_test.rb +153 -0
  61. data/test/iruby/mime_test.rb +43 -0
  62. data/test/iruby/multi_logger_test.rb +1 -2
  63. data/test/iruby/session_adapter/cztop_adapter_test.rb +20 -0
  64. data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +20 -0
  65. data/test/iruby/session_adapter/session_adapter_test_base.rb +27 -0
  66. data/test/iruby/session_adapter_test.rb +91 -0
  67. data/test/iruby/session_test.rb +48 -0
  68. data/test/run-test.rb +19 -0
  69. metadata +132 -43
  70. data/.travis.yml +0 -16
  71. data/CONTRIBUTORS +0 -19
  72. data/test/test_helper.rb +0 -5
@@ -0,0 +1,40 @@
1
+ module IRuby
2
+ class EventManager
3
+ def initialize(available_events)
4
+ @available_events = available_events.dup.freeze
5
+ @callbacks = available_events.map {|n| [n, []] }.to_h
6
+ end
7
+
8
+ attr_reader :available_events
9
+
10
+ def register(event, &block)
11
+ check_available_event(event)
12
+ @callbacks[event] << block unless block.nil?
13
+ block
14
+ end
15
+
16
+ def unregister(event, callback)
17
+ check_available_event(event)
18
+ val = @callbacks[event].delete(callback)
19
+ unless val
20
+ raise ArgumentError,
21
+ "Given callable object #{callback} is not registered as a #{event} callback"
22
+ end
23
+ val
24
+ end
25
+
26
+ def trigger(event, *args, **kwargs)
27
+ check_available_event(event)
28
+ @callbacks[event].each do |fn|
29
+ fn.call(*args, **kwargs)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def check_available_event(event)
36
+ return if @callbacks.key?(event)
37
+ raise ArgumentError, "Unknown event name: #{event}", caller
38
+ end
39
+ end
40
+ end
@@ -61,7 +61,8 @@ module IRuby
61
61
  rows << row
62
62
  end
63
63
 
64
- if header = keys
64
+ if keys
65
+ header = keys.to_a
65
66
  keys.merge(0...array_size)
66
67
  else
67
68
  keys = 0...array_size
@@ -77,16 +78,16 @@ module IRuby
77
78
 
78
79
  if maxcols && keys.size > maxcols
79
80
  keys1 = keys[0...maxcols / 2]
80
- keys2 = keys[-maxcols / 2...-1]
81
+ keys2 = keys[-maxcols / 2 + 1..-1]
81
82
  if header
82
83
  header1 = header[0...maxcols / 2]
83
- header2 = header[-maxcols / 2...-1]
84
+ header2 = header[-maxcols / 2 + 1..-1]
84
85
  end
85
86
  end
86
87
 
87
88
  if maxrows && rows.size > maxrows
88
89
  rows1 = rows[0...maxrows / 2]
89
- rows2 = rows[-maxrows / 2...-1]
90
+ rows2 = rows[-maxrows / 2 + 1..-1]
90
91
  end
91
92
 
92
93
  table = '<table>'
@@ -0,0 +1,41 @@
1
+ module IRuby
2
+ module Input
3
+ # autoload so that erector is not a required
4
+ # runtime dependency of IRuby
5
+ autoload :Builder, 'iruby/input/autoload'
6
+
7
+ def input prompt='Input'
8
+ result = form{input label: prompt}
9
+ result[:input] unless result.nil?
10
+ end
11
+
12
+ def password prompt='Password'
13
+ result = form{password label: prompt}
14
+ result[:password] unless result.nil?
15
+ end
16
+
17
+ def form &block
18
+ builder = Builder.new(&block)
19
+ form = InputForm.new(
20
+ fields: builder.fields,
21
+ buttons: builder.buttons
22
+ )
23
+ form.widget_display
24
+ builder.process_result form.submit
25
+ end
26
+
27
+ def popup title='Input', &block
28
+ builder = Builder.new(&block)
29
+ form = InputForm.new fields: builder.fields
30
+ popup = Popup.new(
31
+ title: title,
32
+ form: form,
33
+ buttons: builder.buttons
34
+ )
35
+ popup.widget_display
36
+ builder.process_result form.submit
37
+ end
38
+ end
39
+
40
+ extend Input
41
+ end
@@ -0,0 +1,502 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# IRuby Input\n",
8
+ "\n",
9
+ "The `IRuby::Input` class makes it easier for IRuby users to get input from users. For example:"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {
16
+ "collapsed": false
17
+ },
18
+ "outputs": [],
19
+ "source": [
20
+ "name = IRuby.input 'Enter your name'"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "markdown",
25
+ "metadata": {},
26
+ "source": [
27
+ "The following input methods are supported on the `IRuby` module:\n",
28
+ "\n",
29
+ "| method | description |\n",
30
+ "| -------- | -------- |\n",
31
+ "| `input(prompt)` | Prompts the user for a line of input |\n",
32
+ "| `password(prompt)` | Prompts the user for a password |\n",
33
+ "| `form(&block)` | Presents a form to the user |\n",
34
+ "| `popup(title,&block)` | Displays a form to the user as a popup |"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "markdown",
39
+ "metadata": {},
40
+ "source": [
41
+ "## Forms\n",
42
+ "\n",
43
+ "Forms are groups of inputs to be collected from the user. For example:"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": null,
49
+ "metadata": {
50
+ "collapsed": false
51
+ },
52
+ "outputs": [],
53
+ "source": [
54
+ "result = IRuby.form do \n",
55
+ " input :username\n",
56
+ " password :password\n",
57
+ " button\n",
58
+ "end"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "markdown",
63
+ "metadata": {},
64
+ "source": [
65
+ "The following methods are available to build forms: \n",
66
+ "\n",
67
+ "| method | description |\n",
68
+ "| -------- | -------- |\n",
69
+ "| `input(key=:input)` | Prompts the user for a line of input |\n",
70
+ "| `textarea(key=:textarea),` | Adds a textarea to the form |\n",
71
+ "| `password(key=:password)` | Prompts the user for a password |\n",
72
+ "| `button(key=:done, color: :blue)` | Adds a submit button to the form |\n",
73
+ "| `cancel(prompt='Cancel')` | Adds a cancel button to the form |\n",
74
+ "| `text(string)` | Adds text to the form |\n",
75
+ "| `html(&block)` | Inserts HTML from the given [erector block](https://github.com/erector/erector) |\n",
76
+ "| `file(key=:file)` | Adds a file input to the form |\n",
77
+ "| `date(key=:date)` | Adds a date picker to the form |\n",
78
+ "| `select(*options)` | Adds a dropdown select input to the form |\n",
79
+ "| `radio(*options)` | Adds a radio select input to the form |\n",
80
+ "| `checkbox(*options)` | Adds checkbox inputs to the form |"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "markdown",
85
+ "metadata": {},
86
+ "source": [
87
+ "## Popups\n",
88
+ " \n",
89
+ "Popups are just forms in a bootstrap modal. They are useful when users **Run All** in a notebook with a lot of inputs. The popups always appear in the same spot, so users don't have to scroll down to find the next input. \n",
90
+ "\n",
91
+ "Popups accept a `title` argument, for example: "
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "code",
96
+ "execution_count": null,
97
+ "metadata": {
98
+ "collapsed": false
99
+ },
100
+ "outputs": [],
101
+ "source": [
102
+ "result = IRuby.popup 'Please enter your name' do \n",
103
+ " input\n",
104
+ " button\n",
105
+ "end"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "markdown",
110
+ "metadata": {},
111
+ "source": [
112
+ "## Submit and cancel\n",
113
+ "\n",
114
+ "The enter key will submit an input or form and the escape key will cancel it. Canceled inputs are returned as `nil`. Inputs are automatically canceled if destroyed. An input can be destroyed by clearing its cell's output. The `cancel` button will cancel a form and all other buttons will submit it. \n",
115
+ "\n",
116
+ "After a form destroyed, the cell's output is cleared. Be careful not to prompt for input in a block that has previous output you would like to keep. Output is cleared to prevent forms from interferring with one another and to ensure that inputs are not inadvertently saved to the notebook. "
117
+ ]
118
+ },
119
+ {
120
+ "cell_type": "code",
121
+ "execution_count": null,
122
+ "metadata": {
123
+ "collapsed": false
124
+ },
125
+ "outputs": [],
126
+ "source": [
127
+ "result = IRuby.popup 'Confirm' do \n",
128
+ " text 'Are you sure you want to continue?'\n",
129
+ " cancel 'No'\n",
130
+ " button 'Yes'\n",
131
+ "end"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "markdown",
136
+ "metadata": {},
137
+ "source": [
138
+ "## Custom keys\n",
139
+ "\n",
140
+ "Every widget has an entry in the final results hash. A custom key can be passed as the first parameter to the hash. If no key is provided, the widget name is used as the key. The `cancel` widget has no key; it's first parameter is its label. "
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": null,
146
+ "metadata": {
147
+ "collapsed": false
148
+ },
149
+ "outputs": [],
150
+ "source": [
151
+ "result = IRuby.form do\n",
152
+ " input :username\n",
153
+ " password :password\n",
154
+ "end"
155
+ ]
156
+ },
157
+ {
158
+ "cell_type": "markdown",
159
+ "metadata": {},
160
+ "source": [
161
+ "## Custom labels\n",
162
+ "\n",
163
+ "Field labels appear to the left of the field. Button labels appear as the text on the button. `cancel` labels are passed as the first argument. All other widgets' labels are set using the `label` parameter. "
164
+ ]
165
+ },
166
+ {
167
+ "cell_type": "code",
168
+ "execution_count": null,
169
+ "metadata": {
170
+ "collapsed": false
171
+ },
172
+ "outputs": [],
173
+ "source": [
174
+ "result = IRuby.form do \n",
175
+ " input :name, label: 'Please enter your name'\n",
176
+ " cancel 'None of your business!'\n",
177
+ " button :submit, label: 'All done'\n",
178
+ "end"
179
+ ]
180
+ },
181
+ {
182
+ "cell_type": "markdown",
183
+ "metadata": {},
184
+ "source": [
185
+ "## Defaults\n",
186
+ "\n",
187
+ "Most inputs will accept a `default` parameter. If no default is given, the deault is `nil`. Since checkboxes can have multiple values selected, you can pass an array of values. To check everything, pass `true` as the default. "
188
+ ]
189
+ },
190
+ {
191
+ "cell_type": "code",
192
+ "execution_count": null,
193
+ "metadata": {
194
+ "collapsed": false
195
+ },
196
+ "outputs": [],
197
+ "source": [
198
+ "result = IRuby.form do \n",
199
+ " checkbox :one, 'Fish', 'Cat', 'Dog', default: 'Fish'\n",
200
+ " checkbox :many, 'Fish', 'Cat', 'Dog', default: ['Cat', 'Dog']\n",
201
+ " checkbox :all, 'Fish', 'Cat', 'Dog', default: true\n",
202
+ " button :submit, label: 'All done'\n",
203
+ "end"
204
+ ]
205
+ },
206
+ {
207
+ "cell_type": "markdown",
208
+ "metadata": {},
209
+ "source": [
210
+ "## Dates\n",
211
+ "\n",
212
+ "The `date` widget provides a calendar popup and returns a `Time` object. It's default should also be a `Time` object. "
213
+ ]
214
+ },
215
+ {
216
+ "cell_type": "code",
217
+ "execution_count": null,
218
+ "metadata": {
219
+ "collapsed": false
220
+ },
221
+ "outputs": [],
222
+ "source": [
223
+ "result = IRuby.form do \n",
224
+ " date :birthday\n",
225
+ " date :today, default: Time.now\n",
226
+ " button\n",
227
+ "end"
228
+ ]
229
+ },
230
+ {
231
+ "cell_type": "markdown",
232
+ "metadata": {},
233
+ "source": [
234
+ "## Buttons\n",
235
+ "\n",
236
+ "Buttons do not appear in the final hash unless they are clicked. If clicked, their value is `true`. Here are the various colors a button can be:"
237
+ ]
238
+ },
239
+ {
240
+ "cell_type": "code",
241
+ "execution_count": null,
242
+ "metadata": {
243
+ "collapsed": false
244
+ },
245
+ "outputs": [],
246
+ "source": [
247
+ "result = IRuby.form do \n",
248
+ " IRuby::Input::Button::COLORS.each_key do |color|\n",
249
+ " button color, color: color\n",
250
+ " end\n",
251
+ "end"
252
+ ]
253
+ },
254
+ {
255
+ "cell_type": "markdown",
256
+ "metadata": {},
257
+ "source": [
258
+ "## Textareas\n",
259
+ "\n",
260
+ "Textareas are multiline inputs that are convenient for larger inputs. If you need a line return when typing in a textarea, use shift+enter since enter will submit the form."
261
+ ]
262
+ },
263
+ {
264
+ "cell_type": "code",
265
+ "execution_count": null,
266
+ "metadata": {
267
+ "collapsed": false
268
+ },
269
+ "outputs": [],
270
+ "source": [
271
+ "result = IRuby.form do \n",
272
+ " text 'Enter email addresses, one per line (use shift+enter for newlines)'\n",
273
+ " textarea :emails\n",
274
+ "end"
275
+ ]
276
+ },
277
+ {
278
+ "cell_type": "markdown",
279
+ "metadata": {},
280
+ "source": [
281
+ "## Text and HTML\n",
282
+ "\n",
283
+ "You can insert lines of text or custom html using their respective helpers:"
284
+ ]
285
+ },
286
+ {
287
+ "cell_type": "code",
288
+ "execution_count": null,
289
+ "metadata": {
290
+ "collapsed": false
291
+ },
292
+ "outputs": [],
293
+ "source": [
294
+ "result = IRuby.form do \n",
295
+ " html { h1 'Choose a Stooge' }\n",
296
+ " text 'Choose your favorite stooge'\n",
297
+ " select :stooge, 'Moe', 'Larry', 'Curly'\n",
298
+ " button\n",
299
+ "end"
300
+ ]
301
+ },
302
+ {
303
+ "cell_type": "markdown",
304
+ "metadata": {},
305
+ "source": [
306
+ "## Dropdowns\n",
307
+ "\n",
308
+ "A `select` is a dropdown of options. Use a `multiple` to allow multiple selections. `multiple` widgets accept an additional `size` parameters that determines the number of rows. The default is 4. "
309
+ ]
310
+ },
311
+ {
312
+ "cell_type": "code",
313
+ "execution_count": null,
314
+ "metadata": {
315
+ "collapsed": false
316
+ },
317
+ "outputs": [],
318
+ "source": [
319
+ "result = IRuby.form do \n",
320
+ " select :stooge, 'Moe', 'Larry', 'Curly'\n",
321
+ " select :stooge, 'Moe', 'Larry', 'Curly', default: 'Moe'\n",
322
+ " multiple :stooges, 'Moe', 'Larry', 'Curly', default: true, size: 3\n",
323
+ " multiple :stooges, 'Moe', 'Larry', 'Curly', default: ['Moe','Curly']\n",
324
+ " button\n",
325
+ "end"
326
+ ]
327
+ },
328
+ {
329
+ "cell_type": "markdown",
330
+ "metadata": {},
331
+ "source": [
332
+ "## Radio selects and checkboxes\n",
333
+ "\n",
334
+ "Like selects, radio selects and checkboxes take multiple arguments, each one an option. If the first argument is a symbol, it is used as the key. \n",
335
+ "\n",
336
+ "Note that the `checkbox` widget will always return `nil` or an array. "
337
+ ]
338
+ },
339
+ {
340
+ "cell_type": "code",
341
+ "execution_count": null,
342
+ "metadata": {
343
+ "collapsed": false
344
+ },
345
+ "outputs": [],
346
+ "source": [
347
+ "result = IRuby.form do \n",
348
+ " radio :children, *(0..12), label: 'How many children do you have?'\n",
349
+ " checkbox :gender, 'Male', 'Female', 'Intersex', label: 'Select the genders of your children'\n",
350
+ " button\n",
351
+ "end"
352
+ ]
353
+ },
354
+ {
355
+ "cell_type": "markdown",
356
+ "metadata": {},
357
+ "source": [
358
+ "## Files\n",
359
+ "\n",
360
+ "Since file widgets capture the enter key, you should include a button when creating forms that contain only a file input:"
361
+ ]
362
+ },
363
+ {
364
+ "cell_type": "code",
365
+ "execution_count": null,
366
+ "metadata": {
367
+ "collapsed": true
368
+ },
369
+ "outputs": [],
370
+ "source": [
371
+ "IRuby.form do \n",
372
+ " file :avatar, label: 'Choose an Avatar'\n",
373
+ " button :submit\n",
374
+ "end"
375
+ ]
376
+ },
377
+ {
378
+ "cell_type": "markdown",
379
+ "metadata": {},
380
+ "source": [
381
+ "File widgets return a hash with three keys: \n",
382
+ "\n",
383
+ "* `data`: The contents of the file as a string\n",
384
+ "* `content_type`: The type of file, such as `text/plain` or `image/jpeg`\n",
385
+ "* `name`: The name of the uploaded file"
386
+ ]
387
+ },
388
+ {
389
+ "cell_type": "markdown",
390
+ "metadata": {},
391
+ "source": [
392
+ "## Example\n",
393
+ "\n",
394
+ "Here is an example form that uses every built-in widget. "
395
+ ]
396
+ },
397
+ {
398
+ "cell_type": "code",
399
+ "execution_count": null,
400
+ "metadata": {
401
+ "collapsed": false,
402
+ "scrolled": false
403
+ },
404
+ "outputs": [],
405
+ "source": [
406
+ "result = IRuby.form do \n",
407
+ " html { h1 'The Everything Form' }\n",
408
+ " text 'Marvel at the strange and varied inputs!'\n",
409
+ " date\n",
410
+ " file\n",
411
+ " input :username\n",
412
+ " password\n",
413
+ " textarea\n",
414
+ " radio *(1..10)\n",
415
+ " checkbox 'Fish', 'Cat', 'Dog', label: 'Animals'\n",
416
+ " select :color, *IRuby::Input::Button::COLORS.keys\n",
417
+ " cancel \n",
418
+ " button \n",
419
+ "end"
420
+ ]
421
+ },
422
+ {
423
+ "cell_type": "markdown",
424
+ "metadata": {},
425
+ "source": [
426
+ "## Writing your own widget\n",
427
+ "\n",
428
+ "Most form methods are `IRuby::Input::Widget` instances. A `Widget` is an [`Erector::Widget`](https://github.com/erector/erector) with some additional helpers. Here is the `cancel` widget:\n",
429
+ "\n",
430
+ "```ruby\n",
431
+ "module IRuby\n",
432
+ " module Input\n",
433
+ " class Cancel < Widget\n",
434
+ " needs :label\n",
435
+ "\n",
436
+ " builder :cancel do |label='Cancel'|\n",
437
+ " add_button Cancel.new(label: label)\n",
438
+ " end\n",
439
+ "\n",
440
+ " def widget_css\n",
441
+ " \".iruby-cancel { margin-left: 5px; }\"\n",
442
+ " end\n",
443
+ "\n",
444
+ " def widget_js\n",
445
+ " <<-JS\n",
446
+ " $('.iruby-cancel').click(function(){\n",
447
+ " $('#iruby-form').remove();\n",
448
+ " });\n",
449
+ " JS\n",
450
+ " end\n",
451
+ "\n",
452
+ " def widget_html\n",
453
+ " button(\n",
454
+ " @label,\n",
455
+ " type: 'button', \n",
456
+ " :'data-dismiss' => 'modal',\n",
457
+ " class: \"btn btn-danger pull-right iruby-cancel\"\n",
458
+ " )\n",
459
+ " end\n",
460
+ " end\n",
461
+ " end\n",
462
+ "end\n",
463
+ "```\n",
464
+ "\n",
465
+ "The following methods are available for widgets to use or override: \n",
466
+ "\n",
467
+ "| method | description |\n",
468
+ "| -------- | -------- |\n",
469
+ "| `widget_js` | Returns the widget's Javascript |\n",
470
+ "| `widget_css` | Returns the widget's CSS |\n",
471
+ "| `widget_html` | Returns the widget's |\n",
472
+ "| `builder(method,&block)` | Class method to add form building helpers. |\n",
473
+ "\n",
474
+ "The following methods are available in the `builder` block:\n",
475
+ "\n",
476
+ "| method | description |\n",
477
+ "| -------- | -------- |\n",
478
+ "| `add_field(field)` | Adds a widget to the form's field area |\n",
479
+ "| `add_button(button)` | Adds a button to the form's button area |\n",
480
+ "| `process(key,&block)` | Register a custom processing block for the given key in the results hash |\n",
481
+ "| `unique_key(key)` | Returns a unique key for the given key. Use this to make sure that there are no key collisions in the final results hash. |\n",
482
+ "\n",
483
+ "A canceled form always returns `nil`. Otherwise, the form collects any element with a `data-iruby-key` and non-falsey `data-iruby-value` and passes those to the processor proc registered for the key. See the `File` widget for a more involved example of processing results."
484
+ ]
485
+ }
486
+ ],
487
+ "metadata": {
488
+ "kernelspec": {
489
+ "display_name": "Ruby 2.2.1",
490
+ "language": "ruby",
491
+ "name": "ruby"
492
+ },
493
+ "language_info": {
494
+ "file_extension": ".rb",
495
+ "mimetype": "application/x-ruby",
496
+ "name": "ruby",
497
+ "version": "2.2.3"
498
+ }
499
+ },
500
+ "nbformat": 4,
501
+ "nbformat_minor": 0
502
+ }