jarib-celerity 0.0.6.10 → 0.0.6.11

Sign up to get free protection for your applications and to get access to all the features.
data/lib/celerity.rb CHANGED
@@ -18,9 +18,18 @@ module Celerity
18
18
 
19
19
  @index_offset = 1
20
20
  class << self
21
- attr_accessor :index_offset
21
+
22
+ #
23
+ # This index_offset attribute controls the indexing used when locating
24
+ # elements by :index or fetching from Celerity::ElementCollections.
25
+ #
26
+ # By default it is set to 1 for Watir compatibility, but users who use
27
+ # Celerity exlusively may want it set to 0 to make Celerity more consistent with Ruby.
28
+ #
29
+ def index_offset=(n) @index_offset = n end
30
+ def index_offset() @index_offset end
22
31
  end
23
-
32
+
24
33
  DIR = File.expand_path(File.dirname(__FILE__) + "/celerity")
25
34
  end
26
35
 
@@ -56,8 +56,9 @@ module Celerity
56
56
  unless (render_types = [:html, :xml, nil]).include?(opts[:render])
57
57
  raise ArgumentError, "expected one of #{render_types.inspect} for key :render"
58
58
  end
59
-
60
- @options = opts.dup # for ClickableElement#click_and_attach
59
+
60
+ opts = opts.dup # we'll delete from opts, so dup to avoid side effects
61
+ @options = opts.dup # keep the unmodified version around as well
61
62
 
62
63
  @render_type = opts.delete(:render) || :html
63
64
  @charset = opts.delete(:charset) || "UTF-8"
@@ -407,12 +408,16 @@ module Celerity
407
408
  #
408
409
 
409
410
  def wait_until(timeout = 30, &block)
411
+ returned = nil
412
+
410
413
  Timeout.timeout(timeout) do
411
- until yield(self)
414
+ until returned = yield(self)
412
415
  refresh_page_from_window
413
416
  sleep 0.1
414
417
  end
415
418
  end
419
+
420
+ returned
416
421
  end
417
422
 
418
423
  #
@@ -424,12 +429,16 @@ module Celerity
424
429
  #
425
430
 
426
431
  def wait_while(timeout = 30, &block)
432
+ returned = nil
433
+
427
434
  Timeout.timeout(timeout) do
428
- while yield(self)
435
+ while returned = yield(self)
429
436
  refresh_page_from_window
430
437
  sleep 0.1
431
438
  end
432
439
  end
440
+
441
+ returned
433
442
  end
434
443
 
435
444
  #
@@ -471,21 +480,18 @@ module Celerity
471
480
  # Start or stop HtmlUnit's DebuggingWebConnection. (Celerity only)
472
481
  # The output will go to /tmp/«name»
473
482
  #
474
- # @param [Boolean] bool start or stop
475
- # @param [String] name required if bool is true
483
+ # @param [String] name directory name
484
+ # @param [block] blk block to execute
476
485
  #
477
486
 
478
- def debug_web_connection(bool, name = nil)
479
- if bool
480
- raise "no name given" unless name
481
- @old_webconnection = @webclient.getWebConnection
482
- dwc = HtmlUnit::Util::DebuggingWebConnection.new(@old_webconnection, name)
483
- @webclient.setWebConnection(dwc)
484
- $stderr.puts "debug-webconnection on"
485
- else
486
- @webclient.setWebConnection(@old_webconnection) if @old_webconnection
487
- $stderr.puts "debug-webconnection off"
488
- end
487
+ def debug_web_connection(name, &blk)
488
+ old_wc = @webclient.getWebConnection
489
+
490
+ @webclient.setWebConnection HtmlUnit::Util::DebuggingWebConnection.new(old_wc, name)
491
+ res = yield
492
+ @webclient.setWebConnection old_wc
493
+
494
+ res
489
495
  end
490
496
 
491
497
  #
@@ -722,8 +728,10 @@ module Celerity
722
728
  browser = (opts.delete(:browser) || :firefox).to_sym
723
729
 
724
730
  case browser
725
- when :firefox, :ff
731
+ when :firefox, :ff, :ff2
726
732
  browser_version = ::HtmlUnit::BrowserVersion::FIREFOX_2
733
+ when :firefox3, :ff3
734
+ browser_version = ::HtmlUnit::BrowserVersion::FIREFOX_3
727
735
  when :internet_explorer, :ie
728
736
  browser_version = ::HtmlUnit::BrowserVersion::INTERNET_EXPLORER_7
729
737
  else
@@ -52,6 +52,7 @@ module Celerity
52
52
  end
53
53
 
54
54
  @conditions.freeze
55
+ @object = nil
55
56
  end
56
57
 
57
58
  #
@@ -3,7 +3,7 @@ module Celerity #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
5
  TINY = 6
6
- PATCH = 10 # Set to nil for official release
6
+ PATCH = 11 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarib-celerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.10
4
+ version: 0.0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-06-13 00:00:00 -07:00
14
+ date: 2009-06-26 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -75,7 +75,7 @@ files:
75
75
  - lib/celerity/htmlunit/commons-logging-1.1.1.jar
76
76
  - lib/celerity/htmlunit/cssparser-0.9.5.jar
77
77
  - lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar
78
- - lib/celerity/htmlunit/htmlunit-core-js-2.5.jar
78
+ - lib/celerity/htmlunit/htmlunit-core-js-2.6-SNAPSHOT.jar
79
79
  - lib/celerity/htmlunit/nekohtml-1.9.13-20090507.082850-2.jar
80
80
  - lib/celerity/htmlunit/sac-1.3.jar
81
81
  - lib/celerity/htmlunit/serializer-2.7.1.jar