bauxite 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d90a3d4658ed9ac9f71ffbfc989e956009eba62
4
- data.tar.gz: fade31201508e4f84f42c166fb72434768116665
3
+ metadata.gz: 45b66aed675fe032b372046709145824f739bf72
4
+ data.tar.gz: 98ff7bbb6d5c6403673d17f74505441cb2c9cc41
5
5
  SHA512:
6
- metadata.gz: 64776eb1c7583528003712713d0ab598676d67b71b16afbf9d7fcca09c7d3747609e8869ac8be8d63450d18e771ee9f478b04f75c0195c8fc5691b6e47d42efe
7
- data.tar.gz: 9b0c620a2bd86b78622cb88065d9db7a640d962f81067449ce2aafb523b973e904c2a130e58ac497ac20e9afc8ec94d22a72f57d62fe2c2a84e12d3c4ca22733
6
+ metadata.gz: 144ae5211549b179126d1b283d64a508b7af92e4bccb56f8fdedad1dbd5a3635d2ca1b3628008f186ecc53c167d00a9e9f18cc90f8253ec5fa3b9940e85b0478
7
+ data.tar.gz: 74b2c389aa65c1b22ec7528cba3309856f0a0ca9b4080d74ad4556645054f99ac84609825a9d1be1120d3aa8acbd1ea81404ace15abec50e9750685146af2c35
@@ -1341,8 +1341,14 @@ href="Action.html#method-i-assert">assert</a> for more details):</p>
1341
1341
  <div class="method-source-code" id="return_action-source">
1342
1342
  <pre><span class="ruby-comment"># File lib/bauxite/actions/return.rb, line 58</span>
1343
1343
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">return_action</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
1344
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">vars</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&#39;*&#39;</span>]
1345
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] = <span class="ruby-identifier">vars</span>
1346
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
1347
+ <span class="ruby-keyword">end</span>
1348
+
1344
1349
  <span class="ruby-identifier">rets</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] <span class="ruby-operator">||</span> []
1345
- <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] = <span class="ruby-identifier">rets</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vars</span>
1350
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] = <span class="ruby-identifier">rets</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vars</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">rets</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&#39;*&#39;</span>
1351
+ <span class="ruby-keyword">true</span>
1346
1352
  <span class="ruby-keyword">end</span></pre>
1347
1353
  </div>
1348
1354
 
@@ -1905,7 +1911,11 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
1905
1911
  <pre><span class="ruby-comment"># File lib/bauxite/actions/write.rb, line 34</span>
1906
1912
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
1907
1913
  <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
1908
- <span class="ruby-identifier">e</span>.<span class="ruby-identifier">clear</span>
1914
+ <span class="ruby-keyword">begin</span>
1915
+ <span class="ruby-identifier">e</span>.<span class="ruby-identifier">clear</span>
1916
+ <span class="ruby-keyword">rescue</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">UnknownError</span> <span class="ruby-comment"># user-editable...</span>
1917
+ <span class="ruby-comment"># do nothing (if this should fail, it will in the line below)</span>
1918
+ <span class="ruby-keyword">end</span>
1909
1919
  <span class="ruby-identifier">e</span>.<span class="ruby-identifier">send_keys</span>(<span class="ruby-identifier">text</span>)
1910
1920
  <span class="ruby-keyword">end</span>
1911
1921
  <span class="ruby-keyword">end</span></pre>
@@ -1876,7 +1876,17 @@ variables is restored.</p>
1876
1876
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">with_vars</span>(<span class="ruby-identifier">vars</span>)
1877
1877
  <span class="ruby-identifier">current</span> = <span class="ruby-ivar">@variables</span>
1878
1878
  <span class="ruby-ivar">@variables</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">vars</span>)
1879
- <span class="ruby-keyword">yield</span>
1879
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-keyword">nil</span>
1880
+
1881
+ <span class="ruby-identifier">ret</span> = <span class="ruby-keyword">yield</span>
1882
+
1883
+ <span class="ruby-identifier">returned</span> = <span class="ruby-ivar">@variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>]
1884
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">returned</span> <span class="ruby-operator">==</span> [<span class="ruby-string">&#39;*&#39;</span>]
1885
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">clone</span>
1886
+ <span class="ruby-identifier">ret_vars</span>.<span class="ruby-identifier">delete</span> <span class="ruby-string">&#39;__RETURN__&#39;</span>
1887
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">returned</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
1888
+ <span class="ruby-identifier">ret_vars</span> = <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">returned</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">k</span> }
1889
+ <span class="ruby-keyword">end</span>
1880
1890
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1881
1891
  <span class="ruby-identifier">e</span>.<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-string">&quot;@variables&quot;</span>, <span class="ruby-ivar">@variables</span>
1882
1892
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">variables</span>
@@ -1885,6 +1895,8 @@ variables is restored.</p>
1885
1895
  <span class="ruby-identifier">raise</span>
1886
1896
  <span class="ruby-keyword">ensure</span>
1887
1897
  <span class="ruby-ivar">@variables</span> = <span class="ruby-identifier">current</span>
1898
+ <span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">ret_vars</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">ret_vars</span>
1899
+ <span class="ruby-identifier">ret</span>
1888
1900
  <span class="ruby-keyword">end</span></pre>
1889
1901
  </div>
1890
1902
 
data/doc/created.rid CHANGED
@@ -1,4 +1,4 @@
1
- Mon, 10 Feb 2014 10:59:18 -0300
1
+ Tue, 11 Feb 2014 14:16:18 -0300
2
2
  README.md Mon, 10 Feb 2014 10:55:53 -0300
3
3
  lib/bauxite/actions/js.rb Mon, 27 Jan 2014 11:02:44 -0300
4
4
  lib/bauxite/actions/exec.rb Mon, 27 Jan 2014 11:02:44 -0300
@@ -10,14 +10,14 @@ lib/bauxite/actions/ruby.rb Mon, 27 Jan 2014 11:02:44 -0300
10
10
  lib/bauxite/actions/store.rb Mon, 27 Jan 2014 11:02:44 -0300
11
11
  lib/bauxite/actions/assertv.rb Mon, 27 Jan 2014 11:02:44 -0300
12
12
  lib/bauxite/actions/alias.rb Mon, 27 Jan 2014 11:02:44 -0300
13
- lib/bauxite/actions/tryload.rb Mon, 10 Feb 2014 09:50:17 -0300
13
+ lib/bauxite/actions/tryload.rb Tue, 11 Feb 2014 14:10:05 -0300
14
14
  lib/bauxite/actions/test.rb Tue, 04 Feb 2014 13:02:27 -0300
15
15
  lib/bauxite/actions/load.rb Mon, 27 Jan 2014 11:02:44 -0300
16
16
  lib/bauxite/actions/submit.rb Tue, 28 Jan 2014 16:05:51 -0300
17
17
  lib/bauxite/actions/open.rb Wed, 29 Jan 2014 09:10:40 -0300
18
18
  lib/bauxite/actions/reset.rb Mon, 27 Jan 2014 11:02:44 -0300
19
19
  lib/bauxite/actions/capture.rb Mon, 10 Feb 2014 09:50:17 -0300
20
- lib/bauxite/actions/write.rb Mon, 27 Jan 2014 11:02:44 -0300
20
+ lib/bauxite/actions/write.rb Mon, 10 Feb 2014 18:14:54 -0300
21
21
  lib/bauxite/actions/failif.rb Tue, 04 Feb 2014 11:03:59 -0300
22
22
  lib/bauxite/actions/setif.rb Tue, 04 Feb 2014 11:05:42 -0300
23
23
  lib/bauxite/actions/replace.rb Mon, 27 Jan 2014 11:02:44 -0300
@@ -26,14 +26,14 @@ lib/bauxite/actions/echo.rb Mon, 27 Jan 2014 11:02:44 -0300
26
26
  lib/bauxite/actions/set.rb Mon, 27 Jan 2014 11:02:44 -0300
27
27
  lib/bauxite/actions/params.rb Mon, 27 Jan 2014 11:02:44 -0300
28
28
  lib/bauxite/actions/debug.rb Tue, 04 Feb 2014 14:06:05 -0300
29
- lib/bauxite/actions/return.rb Mon, 27 Jan 2014 11:02:44 -0300
29
+ lib/bauxite/actions/return.rb Tue, 11 Feb 2014 14:10:05 -0300
30
30
  lib/bauxite/actions/click.rb Mon, 10 Feb 2014 10:46:11 -0300
31
31
  lib/bauxite/actions/doif.rb Mon, 03 Feb 2014 11:48:07 -0300
32
32
  lib/bauxite/actions/source.rb Mon, 27 Jan 2014 11:02:44 -0300
33
33
  lib/bauxite/actions/break.rb Mon, 27 Jan 2014 11:02:44 -0300
34
34
  lib/bauxite/core/selector.rb Wed, 29 Jan 2014 09:10:40 -0300
35
35
  lib/bauxite/core/errors.rb Mon, 27 Jan 2014 11:02:44 -0300
36
- lib/bauxite/core/context.rb Mon, 10 Feb 2014 09:50:17 -0300
36
+ lib/bauxite/core/context.rb Tue, 11 Feb 2014 14:10:05 -0300
37
37
  lib/bauxite/core/parser.rb Tue, 28 Jan 2014 16:48:43 -0300
38
38
  lib/bauxite/core/action.rb Wed, 05 Feb 2014 12:11:16 -0300
39
39
  lib/bauxite/core/logger.rb Wed, 05 Feb 2014 12:11:16 -0300
@@ -56,7 +56,13 @@ class Bauxite::Action
56
56
  #
57
57
  # :category: Action Methods
58
58
  def return_action(*vars)
59
+ if vars == ['*']
60
+ @ctx.variables['__RETURN__'] = vars
61
+ return true
62
+ end
63
+
59
64
  rets = @ctx.variables['__RETURN__'] || []
60
- @ctx.variables['__RETURN__'] = rets + vars
65
+ @ctx.variables['__RETURN__'] = rets + vars unless rets.include? '*'
66
+ true
61
67
  end
62
68
  end
@@ -65,17 +65,7 @@ private
65
65
  end
66
66
 
67
67
  lambda do
68
- ret_vars = nil
69
- @ctx.with_vars var_hash do
70
- yield file
71
- rets = @ctx.variables['__RETURN__']
72
- if rets == ['*']
73
- ret_vars = @ctx.variables
74
- elsif rets != nil
75
- ret_vars = @ctx.variables.select { |k,v| rets.include? k }
76
- end
77
- end
78
- @ctx.variables.merge!(ret_vars) if ret_vars
68
+ @ctx.with_vars(var_hash) { yield file }
79
69
  end
80
70
  end
81
71
  end
@@ -33,7 +33,11 @@ class Bauxite::Action
33
33
  # :category: Action Methods
34
34
  def write(selector, text)
35
35
  @ctx.find(selector) do |e|
36
- e.clear
36
+ begin
37
+ e.clear
38
+ rescue Selenium::WebDriver::Error::UnknownError # user-editable...
39
+ # do nothing (if this should fail, it will in the line below)
40
+ end
37
41
  e.send_keys(text)
38
42
  end
39
43
  end
@@ -710,7 +710,17 @@ module Bauxite
710
710
  def with_vars(vars)
711
711
  current = @variables
712
712
  @variables = @variables.merge(vars)
713
- yield
713
+ ret_vars = nil
714
+
715
+ ret = yield
716
+
717
+ returned = @variables['__RETURN__']
718
+ if returned == ['*']
719
+ ret_vars = @variables.clone
720
+ ret_vars.delete '__RETURN__'
721
+ elsif returned != nil
722
+ ret_vars = @variables.select { |k,v| returned.include? k }
723
+ end
714
724
  rescue StandardError => e
715
725
  e.instance_variable_set "@variables", @variables
716
726
  def e.variables
@@ -719,6 +729,8 @@ module Bauxite
719
729
  raise
720
730
  ensure
721
731
  @variables = current
732
+ @variables.merge!(ret_vars) if ret_vars
733
+ ret
722
734
  end
723
735
 
724
736
  private
data/lib/bauxite.rb CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  #--
24
24
  module Bauxite
25
- VERSION = "0.6.7"
25
+ VERSION = "0.6.8"
26
26
  end
27
27
  #++
28
28
 
@@ -0,0 +1,2 @@
1
+ load f2.bxt
2
+ return my_var
@@ -0,0 +1,2 @@
1
+ load f3.bxt
2
+ return *
@@ -0,0 +1,2 @@
1
+ load f4.bxt
2
+ return *
@@ -0,0 +1,2 @@
1
+ set my_var my_value
2
+ return my_var
data/test/return.bxt ADDED
@@ -0,0 +1,2 @@
1
+ load return/f1.bxt
2
+ assertv "my_value" "${my_var}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bauxite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Zavolinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -209,6 +209,11 @@ files:
209
209
  - test/parsers.csv
210
210
  - test/parsers.html
211
211
  - test/parsers/page.html
212
+ - test/return.bxt
213
+ - test/return/f1.bxt
214
+ - test/return/f2.bxt
215
+ - test/return/f3.bxt
216
+ - test/return/f4.bxt
212
217
  - test/ruby.bxt
213
218
  - test/ruby/custom.rb
214
219
  - test/select.bxt