castanaut 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- == Castanaut
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
- === DomQuery
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
@@ -1,18 +1,23 @@
1
- == 1.1.1 / 2011-08-13
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
- == 1.1.0 / 2010-02-26
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
- === 1.0.0 / 2008-02-21
21
+ ### 1.0.0 / 2008-02-21
17
22
 
18
23
  * Initial release.
@@ -1,34 +1,34 @@
1
- = Castanaut: Automate your screencasts.
1
+ # Castanaut: Automate your screencasts.
2
2
 
3
- Author: Joseph Pearson
4
- http://gadgets.inventivelabs.com.au/castanaut
3
+ Author: Joseph Pearson
4
+ http://gadgets.inventivelabs.com.au/castanaut
5
5
 
6
- == DESCRIPTION:
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
- == SYNOPSIS:
13
+ ## SYNOPSIS
14
14
 
15
- === Writing screenplays
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
- 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!"
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
- === Running your screenplay
43
+ ### Running your screenplay
44
44
 
45
45
  Simply give the screenplay to the castanaut command, like this:
46
46
 
47
- castanaut test.screenplay
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
- chmod a+x test.screenplay
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
- === Stopping the screenplay
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
- which "castanaut"
81
+ which "castanaut"
82
82
 
83
- === Running interactively with IRB
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
- === What stage directions can I make?
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
- === Using plugins
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
- plugin "safari"
121
+ plugin "safari"
122
122
 
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."
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, which
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
- === Creating your own plugins
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
- == REQUIREMENTS:
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 <http://www.kanzu.com/main.html#extrasuites>
156
+ * [The Extras Suite application](http://www.kanzu.com/main.html#extrasuites)
157
157
 
158
- == INSTALL:
158
+ ## INSTALL
159
159
 
160
160
  Run the following command to install Castanaut
161
161
 
162
- sudo gem install castanaut
162
+ gem install castanaut
163
163
 
164
- If you're using Mac OS X 10.4 (Tiger) you will also need to download and install the XTool scripting additions.
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
- castanaut
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
- == LICENSE:
177
+ ## LICENSE
177
178
 
178
- Copyright (C) 2008 Inventive Labs.
179
+ Copyright (C) 2008-2011 Inventive Labs.
179
180
 
180
- Released under the WTFPL: http://sam.zoy.org/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 Copyright.txt for full licensing details.
185
+ See COPYRIGHT.md for full licensing details.
data/lib/castanaut.rb CHANGED
@@ -10,7 +10,7 @@ unless defined? Castanaut
10
10
  module Castanaut
11
11
 
12
12
  # :stopdoc:
13
- VERSION = '1.1.1'
13
+ VERSION = '1.1.2'
14
14
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
15
15
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
16
16
 
@@ -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 3 on Mac OS X 10.5.2.
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
- execute_applescript(%Q`
23
- tell application "safari"
24
- do JavaScript "location.href = '#{str}'" in front document
25
- end tell
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
- document.oldTitle = document.title;
114
- #{escape_dq(scpt)}
115
- if (typeof Castanaut.result != 'undefined') {
116
- document.title = Castanaut.result;
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
- Castanaut.result = Castanaut.Coords.forElement(
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
- prerelease: false
4
+ hash: 23
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
8
  - 1
8
- - 1
9
- version: 1.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: 2011-08-13 00:00:00 +10:00
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
- - Copyright.txt
40
- - History.txt
41
- - README.txt
41
+ - COPYRIGHT.md
42
+ - HISTORY.md
43
+ - README.md
42
44
  files:
43
- - Copyright.txt
44
- - History.txt
45
- - README.txt
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.txt
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.3.6
103
+ rubygems_version: 1.7.2
99
104
  signing_key:
100
105
  specification_version: 3
101
106
  summary: Castanaut - automate your screencasts