jarib-celerity 0.0.6.16 → 0.0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown ADDED
@@ -0,0 +1,86 @@
1
+ Celerity
2
+ ========
3
+
4
+ * [http://celerity.rubyforge.org/](http://celerity.rubyforge.org/)
5
+
6
+ Description
7
+ ------------
8
+
9
+ Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with
10
+ JavaScript support. It provides a simple API for programmatic navigation through
11
+ web applications. Celerity aims at being API compatible with Watir.
12
+
13
+ Features
14
+ --------
15
+
16
+ * *Fast*: No time-consuming GUI rendering or unessential downloads
17
+ * *Scalable*: Java threads lets you run tests in parallel
18
+ * *Easy to use*: Simple API
19
+ * *Portable*: Cross-platform thanks to the JVM
20
+ * *Unintrusive*: No browser window interrupting your workflow (runs in background)
21
+
22
+ Requirements
23
+ ------------
24
+
25
+ * JRuby 1.2.0 or higher
26
+ * Java 6
27
+
28
+ Install
29
+ -------
30
+
31
+ `jruby -S gem install celerity`
32
+
33
+ or from GitHub (updated frequently)
34
+
35
+ `jruby -S gem install jarib-celerity`
36
+
37
+
38
+ Example
39
+ -------
40
+
41
+ require "rubygems"
42
+ require "celerity"
43
+
44
+ browser = Celerity::Browser.new
45
+ browser.goto('http://www.google.com')
46
+ browser.text_field(:name, 'q').value = 'Celerity'
47
+ browser.button(:name, 'btnG').click
48
+
49
+ puts "yay" if browser.text.include? 'celerity.rubyforge.org'
50
+
51
+ Source
52
+ ------
53
+
54
+ The source code is available on [GitHub](http://github.com/jarib/celerity/tree/master).
55
+
56
+
57
+ Wiki & Bug Tracker
58
+ -------------------
59
+
60
+ * [Wiki](http://github.com/jarib/celerity/wikis)
61
+ * [Bug Tracker](http://github.com/jarib/celerity/issues)
62
+
63
+ Related projects
64
+ ----------------
65
+
66
+ * [WatirSpec](http://github.com/jarib/watirspec/tree/master)
67
+ * [Celerity Viewers](http://github.com/jarib/celerity-viewers)
68
+
69
+ License
70
+ -------
71
+
72
+ Celerity - JRuby wrapper for HtmlUnit
73
+ Copyright (c) 2008 FINN.no AS
74
+
75
+ This program is free software: you can redistribute it and/or modify
76
+ it under the terms of the GNU General Public License as published by
77
+ the Free Software Foundation, either version 3 of the License, or
78
+ (at your option) any later version.
79
+
80
+ This program is distributed in the hope that it will be useful,
81
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
82
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83
+ GNU General Public License for more details.
84
+
85
+ You should have received a copy of the GNU General Public License
86
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -46,6 +46,7 @@ module Celerity
46
46
  # @option opts :ignore_pattern [Regexp] See Browser#ignore_pattern=
47
47
  # @option opts :viewer [Boolean] (true) Connect to a CelerityViewer on port 6429 if available.
48
48
  # @option opts :render [:html, :xml] (:html) What DOM representation to send to connected viewers.
49
+ # @option opts :refresh_handler [:immediat, :waiting, :threaded] (:immediate) Set HtmlUnit's refresh handler.
49
50
  #
50
51
  # @return [Celerity::Browser] An instance of the browser.
51
52
  #
@@ -659,6 +660,21 @@ module Celerity
659
660
  @webclient.cssEnabled
660
661
  end
661
662
 
663
+ def refresh_handler=(symbol)
664
+ handler = case symbol
665
+ when :waiting
666
+ HtmlUnit::WaitingRefreshHandler.new
667
+ when :threaded
668
+ HtmlUnit::ThreadedRefreshHandler.new
669
+ when :immediate
670
+ HtmlUnit::ImmediateRefreshHandler.new
671
+ else
672
+ raise ArgumentError, "expected :waiting, :threaded or :immediate"
673
+ end
674
+
675
+ @webclient.setRefreshHandler handler
676
+ end
677
+
662
678
  #
663
679
  # Turn on/off secure SSL
664
680
  #
@@ -809,8 +825,13 @@ module Celerity
809
825
  self.javascript_enabled = opts.delete(:javascript_enabled) != false
810
826
  self.secure_ssl = opts.delete(:secure_ssl) == false
811
827
  self.ignore_pattern = opts.delete(:ignore_pattern) if opts[:ignore_pattern]
828
+ self.refresh_handler = opts.delete(:refresh_handler) if opts[:refresh_handler]
829
+
830
+ if opts.delete(:resynchronize)
831
+ controller = ::HtmlUnit::NicelyResynchronizingAjaxController.new
832
+ @webclient.setAjaxController controller
833
+ end
812
834
 
813
- @webclient.setAjaxController(::HtmlUnit::NicelyResynchronizingAjaxController.new) if opts.delete(:resynchronize)
814
835
  enable_event_listener
815
836
  end
816
837
 
@@ -818,16 +839,14 @@ module Celerity
818
839
  @viewer = DefaultViewer
819
840
  return if option == false
820
841
 
821
- begin
822
- host_string = option.kind_of?(String) ? option : "127.0.0.1:6429"
823
- host, port = host_string.split(":")
842
+ host_string = option.kind_of?(String) ? option : "127.0.0.1:6429"
843
+ host, port = host_string.split(":")
824
844
 
825
- if viewer = ViewerConnection.create(host, port.to_i)
826
- @viewer = viewer
827
- end
828
- rescue Errno::ECONNREFUSED => e
829
- raise e if option.kind_of?(String)
845
+ if viewer = ViewerConnection.create(host, port.to_i)
846
+ @viewer = viewer
830
847
  end
848
+ rescue Errno::ECONNREFUSED => e
849
+ nil
831
850
  end
832
851
 
833
852
  #
@@ -3,7 +3,7 @@ module Celerity #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
5
  TINY = 6
6
- PATCH = 16 # Set to nil for official release
6
+ PATCH = 17 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -1,7 +1,12 @@
1
1
  module Celerity
2
2
  class ViewerConnection
3
3
 
4
+ #
5
+ # Create a new connection to the given host/port
6
+ #
7
+
4
8
  def self.create(host, port)
9
+ # if the connection fails, we won't spend time loading json
5
10
  socket = TCPSocket.new(host, port)
6
11
  require "json"
7
12
  new(socket)
@@ -11,22 +16,48 @@ module Celerity
11
16
  @socket = socket
12
17
  end
13
18
 
19
+ #
20
+ # Tells the viewer to render the given HTML, with the given URL as base url.
21
+ #
22
+
14
23
  def render_html(html, url)
15
24
  send_data({'method' => 'page_changed', 'html' => html, 'url' => url}.to_json)
16
25
  end
17
26
 
18
- def save(path = nil)
27
+ #
28
+ # Tells the viewer to save a screenshot of the current page to the given path.
29
+ # May not be available on all viewers.
30
+ #
31
+
32
+ def save(path)
19
33
  send_data({'method' => 'save', 'path' => path}.to_json)
20
34
  end
21
35
 
36
+ #
37
+ # Tells the viewer to dump the render tree to the given path.
38
+ # Only available on the Qt viewer.
39
+ #
40
+
41
+ def save_render_tree(path)
42
+ send_data({'method' => 'save_render_tree', 'path' => path}.to_json)
43
+ end
44
+
45
+ #
46
+ # Close the connection.
47
+ #
48
+
22
49
  def close
23
- @socket.close
50
+ @socket.close rescue nil
24
51
  end
25
52
 
26
53
  private
27
54
 
28
- def send_data(data)
29
- @socket.write ["Content-Length: #{data.size}", data].join("\n\n")
55
+ def send_data(json)
56
+ data = "Content-Length: #{json.size}\n\n#{json}"
57
+ @socket.write data
58
+ @socket.flush
59
+
60
+ nil
30
61
  end
31
62
 
32
63
  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.16
4
+ version: 0.0.6.17
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-08-10 00:00:00 -07:00
14
+ date: 2009-08-16 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,6 @@ extensions: []
43
43
  extra_rdoc_files:
44
44
  - History.txt
45
45
  - License.txt
46
- - README.txt
47
46
  files:
48
47
  - History.txt
49
48
  - lib
@@ -95,7 +94,7 @@ files:
95
94
  - lib/celerity/htmlunit/cssparser-0.9.5.jar
96
95
  - lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar
97
96
  - lib/celerity/htmlunit/htmlunit-core-js-2.6-SNAPSHOT.jar
98
- - lib/celerity/htmlunit/nekohtml-1.9.13-20090714.153721-7.jar
97
+ - lib/celerity/htmlunit/nekohtml-1.9.13-20090812.213532-11.jar
99
98
  - lib/celerity/htmlunit/sac-1.3.jar
100
99
  - lib/celerity/htmlunit/serializer-2.7.1.jar
101
100
  - lib/celerity/htmlunit/xalan-2.7.1.jar
@@ -104,7 +103,7 @@ files:
104
103
  - lib/celerity/resources/no_viewer.png
105
104
  - License.txt
106
105
  - Rakefile
107
- - README.txt
106
+ - README.markdown
108
107
  - tasks
109
108
  - tasks/jar.rake
110
109
  - tasks/rdoc.rake
@@ -114,7 +113,7 @@ licenses:
114
113
  post_install_message:
115
114
  rdoc_options:
116
115
  - --main
117
- - README.txt
116
+ - README.markdown
118
117
  require_paths:
119
118
  - lib
120
119
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.txt DELETED
@@ -1,74 +0,0 @@
1
- = Celerity
2
-
3
- * http://celerity.rubyforge.org/
4
-
5
- == DESCRIPTION:
6
-
7
- Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with
8
- JavaScript support. It provides a simple API for programmatic navigation through
9
- web applications. Celerity aims at being API compatible with Watir.
10
-
11
- == FEATURES:
12
-
13
- * Fast: No time-consuming GUI rendering or unessential downloads
14
- * Scalable: Java threads lets you run tests in parallel
15
- * Easy to use: Simple API
16
- * Portable: Cross-platform
17
- * Unintrusive: No browser window interrupting your workflow (runs in background)
18
-
19
- == REQUIREMENTS:
20
-
21
- * JRuby 1.2.0 or higher
22
- * Java 6
23
-
24
- == INSTALL:
25
-
26
- `jruby -S gem install celerity`
27
-
28
- or from GitHub
29
-
30
- `jruby -S gem install jarib-celerity`
31
-
32
-
33
- == EXAMPLE:
34
-
35
- require "rubygems"
36
- require "celerity"
37
-
38
- browser = Celerity::Browser.new
39
- browser.goto('http://www.google.com')
40
- browser.text_field(:name, 'q').value = 'Celerity'
41
- browser.button(:name, 'btnG').click
42
-
43
- puts "yay" if browser.text.include? 'celerity.rubyforge.org'
44
-
45
- == SOURCE
46
-
47
- The source code is available at http://github.com/jarib/celerity/tree/master.
48
- Most of Celerity's spec suite is available as a separate project, at http://github.com/jarib/watirspec/tree/master.
49
-
50
- == WIKI:
51
-
52
- * http://github.com/jarib/celerity/wikis
53
-
54
- == BUG TRACKER:
55
-
56
- * http://github.com/jarib/celerity/issues
57
-
58
- == LICENSE:
59
-
60
- Celerity - JRuby wrapper for HtmlUnit
61
- Copyright (c) 2008 FINN.no AS
62
-
63
- This program is free software: you can redistribute it and/or modify
64
- it under the terms of the GNU General Public License as published by
65
- the Free Software Foundation, either version 3 of the License, or
66
- (at your option) any later version.
67
-
68
- This program is distributed in the hope that it will be useful,
69
- but WITHOUT ANY WARRANTY; without even the implied warranty of
70
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
71
- GNU General Public License for more details.
72
-
73
- You should have received a copy of the GNU General Public License
74
- along with this program. If not, see <http://www.gnu.org/licenses/>.