jarib-celerity 0.0.6.3 → 0.0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/celerity.rb CHANGED
@@ -29,6 +29,7 @@ require "celerity/element_collection"
29
29
  require "celerity/collections"
30
30
  require "celerity/element_locator"
31
31
  require "celerity/identifier"
32
+ require "celerity/short_inspect"
32
33
  require "celerity/container"
33
34
  require "celerity/element"
34
35
  require "celerity/input_element"
@@ -7,10 +7,10 @@ module Celerity
7
7
 
8
8
  #
9
9
  # Initialize a browser and go to the given URL
10
- #
10
+ #
11
11
  # @param [String] uri The URL to go to.
12
12
  # @return [Celerity::Browser] instance.
13
- #
13
+ #
14
14
 
15
15
  def self.start(uri)
16
16
  browser = new
@@ -27,9 +27,7 @@ module Celerity
27
27
  end
28
28
 
29
29
  def inspect
30
- vars = (instance_variables - %w[@webclient @browser @object])
31
- vars = vars.map { |var| "#{var}=#{instance_variable_get(var).inspect}" }.join(" ")
32
- '#<%s:0x%s %s>' % [self.class.name, self.hash.to_s(16), vars]
30
+ short_inspect :exclude => %w[@webclient @browser @object]
33
31
  end
34
32
 
35
33
  #
@@ -71,7 +69,7 @@ module Celerity
71
69
  @browser = self # for Container#browser
72
70
 
73
71
  setup_webclient(opts)
74
-
72
+
75
73
  raise ArgumentError, "unknown option #{opts.inspect}" unless opts.empty?
76
74
  find_viewer
77
75
  end
@@ -123,7 +121,7 @@ module Celerity
123
121
 
124
122
  #
125
123
  # @return [String] the URL of the current page
126
- #
124
+ #
127
125
 
128
126
  def url
129
127
  assert_exists
@@ -141,15 +139,15 @@ module Celerity
141
139
  #
142
140
  # @return [String] the HTML content of the current page
143
141
  #
144
-
142
+
145
143
  def html
146
144
  @page ? @page.getWebResponse.getContentAsString : ''
147
145
  end
148
-
146
+
149
147
  #
150
148
  # @return [String] the XML representation of the DOM
151
149
  #
152
-
150
+
153
151
  def xml
154
152
  return '' unless @page
155
153
  return @page.asXml if @page.respond_to?(:asXml)
@@ -159,7 +157,7 @@ module Celerity
159
157
  #
160
158
  # @return [String] a text representation of the current page
161
159
  #
162
-
160
+
163
161
  def text
164
162
  return '' unless @page
165
163
 
@@ -179,14 +177,14 @@ module Celerity
179
177
 
180
178
  def response_headers
181
179
  return {} unless @page
182
-
180
+
183
181
  Hash[*@page.getWebResponse.getResponseHeaders.map { |obj| [obj.name, obj.value] }.flatten]
184
182
  end
185
-
183
+
186
184
  #
187
185
  # @return [Fixnum] status code of the last request
188
186
  #
189
-
187
+
190
188
  def status_code
191
189
  @page.getWebResponse.getStatusCode
192
190
  end
@@ -197,17 +195,17 @@ module Celerity
197
195
 
198
196
  def content_type
199
197
  return '' unless @page
200
-
198
+
201
199
  @page.getWebResponse.getContentType
202
200
  end
203
-
201
+
204
202
  #
205
203
  # @return [IO, nil] page contents as an IO, returns nil if no page is loaded.
206
- #
207
-
204
+ #
205
+
208
206
  def io
209
207
  return nil unless @page
210
-
208
+
211
209
  @page.getWebResponse.getContentAsStream.to_io
212
210
  end
213
211
 
@@ -217,7 +215,7 @@ module Celerity
217
215
  # @param [String, Regexp] expected_text The text to look for.
218
216
  # @return [Numeric, nil] The index of the matched text, or nil if it isn't found.
219
217
  # @raise [TypeError]
220
- #
218
+ #
221
219
 
222
220
  def contains_text(expected_text)
223
221
  return nil unless exist?
@@ -230,7 +228,7 @@ module Celerity
230
228
  # @param [String] xpath
231
229
  # @return [Celerity::Element] An element subclass (or Element if none is found)
232
230
  #
233
-
231
+
234
232
  def element_by_xpath(xpath)
235
233
  assert_exists
236
234
  obj = @page.getFirstByXPath(xpath)
@@ -243,7 +241,7 @@ module Celerity
243
241
  # @param [String] xpath
244
242
  # @return [Array<Celerity::Element>] array of elements
245
243
  #
246
-
244
+
247
245
  def elements_by_xpath(xpath)
248
246
  assert_exists
249
247
  objects = @page.getByXPath(xpath)
@@ -253,8 +251,8 @@ module Celerity
253
251
 
254
252
  #
255
253
  # @return [HtmlUnit::HtmlHtml] the underlying HtmlUnit document.
256
- #
257
-
254
+ #
255
+
258
256
  def document
259
257
  @object
260
258
  end
@@ -262,7 +260,7 @@ module Celerity
262
260
  #
263
261
  # Goto the last url - HtmlUnit doesn't have a 'back' functionality, so we only have 1 history item :)
264
262
  # @return [String, nil] The url of the resulting page, or nil if none was stored.
265
- #
263
+ #
266
264
 
267
265
  def back
268
266
  # TODO: this is naive, need capability from HtmlUnit
@@ -271,7 +269,7 @@ module Celerity
271
269
 
272
270
  #
273
271
  # Wait for javascript jobs to finish
274
- #
272
+ #
275
273
 
276
274
  def wait
277
275
  assert_exists
@@ -280,7 +278,7 @@ module Celerity
280
278
 
281
279
  #
282
280
  # Refresh the current page
283
- #
281
+ #
284
282
 
285
283
  def refresh
286
284
  assert_exists
@@ -289,41 +287,49 @@ module Celerity
289
287
 
290
288
  #
291
289
  # Clears all cookies. (Celerity only)
292
- #
290
+ #
293
291
 
294
292
  def clear_cookies
295
293
  @webclient.getCookieManager.clearCookies
296
294
  end
297
295
 
296
+ #
297
+ # Clears the cache of "compiled JavaScript files and parsed CSS snippets"
298
+ #
299
+
300
+ def clear_cache
301
+ @webclient.cache.clear
302
+ end
303
+
298
304
  #
299
305
  # Get the cookies for this session. (Celerity only)
300
- #
301
- # @return [Hash<domain, Hash<name, value>>]
306
+ #
307
+ # @return [Hash<domain, Hash<name, value>>]
302
308
  #
303
309
 
304
310
  def cookies
305
311
  result = Hash.new { |hash, key| hash[key] = {} }
306
-
312
+
307
313
  cookies = @webclient.getCookieManager.getCookies
308
314
  cookies.each do |cookie|
309
315
  result[cookie.getDomain][cookie.getName] = cookie.getValue
310
316
  end
311
-
317
+
312
318
  result
313
319
  end
314
-
320
+
315
321
  #
316
322
  # Add a cookie with the given parameters (Celerity only)
317
- #
323
+ #
318
324
  # @param [String] domain
319
325
  # @param [String] name
320
326
  # @param [String] value
321
327
  #
322
- # @option opts :path [String] ("/") A path
328
+ # @option opts :path [String] ("/") A path
323
329
  # @option opts :max_age [Fixnum] (??) A max age
324
- # @option opts :secure [Boolean] (false)
330
+ # @option opts :secure [Boolean] (false)
325
331
  #
326
-
332
+
327
333
  def add_cookie(domain, name, value, opts = {})
328
334
  path = opts.delete(:path) || "/"
329
335
  max_age = opts.delete(:max_age) || (Time.now + 60*60*24) # not sure if this is correct
@@ -334,22 +340,22 @@ module Celerity
334
340
  cookie = Cookie.new(domain, name, value, path, max_age, secure)
335
341
  @webclient.getCookieManager.addCookie(cookie)
336
342
  end
337
-
343
+
338
344
  #
339
345
  # Remove the cookie with the given domain and name (Celerity only)
340
346
  #
341
347
  # @param [String] domain
342
348
  # @param [String] name
343
349
  #
344
-
350
+
345
351
  def remove_cookie(domain, name)
346
352
  cm = @webclient.getCookieManager
347
353
  cookie = cm.getCookies.find { |c| c.getDomain == domain && c.getName == name }
348
-
354
+
349
355
  if cookie.nil?
350
356
  raise "no cookie with domain #{domain.inspect} and name #{name.inspect}"
351
357
  end
352
-
358
+
353
359
  cm.removeCookie(cookie)
354
360
  end
355
361
 
@@ -386,7 +392,7 @@ module Celerity
386
392
  # @yieldparam [Celerity::Browser] browser The browser instance.
387
393
  # @see Celerity::Browser#resynchronized
388
394
  #
389
-
395
+
390
396
  def wait_until(timeout = 30, &block)
391
397
  Timeout.timeout(timeout) do
392
398
  until yield(self)
@@ -402,7 +408,7 @@ module Celerity
402
408
  # @param [Fixnum] timeout Number of seconds to wait before timing out (default: 30).
403
409
  # @yieldparam [Celerity::Browser] browser The browser instance.
404
410
  # @see Celerity::Browser#resynchronized
405
- #
411
+ #
406
412
 
407
413
  def wait_while(timeout = 30, &block)
408
414
  Timeout.timeout(timeout) do
@@ -430,15 +436,15 @@ module Celerity
430
436
  yield self
431
437
  @webclient.setAjaxController(old_controller)
432
438
  end
433
-
439
+
434
440
  #
435
441
  # Allows you to temporarliy switch to HtmlUnit's default AjaxController, so ajax calls are performed asynchronously.
436
442
  # This is useful if you have created the Browser with :resynchronize => true, but want to switch it off temporarily.
437
- #
443
+ #
438
444
  # @yieldparam [Celerity::Browser] browser The current browser object.
439
445
  # @see Celerity::Browser#new
440
446
  #
441
-
447
+
442
448
  def asynchronized(&block)
443
449
  old_controller = @webclient.ajaxController
444
450
  @webclient.setAjaxController(::HtmlUnit::AjaxController.new)
@@ -452,7 +458,7 @@ module Celerity
452
458
  #
453
459
  # @param [Boolean] bool start or stop
454
460
  # @param [String] name required if bool is true
455
- #
461
+ #
456
462
 
457
463
  def debug_web_connection(bool, name = nil)
458
464
  if bool
@@ -482,37 +488,37 @@ module Celerity
482
488
  #
483
489
  # @param [Symbol] type One of the above symbols.
484
490
  # @param [Proc] block A block to be executed for events of this type.
485
- #
491
+ #
486
492
 
487
493
  def add_listener(type, &block)
488
494
  listener.add_listener(type, &block)
489
495
  end
490
-
496
+
491
497
  #
492
498
  # Specify a boolean value to click either 'OK' or 'Cancel' in any confirm
493
- # dialogs that might show up during the duration of the given block.
494
- #
499
+ # dialogs that might show up during the duration of the given block.
500
+ #
495
501
  # (Celerity only)
496
502
  #
497
503
  # @param [Boolean] bool true to click 'OK', false to click 'cancel'
498
504
  # @param [Proc] block A block that will trigger the confirm() call(s).
499
505
  #
500
-
506
+
501
507
  def confirm(bool, &block)
502
508
  blk = lambda { bool }
503
-
509
+
504
510
  listener.add_listener(:confirm, &blk)
505
511
  yield
506
512
  listener.remove_listener(:confirm, blk)
507
513
  end
508
-
514
+
509
515
  #
510
516
  # Add a 'checker' proc that will be run on every page load
511
517
  #
512
518
  # @param [Proc] checker The proc to be run (can also be given as a block)
513
519
  # @yieldparam [Celerity::Browser] browser The current browser object.
514
520
  # @raise [ArgumentError] if no Proc or block was given.
515
- #
521
+ #
516
522
 
517
523
  def add_checker(checker = nil, &block)
518
524
  if block_given?
@@ -527,7 +533,7 @@ module Celerity
527
533
  #
528
534
  # Remove the given checker from the list of checkers
529
535
  # @param [Proc] checker The Proc to disable.
530
- #
536
+ #
531
537
 
532
538
  def disable_checker(checker)
533
539
  @error_checkers.delete(checker)
@@ -535,9 +541,9 @@ module Celerity
535
541
 
536
542
  #
537
543
  # :finest, :finer, :fine, :config, :info, :warning, :severe, or :off, :all
538
- #
544
+ #
539
545
  # @return [Symbol] the current log level
540
- #
546
+ #
541
547
 
542
548
  def log_level
543
549
  logger_for('com.gargoylesoftware.htmlunit').level.to_s.downcase.to_sym
@@ -547,13 +553,13 @@ module Celerity
547
553
  # Set Java log level (default is :warning)
548
554
  #
549
555
  # @param [Symbol] level :finest, :finer, :fine, :config, :info, :warning, :severe, or :off, :all
550
- #
556
+ #
551
557
 
552
558
  def log_level=(level)
553
559
  log_level = java.util.logging.Level.const_get(level.to_s.upcase)
554
560
 
555
561
  # loggers = [
556
- # logger_for('com.gargoylesoftware.htmlunit'),
562
+ # logger_for('com.gargoylesoftware.htmlunit'),
557
563
  # logger_for("com.gargoylesoftware.htmlunit.html.HtmlElement")
558
564
  # ]
559
565
  # loggers.each { |logger| logger.level = log_level }
@@ -570,35 +576,63 @@ module Celerity
570
576
  !!@page
571
577
  end
572
578
  alias_method :exists?, :exist?
573
-
579
+
574
580
  #
575
581
  # Turn on/off javascript exceptions
576
- #
582
+ #
577
583
  # @param [Bool]
578
- #
584
+ #
579
585
 
580
586
  def javascript_exceptions=(bool)
581
587
  @webclient.throwExceptionOnScriptError = bool
582
588
  end
583
-
589
+
584
590
  def javascript_exceptions
585
591
  @webclient.throwExceptionOnScriptError
586
592
  end
587
-
593
+
588
594
  #
589
595
  # Turn on/off status code exceptions
590
- #
596
+ #
591
597
  # @param [Bool]
592
- #
593
-
598
+ #
599
+
594
600
  def status_code_exceptions=(bool)
595
601
  @webclient.throwExceptionOnFailingStatusCode = bool
596
602
  end
597
-
603
+
598
604
  def status_code_exceptions
599
605
  @webclient.throwExceptionOnFailingStatusCode
600
606
  end
601
-
607
+
608
+ #
609
+ # Turn on/off CSS loading
610
+ #
611
+ # @param [Bool]
612
+ #
613
+
614
+ def css=(bool)
615
+ @webclient.cssEnabled = bool
616
+ end
617
+
618
+ def css
619
+ @webclient.cssEnabled
620
+ end
621
+
622
+ #
623
+ # Turn on/off secure SSL
624
+ #
625
+ # @param [Bool]
626
+ #
627
+
628
+ def secure_ssl=(bool)
629
+ @webclient.useInsecureSSL = !bool
630
+ end
631
+
632
+ def secure_ssl
633
+ !@webclient.useInsecureSSL
634
+ end
635
+
602
636
  #
603
637
  # Sets the current page object for the browser
604
638
  #
@@ -627,19 +661,19 @@ module Celerity
627
661
  #
628
662
  # @raise [Celerity::Exception::UnknownObjectException] if no page is loaded.
629
663
  # @api private
630
- #
631
-
664
+ #
665
+
632
666
  def assert_exists
633
667
  raise UnknownObjectException, "no page loaded" unless exist?
634
668
  end
635
-
669
+
636
670
  #
637
671
  # Returns the element that currently has the focus (Celerity only)
638
672
  #
639
673
 
640
674
  def focused_element
641
675
  element_from_dom_node(page.getFocusedElement())
642
- end
676
+ end
643
677
 
644
678
  private
645
679
 
@@ -648,12 +682,12 @@ module Celerity
648
682
  #
649
683
  # @see add_checker
650
684
  # @api private
651
- #
652
-
685
+ #
686
+
653
687
  def run_error_checks
654
688
  @error_checkers.each { |e| e[self] }
655
689
  end
656
-
690
+
657
691
  #
658
692
  # Configure the webclient according to the options given to #new.
659
693
  # @see initialize
@@ -675,22 +709,22 @@ module Celerity
675
709
  phost, pport = proxy.split(":")
676
710
  @webclient = ::HtmlUnit::WebClient.new(browser_version, phost, pport.to_i)
677
711
  else
678
- @webclient = ::HtmlUnit::WebClient.new(browser_version)
712
+ @webclient = ::HtmlUnit::WebClient.new(browser_version)
679
713
  end
680
-
714
+
681
715
  self.javascript_exceptions = false unless opts.delete(:javascript_exceptions)
682
716
  self.status_code_exceptions = false unless opts.delete(:status_code_exceptions)
683
- @webclient.cssEnabled = false unless opts.delete(:css)
684
- @webclient.useInsecureSSL = opts.delete(:secure_ssl) == false
717
+ self.css = false unless opts.delete(:css)
718
+ self.secure_ssl = opts.delete(:secure_ssl) == false
685
719
  @webclient.setAjaxController(::HtmlUnit::NicelyResynchronizingAjaxController.new) if opts.delete(:resynchronize)
686
720
  end
687
-
721
+
688
722
  #
689
723
  # This *should* be unneccessary, but sometimes the page we get from the
690
724
  # window is different (ie. a different object) from our current @page
691
725
  # (Used by #wait_while and #wait_until)
692
- #
693
-
726
+ #
727
+
694
728
  def refresh_page_from_window
695
729
  new_page = @page.getEnclosingWindow.getEnclosedPage
696
730
 
@@ -700,11 +734,11 @@ module Celerity
700
734
  Log.debug "unneccessary refresh"
701
735
  end
702
736
  end
703
-
737
+
704
738
  #
705
739
  # Render the current page on the viewer.
706
740
  # @api private
707
- #
741
+ #
708
742
 
709
743
  def render
710
744
  @viewer.render_html(self.send(@render_type), url)
@@ -715,7 +749,7 @@ module Celerity
715
749
  #
716
750
  # Check if we have a viewer available on druby://127.0.0.1:6429
717
751
  # @api private
718
- #
752
+ #
719
753
 
720
754
  def find_viewer
721
755
  viewer = DRbObject.new_with_uri("druby://127.0.0.1:6429")
@@ -728,10 +762,10 @@ module Celerity
728
762
  @viewer = DefaultViewer
729
763
  end
730
764
 
731
- #
765
+ #
732
766
  # Convert the given HtmlUnit object to a Celerity object
733
- #
734
-
767
+ #
768
+
735
769
  def element_from_dom_node(obj)
736
770
  if element_class = Celerity::Util.htmlunit2celerity(obj.class)
737
771
  element_class.new(self, :object, obj)
@@ -743,7 +777,7 @@ module Celerity
743
777
  def logger_for(class_string)
744
778
  java.util.logging.Logger.getLogger(class_string)
745
779
  end
746
-
780
+
747
781
  def listener
748
782
  @listener ||= Celerity::Listener.new(@webclient)
749
783
  end
@@ -1,5 +1,5 @@
1
1
  module Celerity
2
-
2
+
3
3
  #
4
4
  # This class contains methods for accessing elements inside a container,
5
5
  # usually the Browser object, meaning the current page.
@@ -30,6 +30,7 @@ module Celerity
30
30
 
31
31
  module Container
32
32
  include Celerity::Exception
33
+ include Celerity::ShortInspect
33
34
 
34
35
  # Points back to the Browser instance that contains this element
35
36
  attr_reader :browser
@@ -39,8 +40,8 @@ module Celerity
39
40
  #
40
41
  # @param [String, Regexp] expected_text The text to look for.
41
42
  # @return [Fixnum, nil] The index of the matched text, or nil if it doesn't match.
42
- #
43
-
43
+ #
44
+
44
45
  def contains_text(expected_text)
45
46
  assert_exists
46
47
  return nil unless respond_to? :text
@@ -54,12 +55,20 @@ module Celerity
54
55
  raise TypeError, "expected String or Regexp, got #{expected_text.inspect}:#{expected_text.class}"
55
56
  end
56
57
  end
57
-
58
+
59
+ #
60
+ # Override inspect for readability
61
+ #
62
+
63
+ def inspect
64
+ short_inspect :exclude => %w[@browser @container]
65
+ end
66
+
58
67
  #
59
68
  # Used internally to update the container object.
60
69
  # @api private
61
70
  #
62
-
71
+
63
72
  def container=(container)
64
73
  @container = container
65
74
  @browser = container.browser
@@ -70,11 +79,11 @@ module Celerity
70
79
  # Used internally to update the page object.
71
80
  # @api private
72
81
  #
73
-
82
+
74
83
  def update_page(page)
75
84
  @browser.page = page
76
85
  end
77
-
86
+
78
87
  #--
79
88
  # below methods sorted alphabetically
80
89
  #++
@@ -82,23 +91,23 @@ module Celerity
82
91
  #
83
92
  # @return [Celerity::Area]
84
93
  #
85
-
94
+
86
95
  def area(*args)
87
96
  Area.new(self, *args)
88
97
  end
89
-
98
+
90
99
  #
91
100
  # @return [Celerity::Areas]
92
101
  #
93
-
102
+
94
103
  def areas
95
104
  Areas.new(self)
96
105
  end
97
-
106
+
98
107
  #
99
108
  # @return [Celerity::Button]
100
109
  #
101
-
110
+
102
111
  def button(*args)
103
112
  Button.new(self, *args)
104
113
  end
@@ -106,23 +115,23 @@ module Celerity
106
115
  #
107
116
  # @return [Celerity::Buttons]
108
117
  #
109
-
118
+
110
119
  def buttons
111
120
  Buttons.new(self)
112
121
  end
113
-
122
+
114
123
  #
115
124
  # @return [Celerity::TableCell]
116
125
  #
117
-
126
+
118
127
  def cell(*args)
119
128
  TableCell.new(self, *args)
120
129
  end
121
-
130
+
122
131
  #
123
132
  # @return [Celerity::TableCells]
124
133
  #
125
-
134
+
126
135
  def cells
127
136
  TableCells.new(self)
128
137
  end
@@ -158,7 +167,7 @@ module Celerity
158
167
  def dd(*args)
159
168
  Dd.new(self, *args)
160
169
  end
161
-
170
+
162
171
  #
163
172
  # @return [Celerity::Dds]
164
173
  #
@@ -166,7 +175,7 @@ module Celerity
166
175
  def dds
167
176
  Dds.new(self)
168
177
  end
169
-
178
+
170
179
  #
171
180
  # @return [Celerity::Div]
172
181
  #
@@ -174,7 +183,7 @@ module Celerity
174
183
  def div(*args)
175
184
  Div.new(self, *args)
176
185
  end
177
-
186
+
178
187
  #
179
188
  # @return [Celerity::Divs]
180
189
  #
@@ -182,7 +191,7 @@ module Celerity
182
191
  def divs
183
192
  Divs.new(self)
184
193
  end
185
-
194
+
186
195
  #
187
196
  # @return [Celerity::Dl]
188
197
  #
@@ -198,7 +207,7 @@ module Celerity
198
207
  def dls
199
208
  Dls.new(self)
200
209
  end
201
-
210
+
202
211
  #
203
212
  # @return [Celerity::Dt]
204
213
  #
@@ -214,19 +223,19 @@ module Celerity
214
223
  def dts
215
224
  Dts.new(self)
216
225
  end
217
-
226
+
218
227
  #
219
228
  # @return [Celerity::Em]
220
- #
221
-
229
+ #
230
+
222
231
  def em(*args)
223
232
  Em.new(self, *args)
224
233
  end
225
-
234
+
226
235
  #
227
236
  # @return [Celerity::Ems]
228
- #
229
-
237
+ #
238
+
230
239
  def ems
231
240
  Ems.new(self)
232
241
  end
@@ -270,7 +279,7 @@ module Celerity
270
279
  def frame(*args)
271
280
  Frame.new(self, *args)
272
281
  end
273
-
282
+
274
283
  #
275
284
  # @return [Celerity::Frames]
276
285
  #
@@ -286,7 +295,7 @@ module Celerity
286
295
  def h1(*args)
287
296
  H1.new(self, *args)
288
297
  end
289
-
298
+
290
299
  #
291
300
  # @return [Celerity::H1s]
292
301
  #
@@ -326,7 +335,7 @@ module Celerity
326
335
  def h3s
327
336
  H3s.new(self)
328
337
  end
329
-
338
+
330
339
  #
331
340
  # @return [Celerity::H4]
332
341
  #
@@ -342,7 +351,7 @@ module Celerity
342
351
  def h4s
343
352
  H4s.new(self)
344
353
  end
345
-
354
+
346
355
  #
347
356
  # @return [Celerity::H5]
348
357
  #
@@ -358,7 +367,7 @@ module Celerity
358
367
  def h5s
359
368
  H5s.new(self)
360
369
  end
361
-
370
+
362
371
  #
363
372
  # @return [Celerity::H6]
364
373
  #
@@ -554,7 +563,7 @@ module Celerity
554
563
  #
555
564
  # @return [Celerity::Radio]
556
565
  #
557
-
566
+
558
567
  def radio(*args)
559
568
  Radio.new(self, *args)
560
569
  end
@@ -598,7 +607,7 @@ module Celerity
598
607
  def select_lists
599
608
  SelectLists.new(self)
600
609
  end
601
-
610
+
602
611
  #
603
612
  # @return [Celerity::Span]
604
613
  #
@@ -662,7 +671,7 @@ module Celerity
662
671
  def tbodies
663
672
  TableBodies.new(self)
664
673
  end
665
-
674
+
666
675
  #
667
676
  # @return [Celerity::TextField]
668
677
  #
@@ -678,7 +687,7 @@ module Celerity
678
687
  def text_fields
679
688
  TextFields.new(self)
680
689
  end
681
-
690
+
682
691
  #
683
692
  # @return [Celerity::TableFooter]
684
693
  #
@@ -695,14 +704,14 @@ module Celerity
695
704
  TableFooters.new(self)
696
705
  end
697
706
  alias_method :tfeet, :tfoots # :-)
698
-
707
+
699
708
  #
700
709
  # Watir's cells() won't find <th> elements.
701
710
  # This is a workaround.
702
711
  #
703
712
  # @return [Celerity::Th]
704
713
  #
705
-
714
+
706
715
  def th(*args)
707
716
  Th.new(self, *args)
708
717
  end
@@ -715,7 +724,7 @@ module Celerity
715
724
  def ths
716
725
  raise NotImplementedError
717
726
  end
718
-
727
+
719
728
  #
720
729
  # @return [Celerity::TableHeader]
721
730
  #
@@ -747,9 +756,9 @@ module Celerity
747
756
  def uls
748
757
  Uls.new(self)
749
758
  end
750
-
759
+
751
760
  private
752
-
761
+
753
762
  #
754
763
  # Used internally.
755
764
  #
@@ -759,16 +768,16 @@ module Celerity
759
768
  #
760
769
  # @api private
761
770
  #
762
-
771
+
763
772
  def matches?(string, what)
764
773
  Regexp === what ? string =~ what : string == what.to_s
765
774
  end
766
-
775
+
767
776
  #
768
- # Rescues HtmlUnit::FailingHttpStatusCodeException and re-raises as
777
+ # Rescues HtmlUnit::FailingHttpStatusCodeException and re-raises as
769
778
  # Celerity::NavigationException to avoid the huge JRuby backtrace
770
- #
771
-
779
+ #
780
+
772
781
  def rescue_status_code_exception(&blk)
773
782
  yield
774
783
  rescue HtmlUnit::FailingHttpStatusCodeException => e
@@ -0,0 +1,20 @@
1
+ module Celerity
2
+ module ShortInspect
3
+
4
+ def short_inspect(opts)
5
+ if excluded_ivars = opts[:exclude]
6
+ ivars = (instance_variables - excluded_ivars)
7
+ elsif included_ivars = opts[:include]
8
+ ivars = included_ivars
9
+ else
10
+ raise ArgumentError, "unknown arg: #{opts.inspect}"
11
+ end
12
+
13
+ ivars.map! { |ivar| "#{ivar}=#{instance_variable_get(ivar).inspect}" }
14
+ '#<%s:0x%s %s>' % [self.class.name, self.hash.to_s(16), ivars.join(" ")]
15
+ end
16
+
17
+
18
+
19
+ end
20
+ end
@@ -3,7 +3,7 @@ module Celerity #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
5
  TINY = 6
6
- PATCH = 3 # Set to nil for official release
6
+ PATCH = 4 # 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.3
4
+ version: 0.0.6.4
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-04-05 00:00:00 -07:00
14
+ date: 2009-04-15 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -91,6 +91,7 @@ files:
91
91
  - lib/celerity/listener.rb
92
92
  - lib/celerity/resources
93
93
  - lib/celerity/resources/no_viewer.png
94
+ - lib/celerity/short_inspect.rb
94
95
  - lib/celerity/util.rb
95
96
  - lib/celerity/version.rb
96
97
  - lib/celerity/watir_compatibility.rb