bauxite 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/doc/Bauxite/Action.html +3 -3
  3. data/doc/Bauxite/ActionModule.html +4 -4
  4. data/doc/Bauxite/Application.html +1 -1
  5. data/doc/Bauxite/Context.html +184 -143
  6. data/doc/Bauxite/Errors/AssertionError.html +1 -1
  7. data/doc/Bauxite/Errors/FileNotFoundError.html +1 -1
  8. data/doc/Bauxite/Errors/FormatError.html +107 -0
  9. data/doc/Bauxite/Errors.html +1 -1
  10. data/doc/Bauxite/Loggers/CompositeLogger.html +1 -1
  11. data/doc/Bauxite/Loggers/EchoLogger.html +2 -1
  12. data/doc/Bauxite/Loggers/FileLogger.html +1 -1
  13. data/doc/Bauxite/Loggers/NullLogger.html +6 -6
  14. data/doc/Bauxite/Loggers/TerminalLogger.html +15 -10
  15. data/doc/Bauxite/Loggers/XtermLogger.html +1 -1
  16. data/doc/Bauxite/Loggers.html +1 -1
  17. data/doc/Bauxite/Parser.html +325 -0
  18. data/doc/Bauxite/ParserModule.html +203 -0
  19. data/doc/Bauxite/Selector.html +1 -1
  20. data/doc/Bauxite/SelectorModule.html +4 -4
  21. data/doc/Bauxite.html +1 -1
  22. data/doc/created.rid +42 -38
  23. data/doc/index.html +5 -1
  24. data/doc/js/search_index.js +1 -1
  25. data/doc/table_of_contents.html +77 -36
  26. data/lib/bauxite/actions/alias.rb +1 -1
  27. data/lib/bauxite/actions/debug.rb +2 -3
  28. data/lib/bauxite/actions/tryload.rb +1 -1
  29. data/lib/bauxite/application.rb +2 -10
  30. data/lib/bauxite/core/{Context.rb → context.rb} +117 -114
  31. data/lib/bauxite/core/{Errors.rb → errors.rb} +6 -0
  32. data/lib/bauxite/core/parser.rb +78 -0
  33. data/lib/bauxite/loggers/echo.rb +1 -0
  34. data/lib/bauxite/loggers/terminal.rb +5 -0
  35. data/lib/bauxite/parsers/csv.rb +49 -0
  36. data/lib/bauxite/parsers/default.rb +42 -0
  37. data/lib/bauxite/parsers/html.rb +76 -0
  38. data/lib/bauxite.rb +1 -1
  39. data/test/alias.bxt +3 -0
  40. data/test/parsers/page.html +7 -0
  41. data/test/parsers.bxt +2 -0
  42. data/test/parsers.csv +7 -0
  43. data/test/parsers.html +32 -0
  44. metadata +18 -7
  45. /data/lib/bauxite/core/{Action.rb → action.rb} +0 -0
  46. /data/lib/bauxite/core/{Logger.rb → logger.rb} +0 -0
  47. /data/lib/bauxite/core/{Selector.rb → selector.rb} +0 -0
@@ -100,16 +100,22 @@
100
100
 
101
101
  <li ><a href="#method-c-new">::new</a>
102
102
 
103
- <li ><a href="#method-c-parse_args">::parse_args</a>
103
+ <li ><a href="#method-c-parse_action_default">::parse_action_default</a>
104
+
105
+ <li ><a href="#method-c-parsers">::parsers</a>
104
106
 
105
107
  <li ><a href="#method-c-selectors">::selectors</a>
106
108
 
107
109
  <li ><a href="#method-c-wait">::wait</a>
108
110
 
111
+ <li ><a href="#method-i-add_alias">#add_alias</a>
112
+
109
113
  <li ><a href="#method-i-debug">#debug</a>
110
114
 
111
115
  <li ><a href="#method-i-exec_action">#exec_action</a>
112
116
 
117
+ <li ><a href="#method-i-exec_file">#exec_file</a>
118
+
113
119
  <li ><a href="#method-i-expand">#expand</a>
114
120
 
115
121
  <li ><a href="#method-i-find">#find</a>
@@ -118,8 +124,6 @@
118
124
 
119
125
  <li ><a href="#method-i-handle_errors">#handle_errors</a>
120
126
 
121
- <li ><a href="#method-i-parse_file">#parse_file</a>
122
-
123
127
  <li ><a href="#method-i-reset_driver">#reset_driver</a>
124
128
 
125
129
  <li ><a href="#method-i-start">#start</a>
@@ -166,19 +170,6 @@ test engine (i.e. Selenium WebDriver).</p>
166
170
  </header>
167
171
 
168
172
 
169
- <div id="attribute-i-aliases" class="method-detail">
170
- <div class="method-heading attribute-method-heading">
171
- <span class="method-name">aliases</span><span
172
- class="attribute-access-type">[RW]</span>
173
- </div>
174
-
175
- <div class="method-description">
176
-
177
- <p><a href="Action.html">Action</a> aliases.</p>
178
-
179
- </div>
180
- </div>
181
-
182
173
  <div id="attribute-i-driver" class="method-detail">
183
174
  <div class="method-heading attribute-method-heading">
184
175
  <span class="method-name">driver</span><span
@@ -304,7 +295,7 @@ href="Context.html#method-i-stop">stop</a> (defaults to <code>false</code>)</p>
304
295
 
305
296
 
306
297
  <div class="method-source-code" id="new-source">
307
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 70</span>
298
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 68</span>
308
299
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>)
309
300
  <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
310
301
  <span class="ruby-ivar">@driver_name</span> = (<span class="ruby-identifier">options</span>[<span class="ruby-value">:driver</span>] <span class="ruby-operator">||</span> <span class="ruby-value">:firefox</span>).<span class="ruby-identifier">to_sym</span>
@@ -320,6 +311,8 @@ href="Context.html#method-i-stop">stop</a> (defaults to <code>false</code>)</p>
320
311
  <span class="ruby-identifier">handle_errors</span> <span class="ruby-keyword">do</span>
321
312
  <span class="ruby-ivar">@logger</span> = <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_logger</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:logger</span>], <span class="ruby-identifier">options</span>[<span class="ruby-value">:logger_opt</span>])
322
313
  <span class="ruby-keyword">end</span>
314
+
315
+ <span class="ruby-ivar">@parser</span> = <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>)
323
316
  <span class="ruby-keyword">end</span></pre>
324
317
  </div>
325
318
 
@@ -364,7 +357,7 @@ href="Context.html#method-i-stop">stop</a> (defaults to <code>false</code>)</p>
364
357
 
365
358
 
366
359
  <div class="method-source-code" id="debug-source">
367
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 175</span>
360
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 175</span>
368
361
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>
369
362
  <span class="ruby-identifier">exec_action</span>(<span class="ruby-string">&#39;debug&#39;</span>, <span class="ruby-keyword">false</span>)
370
363
  <span class="ruby-keyword">end</span></pre>
@@ -421,7 +414,7 @@ applies if no <code>block</code> was given).</p>
421
414
 
422
415
 
423
416
  <div class="method-source-code" id="find-source">
424
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 164</span>
417
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 164</span>
425
418
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-comment"># yields: element</span>
426
419
  <span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoSuchElementError</span> <span class="ruby-keyword">do</span>
427
420
  <span class="ruby-constant">Selector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>).<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
@@ -471,7 +464,7 @@ the inner text or the value of the <code>value</code> attribute.</p>
471
464
 
472
465
 
473
466
  <div class="method-source-code" id="get_value-source">
474
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 194</span>
467
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 194</span>
475
468
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">element</span>)
476
469
  <span class="ruby-keyword">if</span> [<span class="ruby-string">&#39;input&#39;</span>,<span class="ruby-string">&#39;select&#39;</span>,<span class="ruby-string">&#39;textarea&#39;</span>].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">element</span>.<span class="ruby-identifier">tag_name</span>.<span class="ruby-identifier">downcase</span>
477
470
  <span class="ruby-identifier">element</span>.<span class="ruby-identifier">attribute</span>(<span class="ruby-string">&#39;value&#39;</span>)
@@ -514,7 +507,7 @@ the inner text or the value of the <code>value</code> attribute.</p>
514
507
 
515
508
 
516
509
  <div class="method-source-code" id="reset_driver-source">
517
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 119</span>
510
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 119</span>
518
511
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">reset_driver</span>
519
512
  <span class="ruby-ivar">@driver</span>.<span class="ruby-identifier">quit</span>
520
513
  <span class="ruby-identifier">_load_driver</span>
@@ -563,7 +556,7 @@ href="Context.html#method-i-stop">stop</a>).</p>
563
556
 
564
557
 
565
558
  <div class="method-source-code" id="start-source">
566
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 101</span>
559
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 101</span>
567
560
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">start</span>(<span class="ruby-identifier">actions</span> = [])
568
561
  <span class="ruby-identifier">_load_driver</span>
569
562
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actions</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
@@ -622,7 +615,7 @@ href="Context.html#method-i-stop">stop</a> pattern.</p>
622
615
 
623
616
 
624
617
  <div class="method-source-code" id="stop-source">
625
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 139</span>
618
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 139</span>
626
619
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">stop</span>
627
620
  <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">wait</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">:wait</span>]
628
621
  <span class="ruby-ivar">@driver</span>.<span class="ruby-identifier">quit</span>
@@ -688,7 +681,7 @@ logger type.</p>
688
681
 
689
682
 
690
683
  <div class="method-source-code" id="load_logger-source">
691
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 371</span>
684
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 315</span>
692
685
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">load_logger</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span>)
693
686
  <span class="ruby-identifier">log_name</span> = (<span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;null&#39;</span>).<span class="ruby-identifier">downcase</span>
694
687
 
@@ -711,11 +704,11 @@ logger type.</p>
711
704
  </div>
712
705
 
713
706
 
714
- <div id="method-c-parse_args" class="method-detail ">
707
+ <div id="method-c-parse_action_default" class="method-detail ">
715
708
 
716
709
  <div class="method-heading">
717
- <span class="method-name">parse_args</span><span
718
- class="method-args">(line)</span>
710
+ <span class="method-name">parse_action_default</span><span
711
+ class="method-args">(text, file = '<unknown>', line = 0)</span>
719
712
 
720
713
  <span class="method-click-advice">click to toggle source</span>
721
714
 
@@ -724,43 +717,44 @@ logger type.</p>
724
717
 
725
718
  <div class="method-description">
726
719
 
727
- <p>Parses a line of action text into an array. The input <code>line</code>
728
- should be a space-separated list of values, surrounded by optional quotes
729
- (“).</p>
730
-
731
- <p>The first element in <code>line</code> will be interpreted as an action
732
- name. Valid action names are retuned by <a
733
- href="Context.html#method-c-actions">::actions</a>.</p>
734
-
735
- <p>The other elements in <code>line</code> will be interpreted as action
736
- arguments.</p>
737
-
738
- <p>For example:</p>
739
-
740
- <pre class="ruby"><span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">parse_args</span>(<span class="ruby-string">&#39;echo &quot;Hello World!&quot;&#39;</span>)
741
- <span class="ruby-comment"># =&gt; &#39; [&quot;echo&quot;, &quot;Hello World!&quot;]</span>
742
- </pre>
720
+ <p>Default action parsing strategy.</p>
743
721
 
744
722
 
745
723
 
746
724
 
747
- <div class="method-source-code" id="parse_args-source">
748
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 271</span>
749
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse_args</span>(<span class="ruby-identifier">line</span>)
750
- <span class="ruby-comment"># col_sep must be a regex because String.split has a special case for</span>
751
- <span class="ruby-comment"># a single space char (&#39; &#39;) that produced unexpected results (i.e.</span>
752
- <span class="ruby-comment"># if line is &#39;&quot;a b&quot;&#39; the resulting array contains [&quot;a b&quot;]).</span>
753
- <span class="ruby-comment">#</span>
754
- <span class="ruby-comment"># ...but... </span>
755
- <span class="ruby-comment">#</span>
756
- <span class="ruby-comment"># CSV expects col_sep to be a string so we need to work some dark magic</span>
757
- <span class="ruby-comment"># here. Basically we proxy the StringIO received by CSV to returns</span>
758
- <span class="ruby-comment"># strings for which the split method does not fold the whitespaces.</span>
759
- <span class="ruby-comment">#</span>
760
- <span class="ruby-keyword">return</span> [] <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&#39;</span>
761
- <span class="ruby-constant">CSV</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">StringIOProxy</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>), { <span class="ruby-value">:col_sep</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39; &#39;</span> })
762
- .<span class="ruby-identifier">shift</span>
763
- .<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> }
725
+ <div class="method-source-code" id="parse_action_default-source">
726
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 337</span>
727
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse_action_default</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">file</span> = <span class="ruby-string">&#39;&lt;unknown&gt;&#39;</span>, <span class="ruby-identifier">line</span> = <span class="ruby-value">0</span>)
728
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39; &#39;</span>, <span class="ruby-value">2</span>)
729
+ <span class="ruby-keyword">begin</span>
730
+ <span class="ruby-identifier">args_text</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">strip</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>
731
+ <span class="ruby-identifier">args</span> = []
732
+
733
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args_text</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&#39;</span>
734
+ <span class="ruby-comment"># col_sep must be a regex because String.split has a</span>
735
+ <span class="ruby-comment"># special case for a single space char (&#39; &#39;) that produced</span>
736
+ <span class="ruby-comment"># unexpected results (i.e. if line is &#39;&quot;a b&quot;&#39; the</span>
737
+ <span class="ruby-comment"># resulting array contains [&quot;a b&quot;]).</span>
738
+ <span class="ruby-comment">#</span>
739
+ <span class="ruby-comment"># ...but... </span>
740
+ <span class="ruby-comment">#</span>
741
+ <span class="ruby-comment"># CSV expects col_sep to be a string so we need to work</span>
742
+ <span class="ruby-comment"># some dark magic here. Basically we proxy the StringIO</span>
743
+ <span class="ruby-comment"># received by CSV to returns strings for which the split</span>
744
+ <span class="ruby-comment"># method does not fold the whitespaces.</span>
745
+ <span class="ruby-comment">#</span>
746
+ <span class="ruby-identifier">args</span> = <span class="ruby-constant">CSV</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">StringIOProxy</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args_text</span>), { <span class="ruby-value">:col_sep</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39; &#39;</span> })
747
+ .<span class="ruby-identifier">shift</span>
748
+ .<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> } <span class="ruby-operator">||</span> []
749
+ <span class="ruby-keyword">end</span>
750
+
751
+ {
752
+ <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>,
753
+ <span class="ruby-value">:args</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>
754
+ }
755
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
756
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{file} (line #{line+1}): #{e.message}&quot;</span>
757
+ <span class="ruby-keyword">end</span>
764
758
  <span class="ruby-keyword">end</span></pre>
765
759
  </div>
766
760
 
@@ -797,7 +791,7 @@ arguments.</p>
797
791
 
798
792
 
799
793
  <div class="method-source-code" id="wait-source">
800
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 364</span>
794
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 308</span>
801
795
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">wait</span>
802
796
  <span class="ruby-constant">Readline</span>.<span class="ruby-identifier">readline</span>(<span class="ruby-string">&quot;Press ENTER to continue\n&quot;</span>)
803
797
  <span class="ruby-keyword">end</span></pre>
@@ -819,11 +813,45 @@ arguments.</p>
819
813
  </header>
820
814
 
821
815
 
816
+ <div id="method-i-add_alias" class="method-detail ">
817
+
818
+ <div class="method-heading">
819
+ <span class="method-name">add_alias</span><span
820
+ class="method-args">(name, action, args)</span>
821
+
822
+ <span class="method-click-advice">click to toggle source</span>
823
+
824
+ </div>
825
+
826
+
827
+ <div class="method-description">
828
+
829
+ <p>Adds an alias named <code>name</code> to the specified <code>action</code>
830
+ with the arguments specified in <code>args</code>.</p>
831
+
832
+
833
+
834
+
835
+ <div class="method-source-code" id="add_alias-source">
836
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 331</span>
837
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">add_alias</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>)
838
+ <span class="ruby-ivar">@aliases</span>[<span class="ruby-identifier">name</span>] = { <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">action</span>, <span class="ruby-value">:args</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span> }
839
+ <span class="ruby-keyword">end</span></pre>
840
+ </div>
841
+
842
+ </div>
843
+
844
+
845
+
846
+
847
+ </div>
848
+
849
+
822
850
  <div id="method-i-exec_action" class="method-detail ">
823
851
 
824
852
  <div class="method-heading">
825
853
  <span class="method-name">exec_action</span><span
826
- class="method-args">(action, log = true)</span>
854
+ class="method-args">(text, log = true, file = '<unknown>', line = 0)</span>
827
855
 
828
856
  <span class="method-click-advice">click to toggle source</span>
829
857
 
@@ -832,16 +860,15 @@ arguments.</p>
832
860
 
833
861
  <div class="method-description">
834
862
 
835
- <p>Executes the specified action handling errors, logging and debug history.
836
- Actions can be obtained by calling parse_action.</p>
863
+ <p>Executes the specified action string handling errors, logging and debug
864
+ history.</p>
837
865
 
838
866
  <p>If <code>log</code> is <code>true</code>, log the action execution (default
839
867
  behavior).</p>
840
868
 
841
869
  <p>For example:</p>
842
870
 
843
- <pre class="ruby"><span class="ruby-identifier">action</span> = <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">parse_action</span>(<span class="ruby-string">&#39;open &quot;http://www.ruby-lang.org&quot;&#39;</span>)
844
- <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">exec_action</span> <span class="ruby-identifier">action</span>
871
+ <pre class="ruby"><span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">exec_action</span> <span class="ruby-string">&#39;open &quot;http://www.ruby-lang.org&quot;&#39;</span>
845
872
  <span class="ruby-comment"># =&gt; navigates to www.ruby-lang.org</span>
846
873
  </pre>
847
874
 
@@ -849,32 +876,51 @@ behavior).</p>
849
876
 
850
877
 
851
878
  <div class="method-source-code" id="exec_action-source">
852
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 216</span>
853
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">exec_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">log</span> = <span class="ruby-keyword">true</span>)
854
- <span class="ruby-keyword">if</span> (<span class="ruby-identifier">action</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>)
855
- <span class="ruby-identifier">action</span> = { <span class="ruby-value">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">action</span>, <span class="ruby-value">:file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;&lt;unknown&gt;&#39;</span>, <span class="ruby-value">:line</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> }
856
- <span class="ruby-keyword">end</span>
879
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 215</span>
880
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">exec_action</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">log</span> = <span class="ruby-keyword">true</span>, <span class="ruby-identifier">file</span> = <span class="ruby-string">&#39;&lt;unknown&gt;&#39;</span>, <span class="ruby-identifier">line</span> = <span class="ruby-value">0</span>)
881
+ <span class="ruby-identifier">data</span> = <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">parse_action_default</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>)
882
+ <span class="ruby-identifier">_exec_parsed_action</span>(<span class="ruby-identifier">data</span>[<span class="ruby-value">:action</span>], <span class="ruby-identifier">data</span>[<span class="ruby-value">:args</span>], <span class="ruby-identifier">text</span>, <span class="ruby-identifier">log</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>)
883
+ <span class="ruby-keyword">end</span></pre>
884
+ </div>
885
+
886
+ </div>
887
+
857
888
 
858
- <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">handle_errors</span>(<span class="ruby-keyword">true</span>) <span class="ruby-keyword">do</span>
859
889
 
860
- <span class="ruby-identifier">action</span> = <span class="ruby-identifier">_load_action</span>(<span class="ruby-identifier">action</span>)
890
+
891
+ </div>
861
892
 
862
- <span class="ruby-comment"># Inject built-in variables</span>
863
- <span class="ruby-identifier">file</span> = <span class="ruby-identifier">action</span>.<span class="ruby-identifier">file</span>
864
- <span class="ruby-identifier">dir</span> = (<span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span> <span class="ruby-identifier">file</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">file</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
865
- <span class="ruby-ivar">@variables</span>[<span class="ruby-string">&#39;__FILE__&#39;</span>] = <span class="ruby-identifier">file</span>
866
- <span class="ruby-ivar">@variables</span>[<span class="ruby-string">&#39;__DIR__&#39;</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">absolute_path</span>(<span class="ruby-identifier">dir</span>)
867
-
868
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">log</span>
869
- <span class="ruby-ivar">@logger</span>.<span class="ruby-identifier">log_cmd</span>(<span class="ruby-identifier">action</span>) <span class="ruby-keyword">do</span>
870
- <span class="ruby-constant">Readline</span><span class="ruby-operator">::</span><span class="ruby-constant">HISTORY</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">action</span>.<span class="ruby-identifier">text</span>
871
- <span class="ruby-identifier">action</span>.<span class="ruby-identifier">execute</span>
872
- <span class="ruby-keyword">end</span>
873
- <span class="ruby-keyword">else</span>
874
- <span class="ruby-identifier">action</span>.<span class="ruby-identifier">execute</span>
875
- <span class="ruby-keyword">end</span>
893
+
894
+ <div id="method-i-exec_file" class="method-detail ">
895
+
896
+ <div class="method-heading">
897
+ <span class="method-name">exec_file</span><span
898
+ class="method-args">(file)</span>
899
+
900
+ <span class="method-click-advice">click to toggle source</span>
901
+
902
+ </div>
903
+
904
+
905
+ <div class="method-description">
906
+
907
+ <p>Executes the specified <code>file</code>.</p>
908
+
909
+ <p>For example:</p>
910
+
911
+ <pre class="ruby"><span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">exec_file</span>(<span class="ruby-string">&#39;file&#39;</span>)
912
+ <span class="ruby-comment"># =&gt; executes every action defined in &#39;file&#39;</span>
913
+ </pre>
914
+
915
+
916
+
917
+
918
+ <div class="method-source-code" id="exec_file-source">
919
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 226</span>
920
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">exec_file</span>(<span class="ruby-identifier">file</span>)
921
+ <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">text</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
922
+ <span class="ruby-identifier">_exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">text</span>, <span class="ruby-keyword">true</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>)
876
923
  <span class="ruby-keyword">end</span>
877
- <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value">:call</span> <span class="ruby-comment"># delayed actions (after log_cmd)</span>
878
924
  <span class="ruby-keyword">end</span></pre>
879
925
  </div>
880
926
 
@@ -925,7 +971,7 @@ handler will not exit after printing the error message.</p>
925
971
 
926
972
 
927
973
  <div class="method-source-code" id="handle_errors-source">
928
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 307</span>
974
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 251</span>
929
975
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">handle_errors</span>(<span class="ruby-identifier">break_into_debug</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">exit_on_error</span> = <span class="ruby-keyword">true</span>)
930
976
  <span class="ruby-keyword">yield</span>
931
977
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
@@ -957,51 +1003,6 @@ handler will not exit after printing the error message.</p>
957
1003
 
958
1004
 
959
1005
 
960
- </div>
961
-
962
-
963
- <div id="method-i-parse_file" class="method-detail ">
964
-
965
- <div class="method-heading">
966
- <span class="method-name">parse_file</span><span
967
- class="method-args">(file)</span>
968
-
969
- <span class="method-click-advice">click to toggle source</span>
970
-
971
- </div>
972
-
973
-
974
- <div class="method-description">
975
-
976
- <p>Parses the specified text into a test action array.</p>
977
-
978
- <p>See parse_action for more details.</p>
979
-
980
- <p>For example:</p>
981
-
982
- <pre class="ruby"><span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">parse_file</span>(<span class="ruby-string">&#39;file&#39;</span>)
983
- <span class="ruby-comment"># =&gt; [ { :cmd =&gt; &#39;echo&#39;, ... } ]</span>
984
- </pre>
985
-
986
-
987
-
988
-
989
- <div class="method-source-code" id="parse_file-source">
990
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 251</span>
991
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_file</span>(<span class="ruby-identifier">file</span>)
992
- <span class="ruby-keyword">if</span> (<span class="ruby-identifier">file</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;stdin&#39;</span>)
993
- <span class="ruby-identifier">_parse_file</span>(<span class="ruby-identifier">$stdin</span>, <span class="ruby-identifier">file</span>)
994
- <span class="ruby-keyword">else</span>
995
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_parse_file</span>(<span class="ruby-identifier">io</span>, <span class="ruby-identifier">file</span>) }
996
- <span class="ruby-keyword">end</span>
997
- <span class="ruby-keyword">end</span></pre>
998
- </div>
999
-
1000
- </div>
1001
-
1002
-
1003
-
1004
-
1005
1006
  </div>
1006
1007
 
1007
1008
 
@@ -1035,7 +1036,7 @@ to execute the block itself.</p>
1035
1036
 
1036
1037
 
1037
1038
  <div class="method-source-code" id="with_timeout-source">
1038
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 343</span>
1039
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 287</span>
1039
1040
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">with_timeout</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">error_types</span>)
1040
1041
  <span class="ruby-identifier">stime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
1041
1042
  <span class="ruby-identifier">timeout</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">stime</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@variables</span>[<span class="ruby-string">&#39;__TIMEOUT__&#39;</span>]
@@ -1116,7 +1117,7 @@ to execute the block itself.</p>
1116
1117
 
1117
1118
 
1118
1119
  <div class="method-source-code" id="action_args-source">
1119
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 404</span>
1120
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 390</span>
1120
1121
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">action_args</span>(<span class="ruby-identifier">action</span>)
1121
1122
  <span class="ruby-identifier">action</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&#39;_action&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">_action_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">action</span>
1122
1123
  <span class="ruby-constant">Action</span>.<span class="ruby-identifier">public_instance_method</span>(<span class="ruby-identifier">action</span>).<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">att</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span> }
@@ -1156,7 +1157,7 @@ to execute the block itself.</p>
1156
1157
 
1157
1158
 
1158
1159
  <div class="method-source-code" id="actions-source">
1159
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 394</span>
1160
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 380</span>
1160
1161
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">actions</span>
1161
1162
  <span class="ruby-identifier">_action_methods</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/_action$/</span>, <span class="ruby-string">&#39;&#39;</span>) }
1162
1163
  <span class="ruby-keyword">end</span></pre>
@@ -1195,7 +1196,7 @@ to execute the block itself.</p>
1195
1196
 
1196
1197
 
1197
1198
  <div class="method-source-code" id="loggers-source">
1198
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 433</span>
1199
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 419</span>
1199
1200
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">loggers</span>
1200
1201
  <span class="ruby-constant">Loggers</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/logger$/</span>, <span class="ruby-string">&#39;&#39;</span>) }
1201
1202
  <span class="ruby-keyword">end</span></pre>
@@ -1237,7 +1238,7 @@ to execute the block itself.</p>
1237
1238
 
1238
1239
 
1239
1240
  <div class="method-source-code" id="max_action_name_size-source">
1240
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 445</span>
1241
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 443</span>
1241
1242
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">max_action_name_size</span>
1242
1243
  <span class="ruby-identifier">actions</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">s</span> }
1243
1244
  <span class="ruby-keyword">end</span></pre>
@@ -1248,6 +1249,46 @@ to execute the block itself.</p>
1248
1249
 
1249
1250
 
1250
1251
 
1252
+ </div>
1253
+
1254
+
1255
+ <div id="method-c-parsers" class="method-detail ">
1256
+
1257
+ <div class="method-heading">
1258
+ <span class="method-name">parsers</span><span
1259
+ class="method-args">()</span>
1260
+
1261
+ <span class="method-click-advice">click to toggle source</span>
1262
+
1263
+ </div>
1264
+
1265
+
1266
+ <div class="method-description">
1267
+
1268
+ <p>Returns an array with the names of every parser available.</p>
1269
+
1270
+ <p>For example:</p>
1271
+
1272
+ <pre class="ruby"><span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">parsers</span>
1273
+ <span class="ruby-comment"># =&gt; [ &quot;default&quot;, &quot;html&quot;, ... ]</span>
1274
+ </pre>
1275
+
1276
+
1277
+
1278
+
1279
+ <div class="method-source-code" id="parsers-source">
1280
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 429</span>
1281
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parsers</span>
1282
+ (<span class="ruby-constant">Parser</span>.<span class="ruby-identifier">public_instance_methods</span>(<span class="ruby-keyword">false</span>) <span class="ruby-operator">-</span> <span class="ruby-constant">ParserModule</span>.<span class="ruby-identifier">public_instance_methods</span>(<span class="ruby-keyword">false</span>))
1283
+ .<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">to_s</span> }
1284
+ <span class="ruby-keyword">end</span></pre>
1285
+ </div>
1286
+
1287
+ </div>
1288
+
1289
+
1290
+
1291
+
1251
1292
  </div>
1252
1293
 
1253
1294
 
@@ -1280,7 +1321,7 @@ custom selectors are returned.</p>
1280
1321
 
1281
1322
 
1282
1323
  <div class="method-source-code" id="selectors-source">
1283
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 419</span>
1324
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 405</span>
1284
1325
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">selectors</span>(<span class="ruby-identifier">include_standard_selectors</span> = <span class="ruby-keyword">true</span>)
1285
1326
  <span class="ruby-identifier">ret</span> = <span class="ruby-constant">Selector</span>.<span class="ruby-identifier">public_instance_methods</span>(<span class="ruby-keyword">false</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/_selector$/</span>, <span class="ruby-string">&#39;&#39;</span>) }
1286
1327
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">include_standard_selectors</span>
@@ -1362,7 +1403,7 @@ with the corresponding variable value.</p>
1362
1403
 
1363
1404
 
1364
1405
  <div class="method-source-code" id="expand-source">
1365
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 466</span>
1406
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 464</span>
1366
1407
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">expand</span>(<span class="ruby-identifier">s</span>)
1367
1408
  <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">s</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">kv</span><span class="ruby-operator">|</span>
1368
1409
  <span class="ruby-identifier">s</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/\$\{#{kv[0]}\}/</span>, <span class="ruby-identifier">kv</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_s</span>)
@@ -1415,7 +1456,7 @@ variables is restored.</p>
1415
1456
 
1416
1457
 
1417
1458
  <div class="method-source-code" id="with_vars-source">
1418
- <pre><span class="ruby-comment"># File lib/bauxite/core/Context.rb, line 489</span>
1459
+ <pre><span class="ruby-comment"># File lib/bauxite/core/context.rb, line 487</span>
1419
1460
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">with_vars</span>(<span class="ruby-identifier">vars</span>)
1420
1461
  <span class="ruby-identifier">current</span> = <span class="ruby-ivar">@variables</span>
1421
1462
  <span class="ruby-ivar">@variables</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">vars</span>)
@@ -1441,7 +1482,7 @@ variables is restored.</p>
1441
1482
 
1442
1483
  <footer id="validator-badges" role="contentinfo">
1443
1484
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
1444
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
1485
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
1445
1486
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
1446
1487
  </footer>
1447
1488
 
@@ -101,7 +101,7 @@
101
101
 
102
102
  <footer id="validator-badges" role="contentinfo">
103
103
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
104
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
104
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
105
105
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
106
106
  </footer>
107
107