cohitre-caculo 0.0.4 → 0.0.6

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.
Files changed (5) hide show
  1. data/History.txt +5 -0
  2. data/Manifest.txt +1 -0
  3. data/README.txt +18 -13
  4. data/lib/caculo.rb +12 -2
  5. metadata +1 -1
@@ -1,3 +1,8 @@
1
+ == 0.0.5 2008-10-21
2
+
3
+ * 1 minor enhancment:
4
+ * Including jquery 1.2.3 source.
5
+
1
6
  == 0.0.1 2008-04-16
2
7
 
3
8
  * 1 major enhancement:
@@ -11,3 +11,4 @@ lib/caculo/jquery.rb
11
11
  lib/caculo/safari.rb
12
12
  lib/caculo/unit.rb
13
13
  lib/caculo/version.rb
14
+ lib/assets/jquery-1.2.3.min.js
data/README.txt CHANGED
@@ -5,29 +5,33 @@
5
5
 
6
6
  == The Succinct Summary:
7
7
 
8
- Caculo lets you simulate interaction with a browser via Ruby. It has the option to load a Javascript Library and call Javascript functions on the document. This allows for simple code that takes advantage of exisiting libraries.
8
+ Caculo lets you simulate interaction with a browser via Ruby. It has the option to load a Javascript Library and call Javascript functions on the document. This allows for simple code that takes advantage of existing libraries.
9
9
 
10
10
  Caculo is inspired by the Watir/FireWatir/SafariWatir trio, However, by simplifying the way of communicating with the browser it tries to offer an integrated cross-browser solution. It also extends the Test/Unit framework to provide some abbreviations to common functions.
11
11
 
12
-
13
12
  == The Polite Apology
14
13
 
15
14
  I haven't really tested Caculo outside of my computer, so things may not work as expected out of the box.
16
15
 
17
16
  == The Descriptive Example:
18
17
 
19
- browser = Caculo.open :safari
20
- browser.libraries = [:jquery]
21
-
22
- browser.visit( 'http://google.com' )
23
-
24
- browser["input[@name='q']"].val! 'cohitre'
25
- browser["form[@name='f']"].submit!
18
+ Here's a short example of how to use caculo to do a very fun google search.
26
19
 
27
- browser.wait
28
- browser.load_libraries
20
+ require "rubygems"
21
+ require "caculo"
29
22
 
30
- browser.visit browser['#res .g:eq(1) h2.r a'].attr('href').execute
23
+ page = Caculo::Browser.open(:safari)
24
+
25
+ page.visit( "http://www.google.com" )
26
+ page.search("input[name=q]") { |obj| obj.val("cohitre") }
27
+ page.search("form[name=f]") { |form| form.submit }
28
+
29
+ sleep(1)
30
+ page.load_libraries!
31
+ sleep(1)
32
+
33
+ puts page.search("ol li:first a:first"){|f| f.text }
34
+ puts page.search("ol li:first a:first"){|f| f.attr("href") }
31
35
 
32
36
 
33
37
  == The Required Requirements
@@ -43,7 +47,8 @@ $ sudo gem install rubyosa
43
47
 
44
48
  == The Daunting Installation:
45
49
 
46
- $ gem install caculo
50
+ $ gem sources -a http://gems.github.com
51
+ $ sudo gem install cohitre-caculo
47
52
 
48
53
 
49
54
  == The Permissive License
@@ -50,9 +50,18 @@ module Caculo
50
50
  end
51
51
 
52
52
  def load_libraries!
53
- @libraries.each { |l| self.script(l) }
53
+ @libraries.each { |l| self << (l) }
54
54
  end
55
55
 
56
+ def search string , &block
57
+ obj = JQueryObject.new( string )
58
+ obj = yield( obj ) if block_given?
59
+ sleep(0.1)
60
+ return self[obj]
61
+ end
62
+
63
+ alias / :search
64
+
56
65
  def [] selector=nil
57
66
  if selector.nil?
58
67
  self << JQueryObject.new()
@@ -68,9 +77,10 @@ module Caculo
68
77
  url = self << url
69
78
  end
70
79
  self << "window.document.location.href = #{url.to_js}"
71
-
80
+ sleep( 1.0 )
72
81
  self.wait_until {|p| p.page_loaded? }
73
82
  load_libraries!
83
+ sleep( 1.0 )
74
84
  url
75
85
  end
76
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohitre-caculo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlos rodriguez