castanaut 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/{Copyright.txt → COPYRIGHT.md} +2 -2
- data/{History.txt → HISTORY.md} +10 -5
- data/{README.txt → README.md} +50 -49
- data/lib/castanaut.rb +1 -1
- data/lib/plugins/safari.rb +28 -20
- metadata +19 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
### Castanaut
|
2
2
|
|
3
3
|
Copyright (C) 2008 Inventive Labs.
|
4
4
|
|
@@ -8,7 +8,7 @@ and/or modify it under the terms of the Do What The Fuck You Want
|
|
8
8
|
To Public License, Version 2, as published by Sam Hocevar. See
|
9
9
|
http://sam.zoy.org/wtfpl/COPYING for more details.
|
10
10
|
|
11
|
-
|
11
|
+
### DomQuery
|
12
12
|
|
13
13
|
The DomQuery implementation is included from the Ext JS distribution, which
|
14
14
|
uses the MIT license requiring the following copyright and permission
|
data/{History.txt → HISTORY.md}
RENAMED
@@ -1,18 +1,23 @@
|
|
1
|
-
|
1
|
+
### 1.1.2 / 2012-01-10
|
2
|
+
|
3
|
+
* Safari 5 support, including adding tabs [DouweM]
|
4
|
+
* Updated gem build practices [joseph]
|
5
|
+
|
6
|
+
### 1.1.1 / 2011-08-13
|
2
7
|
|
3
8
|
* Now supports Mac OS X 10.7 (Lion).
|
4
9
|
|
5
|
-
|
10
|
+
### 1.1.0 / 2010-02-26
|
6
11
|
|
7
12
|
* Replaced the gem/rubyforge packaging cruft with a gemspec and rake task.
|
8
13
|
* IRB support (see README). [metavida / joseph]
|
9
|
-
* Added click_menu_item function. [topfunky]
|
14
|
+
* Added `click_menu_item` function. [topfunky]
|
10
15
|
* Added basic TextMate plugin. Name is textmate to comply with Castanaut
|
11
16
|
expectations. [topfunky]
|
12
|
-
* Added wait_for_element method [metavida]
|
17
|
+
* Added `wait_for_element` method [metavida]
|
13
18
|
* Added perform method for organization. [topfunky]
|
14
19
|
* Keystroke method using special keys if necessary. [jlsync / topfunky]
|
15
20
|
|
16
|
-
|
21
|
+
### 1.0.0 / 2008-02-21
|
17
22
|
|
18
23
|
* Initial release.
|
data/{README.txt → README.md}
RENAMED
@@ -1,34 +1,34 @@
|
|
1
|
-
|
1
|
+
# Castanaut: Automate your screencasts.
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Author: Joseph Pearson
|
4
|
+
http://gadgets.inventivelabs.com.au/castanaut
|
5
5
|
|
6
|
-
|
6
|
+
## DESCRIPTION
|
7
7
|
|
8
8
|
Castanaut lets you write executable scripts for your screencasts. With a
|
9
9
|
simple dictionary of stage directions, you can create complex interactions
|
10
10
|
with a variety of applications. Currently, and for the foreseeable future,
|
11
11
|
Castanaut supports Mac OS X 10.5 only.
|
12
12
|
|
13
|
-
|
13
|
+
## SYNOPSIS
|
14
14
|
|
15
|
-
|
15
|
+
### Writing screenplays
|
16
16
|
|
17
17
|
You write your screenplays as Ruby files. Castanaut has been designed to
|
18
18
|
read fairly naturally to the non-technical, within Ruby's constraints.
|
19
19
|
|
20
20
|
Here's a simple screenplay:
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
launch "Safari", at(10, 10, 800, 600)
|
23
|
+
type "http://www.inventivelabs.com.au"
|
24
|
+
hit Enter
|
25
|
+
pause 2
|
26
|
+
move to(100, 100)
|
27
|
+
move to(200, 100)
|
28
|
+
move to(200, 200)
|
29
|
+
move to(100, 200)
|
30
|
+
move to(100, 100)
|
31
|
+
say "I drew a square!"
|
32
32
|
|
33
33
|
With any luck we don't need to explain to you what this screenplay
|
34
34
|
does. The only thing that might need some explanation is "say" -- this has a
|
@@ -40,11 +40,11 @@ a large audience. Most people find it a little offputting.
|
|
40
40
|
You are free to contravene our recommendation though. You
|
41
41
|
can tweak the robot in the Mac OS X Speech Preferences pane.
|
42
42
|
|
43
|
-
|
43
|
+
### Running your screenplay
|
44
44
|
|
45
45
|
Simply give the screenplay to the castanaut command, like this:
|
46
46
|
|
47
|
-
|
47
|
+
castanaut test.screenplay
|
48
48
|
|
49
49
|
This assumes you have a screenplay file called "test.screenplay" in the
|
50
50
|
directory where you are running the command.
|
@@ -53,19 +53,19 @@ Of course, it isn't always convenient to drop to the terminal to run your
|
|
53
53
|
screenplay. So there's also a method of executing your screenplays directly.
|
54
54
|
You need to add this line (the "shebang" line) at the top of your screenplay:
|
55
55
|
|
56
|
-
#!/usr/bin/env castanaut
|
56
|
+
#!/usr/bin/env castanaut
|
57
57
|
|
58
58
|
Then you need to set the screenplay to be executable by running this command
|
59
59
|
on it:
|
60
60
|
|
61
|
-
|
61
|
+
chmod a+x test.screenplay
|
62
62
|
|
63
63
|
Again, substitute "test.screenplay" for your screenplay's filename.
|
64
64
|
|
65
65
|
At this point, you should be able to double-click the screenplay, or invoke
|
66
66
|
it with Quicksilver, or run it any other way that floats your boat.
|
67
67
|
|
68
|
-
|
68
|
+
### Stopping the screenplay
|
69
69
|
|
70
70
|
If you want to abruptly terminate execution before the end of the screenplay,
|
71
71
|
you just need to run the 'castanaut' command again -- with or without any
|
@@ -78,9 +78,9 @@ assigned to Shift-F1, that calls castanaut. You'll need the full path to
|
|
78
78
|
the command for this, which is usually /usr/bin/castanaut, but you can check
|
79
79
|
it with the following command:
|
80
80
|
|
81
|
-
|
81
|
+
which "castanaut"
|
82
82
|
|
83
|
-
|
83
|
+
### Running interactively with IRB
|
84
84
|
|
85
85
|
You can now run Castanaut interactively from IRB — to test commands, try stuff
|
86
86
|
out, etc:
|
@@ -94,7 +94,7 @@ Note that this technique creates an IRB subsession, so you'll have to exit out
|
|
94
94
|
of that before exiting out of IRB. There's heaps you can do with subsessions -
|
95
95
|
read up about them online.
|
96
96
|
|
97
|
-
|
97
|
+
### What stage directions can I make?
|
98
98
|
|
99
99
|
Out of the box, Castanaut performs mouse actions, keyboard actions,
|
100
100
|
robot speech and application launches.
|
@@ -102,7 +102,7 @@ robot speech and application launches.
|
|
102
102
|
For a complete overview of the built-in stage directions, see the
|
103
103
|
Castanaut::Movie class.
|
104
104
|
|
105
|
-
|
105
|
+
### Using plugins
|
106
106
|
|
107
107
|
Of course, just using the built-in stage directions is a little bit awkward
|
108
108
|
and verbose. Plugins allow you to extend the available dictionary with
|
@@ -118,26 +118,26 @@ Castanaut comes with several plugins, including
|
|
118
118
|
|
119
119
|
To use a plugin, simply declare it:
|
120
120
|
|
121
|
-
|
121
|
+
plugin "safari"
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
123
|
+
launch "Safari", at(32, 32, 800, 600)
|
124
|
+
url "http://www.google.com"
|
125
|
+
pause 4
|
126
|
+
move to_element('input[name="q"]')
|
127
|
+
click
|
128
|
+
type "Castanaut"
|
129
|
+
move to_element('input[type="submit"]')
|
130
|
+
click
|
131
|
+
pause 4
|
132
|
+
say "Oh. I was hoping for more results."
|
133
133
|
|
134
134
|
|
135
135
|
In the example above, we use the two methods provided by the Safari module:
|
136
|
-
url, which causes Safari to navigate to the given url, and to_element
|
136
|
+
url, which causes Safari to navigate to the given url, and `to_element`, which
|
137
137
|
returns the co-ordinates of a page element (using CSS selectors) relative to
|
138
138
|
the screen.
|
139
139
|
|
140
|
-
|
140
|
+
### Creating your own plugins
|
141
141
|
|
142
142
|
Advanced users can create their own plugins. Put them in a directory
|
143
143
|
called "plugins" below the directory containing the screenplays that use
|
@@ -146,26 +146,27 @@ the plugin.
|
|
146
146
|
Take a look at the plugins that Castanaut comes with for examples on creating
|
147
147
|
your own.
|
148
148
|
|
149
|
-
|
149
|
+
## REQUIREMENTS
|
150
150
|
|
151
|
-
* Mac OS X 10.5
|
151
|
+
* Mac OS X 10.5 or higher
|
152
152
|
|
153
153
|
or
|
154
154
|
|
155
155
|
* Mac OS X 10.4
|
156
|
-
* The Extras Suite application
|
156
|
+
* [The Extras Suite application](http://www.kanzu.com/main.html#extrasuites)
|
157
157
|
|
158
|
-
|
158
|
+
## INSTALL
|
159
159
|
|
160
160
|
Run the following command to install Castanaut
|
161
161
|
|
162
|
-
|
162
|
+
gem install castanaut
|
163
163
|
|
164
|
-
If you're using Mac OS X 10.4 (Tiger) you will also need to download and
|
164
|
+
If you're using Mac OS X 10.4 (Tiger) you will also need to download and
|
165
|
+
install the XTool scripting additions.
|
165
166
|
|
166
167
|
Once installed, you should run the following command for two reasons:
|
167
168
|
|
168
|
-
|
169
|
+
castanaut
|
169
170
|
|
170
171
|
Reason 1 is to confirm that it is installed correctly. Reason 2 is to set up
|
171
172
|
the permissions on the utility that controls your mouse and keyboard during
|
@@ -173,12 +174,12 @@ Castanaut movies. You may be asked for a password here.
|
|
173
174
|
|
174
175
|
If you just see a "ScreenplayNotFound" exception here, everything's good.
|
175
176
|
|
176
|
-
|
177
|
+
## LICENSE
|
177
178
|
|
178
|
-
Copyright (C) 2008 Inventive Labs.
|
179
|
+
Copyright (C) 2008-2011 Inventive Labs.
|
179
180
|
|
180
|
-
Released under the WTFPL
|
181
|
+
Released under the [WTFPL](http://sam.zoy.org/wtfpl).
|
181
182
|
|
182
183
|
Portions released under the MIT License.
|
183
184
|
|
184
|
-
See
|
185
|
+
See COPYRIGHT.md for full licensing details.
|
data/lib/castanaut.rb
CHANGED
data/lib/plugins/safari.rb
CHANGED
@@ -2,7 +2,7 @@ module Castanaut
|
|
2
2
|
|
3
3
|
module Plugin
|
4
4
|
# This module provides actions for controlling Safari. It's tested against
|
5
|
-
# Safari
|
5
|
+
# Safari 5.1.2 on Mac OS X 10.7.2.
|
6
6
|
module Safari
|
7
7
|
|
8
8
|
# An applescript fragment by the Movie launch method to determine
|
@@ -19,11 +19,26 @@ module Castanaut
|
|
19
19
|
|
20
20
|
# Open a URL in the front Safari tab.
|
21
21
|
def url(str)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
execute_javascript("location.href = '#{str}'");
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create a new tab in the front Safari window.
|
26
|
+
def new_tab(str = nil)
|
27
|
+
if str.nil?
|
28
|
+
execute_applescript %Q`
|
29
|
+
tell front window of application "Safari"
|
30
|
+
set the current tab to (make new tab)
|
31
|
+
end tell
|
32
|
+
`
|
33
|
+
else
|
34
|
+
execute_applescript %Q`
|
35
|
+
tell front window of application "Safari"
|
36
|
+
set newTab to make new tab
|
37
|
+
set the URL of newTab to "#{str}"
|
38
|
+
set the current tab to newTab
|
39
|
+
end tell
|
40
|
+
`
|
41
|
+
end
|
27
42
|
end
|
28
43
|
|
29
44
|
# Sleep until the specified element appears on-screen. Use this if you
|
@@ -105,21 +120,14 @@ module Castanaut
|
|
105
120
|
|
106
121
|
private
|
107
122
|
|
108
|
-
# Note: the script should set the Castanaut.result variable.
|
109
123
|
def execute_javascript(scpt)
|
110
124
|
execute_applescript %Q`
|
111
125
|
tell application "Safari"
|
112
|
-
do JavaScript "
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
}
|
118
|
-
" in front document
|
119
|
-
set the_result to ((name of window 1) as string)
|
120
|
-
do JavaScript "
|
121
|
-
document.title = document.oldTitle;
|
122
|
-
" in front document
|
126
|
+
set the_result to (do JavaScript "
|
127
|
+
(function() {
|
128
|
+
#{escape_dq(scpt)}
|
129
|
+
})();
|
130
|
+
" in front document)
|
123
131
|
return the_result
|
124
132
|
end tell
|
125
133
|
`
|
@@ -132,7 +140,7 @@ module Castanaut
|
|
132
140
|
coords = execute_javascript(%Q`
|
133
141
|
#{gebys}
|
134
142
|
#{cjs}
|
135
|
-
|
143
|
+
return Castanaut.Coords.forElement(
|
136
144
|
'#{selector}',
|
137
145
|
#{index}
|
138
146
|
);
|
@@ -168,4 +176,4 @@ module Castanaut
|
|
168
176
|
end
|
169
177
|
end
|
170
178
|
|
171
|
-
end
|
179
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: castanaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Joseph Pearson
|
@@ -14,16 +15,17 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
18
|
+
date: 2012-01-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
27
29
|
segments:
|
28
30
|
- 0
|
29
31
|
version: "0"
|
@@ -36,13 +38,13 @@ executables:
|
|
36
38
|
extensions: []
|
37
39
|
|
38
40
|
extra_rdoc_files:
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- README.
|
41
|
+
- COPYRIGHT.md
|
42
|
+
- HISTORY.md
|
43
|
+
- README.md
|
42
44
|
files:
|
43
|
-
-
|
44
|
-
-
|
45
|
-
- README.
|
45
|
+
- COPYRIGHT.md
|
46
|
+
- HISTORY.md
|
47
|
+
- README.md
|
46
48
|
- bin/castanaut
|
47
49
|
- cbin/osxautomation
|
48
50
|
- lib/castanaut/exceptions.rb
|
@@ -66,7 +68,6 @@ files:
|
|
66
68
|
- test/helper.rb
|
67
69
|
- test/main_test.rb
|
68
70
|
- test/movie_test.rb
|
69
|
-
has_rdoc: true
|
70
71
|
homepage: http://gadgets.inventivelabs.com.au/castanaut
|
71
72
|
licenses: []
|
72
73
|
|
@@ -75,27 +76,31 @@ rdoc_options:
|
|
75
76
|
- --title
|
76
77
|
- Castanaut
|
77
78
|
- --main
|
78
|
-
- README.
|
79
|
+
- README.md
|
79
80
|
require_paths:
|
80
81
|
- lib
|
81
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
82
84
|
requirements:
|
83
85
|
- - ">="
|
84
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
85
88
|
segments:
|
86
89
|
- 0
|
87
90
|
version: "0"
|
88
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
89
93
|
requirements:
|
90
94
|
- - ">="
|
91
95
|
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
92
97
|
segments:
|
93
98
|
- 0
|
94
99
|
version: "0"
|
95
100
|
requirements: []
|
96
101
|
|
97
102
|
rubyforge_project: nowarning
|
98
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.7.2
|
99
104
|
signing_key:
|
100
105
|
specification_version: 3
|
101
106
|
summary: Castanaut - automate your screencasts
|