castanaut 1.0.0

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/Copyright.txt ADDED
@@ -0,0 +1,29 @@
1
+ == Castanaut
2
+
3
+ Copyright (C) 2008 Inventive Labs.
4
+
5
+ This program is free software. It comes without any warranty, to
6
+ the extent permitted by applicable law. You can redistribute it
7
+ and/or modify it under the terms of the Do What The Fuck You Want
8
+ To Public License, Version 2, as published by Sam Hocevar. See
9
+ http://sam.zoy.org/wtfpl/COPYING for more details.
10
+
11
+ === DomQuery
12
+
13
+ The DomQuery implementation is included from the Ext JS distribution, which
14
+ uses the MIT license requiring the following copyright and permission
15
+ notices. These pertain only to the script/gebys.js file.
16
+
17
+ Copyright (c) 2006-2007 Ext JS, LLC.
18
+
19
+ Permission is hereby granted, free of charge, to any person
20
+ obtaining a copy of this software and associated documentation
21
+ files (the "Software"), to deal in the Software without
22
+ restriction, including without limitation the rights to use,
23
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ copies of the Software, and to permit persons to whom the
25
+ Software is furnished to do so, subject to the following
26
+ conditions:
27
+
28
+ The above copyright notice and this permission notice shall be
29
+ included in all copies or substantial portions of the Software.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ == 1.0.0 / 2008-02-21
2
+
3
+ * Initial release.
data/Manifest.txt ADDED
@@ -0,0 +1,31 @@
1
+ Copyright.txt
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/castanaut
7
+ cbin/osxautomation
8
+ lib/castanaut.rb
9
+ lib/castanaut/exceptions.rb
10
+ lib/castanaut/keys.rb
11
+ lib/castanaut/main.rb
12
+ lib/castanaut/movie.rb
13
+ lib/castanaut/plugin.rb
14
+ lib/plugins/ishowu.rb
15
+ lib/plugins/mousepose.rb
16
+ lib/plugins/safari.rb
17
+ scripts/coords.js
18
+ scripts/gebys.js
19
+ tasks/ann.rake
20
+ tasks/annotations.rake
21
+ tasks/doc.rake
22
+ tasks/gem.rake
23
+ tasks/manifest.rake
24
+ tasks/post_load.rake
25
+ tasks/rubyforge.rake
26
+ tasks/setup.rb
27
+ tasks/spec.rake
28
+ tasks/svn.rake
29
+ tasks/test.rake
30
+ test/example_script.screenplay
31
+ test/googling.screenplay
data/README.txt ADDED
@@ -0,0 +1,161 @@
1
+ = Castanaut: Automate your screencasts.
2
+
3
+ Author: Joseph Pearson
4
+ http://gadgets.inventivelabs.com.au/castanaut
5
+
6
+ == DESCRIPTION:
7
+
8
+ Castanaut lets you write executable scripts for your screencasts. With a
9
+ simple dictionary of stage directions, you can create complex interactions
10
+ with a variety of applications. Currently, and for the foreseeable future,
11
+ Castanaut supports Mac OS X 10.5 only.
12
+
13
+ == SYNOPSIS:
14
+
15
+ === Writing screenplays
16
+
17
+ You write your screenplays as Ruby files. Castanaut has been designed to
18
+ read fairly naturally to the non-technical, within Ruby's constraints.
19
+
20
+ Here's a simple screenplay:
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!"
32
+
33
+ With any luck we don't need to explain to you what this screenplay
34
+ does. The only thing that might need some explanation is "say" -- this has a
35
+ robotic voice speak the given string. (Also: all numbers are pixel
36
+ co-ordinates).
37
+
38
+ About the robot: no, we don't recommend you use this in real screencasts for
39
+ a large audience. Most people find it a little offputting.
40
+ You are free to contravene our recommendation though. You
41
+ can tweak the robot in the Mac OS X Speech Preferences pane.
42
+
43
+ === Running your screenplay
44
+
45
+ Simply give the screenplay to the castanaut command, like this:
46
+
47
+ castanaut test.screenplay
48
+
49
+ This assumes you have a screenplay file called "test.screenplay" in the
50
+ directory where you are running the command.
51
+
52
+ Of course, it isn't always convenient to drop to the terminal to run your
53
+ screenplay. So there's also a method of executing your screenplays directly.
54
+ You need to add this line (the "shebang" line) at the top of your screenplay:
55
+
56
+ #!/usr/bin/env castanaut
57
+
58
+ Then you need to set the screenplay to be executable by running this command
59
+ on it:
60
+
61
+ chmod a+x test.screenplay
62
+
63
+ Again, substitute "test.screenplay" for your screenplay's filename.
64
+
65
+ At this point, you should be able to double-click the screenplay, or invoke
66
+ it with Quicksilver, or run it any other way that floats your boat.
67
+
68
+ === Stopping the screenplay
69
+
70
+ If you want to abruptly terminate execution before the end of the screenplay,
71
+ you just need to run the 'castanaut' command again -- with or without any
72
+ arguments.
73
+
74
+ Of course, that might be easier said than done, if you haven't got full
75
+ control of the mouse or keyboard at the time. One recommendation is to assign
76
+ a system hot-key to invoke castanaut. I use a Quicksilver trigger for this,
77
+ assigned to Shift-F1, that calls castanaut. You'll need the full path to
78
+ the command for this, which is usually /usr/bin/castanaut, but you can check
79
+ it with the following command:
80
+
81
+ which "castanaut"
82
+
83
+
84
+ === What stage directions can I make?
85
+
86
+ Out of the box, Castanaut performs mouse actions, keyboard actions,
87
+ robot speech and application launches.
88
+
89
+ For a complete overview of the built-in stage directions, see the
90
+ Castanaut::Movie class.
91
+
92
+ === Using plugins
93
+
94
+ Of course, just using the built-in stage directions is a little bit awkward
95
+ and verbose. Plugins allow you to extend the available dictionary with
96
+ some additional convenience actions. Typically a plugin is specific to an
97
+ application.
98
+
99
+ Castanaut comes with several plugins, including Castanaut::Plugin::Safari for
100
+ interacting with the contents of web-pages, and Castanaut::Plugin::Ishowu for
101
+ recording screencasts using the iShowU application from Shiny White Box.
102
+
103
+ To use a plugin, simply declare it:
104
+
105
+ plugin "safari"
106
+
107
+ launch "Safari", at(32, 32, 800, 600)
108
+ url "http://www.google.com"
109
+ pause 4
110
+ move to_element('input[name="q"]')
111
+ click
112
+ type "Castanaut"
113
+ move to_element('input[type="submit"]')
114
+ click
115
+ pause 4
116
+ say "Oh. I was hoping for more results."
117
+
118
+
119
+ In the example above, we use the two methods provided by the Safari module:
120
+ url, which causes Safari to navigate to the given url, and to_element, which
121
+ returns the co-ordinates of a page element (using CSS selectors) relative to
122
+ the screen.
123
+
124
+ === Creating your own plugins
125
+
126
+ Advanced users can create their own plugins. Put them in a directory
127
+ called "plugins" below the directory containing the screenplays that use
128
+ the plugin.
129
+
130
+ Take a look at the plugins that Castanaut comes with for examples on creating
131
+ your own.
132
+
133
+ == REQUIREMENTS:
134
+
135
+ * Mac OS X 10.5
136
+
137
+ == INSTALL:
138
+
139
+ Run the following command to install Castanaut
140
+
141
+ sudo gem install castanaut
142
+
143
+ Once installed, you should run the following command for two reasons:
144
+
145
+ castanaut
146
+
147
+ Reason 1 is to confirm that it is installed correctly. Reason 2 is to set up
148
+ the permissions on the utility that controls your mouse and keyboard during
149
+ Castanaut movies. You may be asked for a password here.
150
+
151
+ If you just see a "ScreenplayNotFound" exception here, everything's good.
152
+
153
+ == LICENSE:
154
+
155
+ Copyright (C) 2008 Inventive Labs.
156
+
157
+ Released under the WTFPL: http://sam.zoy.org/wtfpl.
158
+
159
+ Portions released under the MIT License.
160
+
161
+ See Copyright.txt for full licensing details.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # Look in the tasks/setup.rb file for the various options that can be
2
+ # configured in this Rakefile. The .rake files in the tasks directory
3
+ # are where the options are used.
4
+
5
+ load 'tasks/setup.rb'
6
+
7
+ ensure_in_path 'lib'
8
+ require 'castanaut'
9
+
10
+ task :default => 'spec:run'
11
+
12
+ PROJ.name = 'castanaut'
13
+ PROJ.authors = 'Joseph Pearson'
14
+ PROJ.email = 'joseph@inventivelabs.com.au'
15
+ PROJ.url = 'http://castanaut.rubyforge.org'
16
+ PROJ.version = Castanaut::VERSION
17
+
18
+ PROJ.rubyforge_name = 'castanaut'
19
+ PROJ.rdoc_remote_dir = 'doc'
20
+
21
+ PROJ.exclude += ['^spec\/*', '^test\/*']
22
+
23
+ PROJ.spec_opts << '--color'
24
+
25
+ # EOF
data/bin/castanaut ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), '..', 'lib', 'castanaut')
5
+ )
6
+
7
+ Castanaut::Main.run ARGV
Binary file
@@ -0,0 +1,32 @@
1
+ module Castanaut
2
+ # All Castanaut errors are defined within this module. If you are creating
3
+ # a plugin, you should re-open this module in your plugin script file to
4
+ # add any plugin-specific exceptions (it's also a good idea to have them
5
+ # descend from CastanautError).
6
+ module Exceptions
7
+ # The abstract parent class of all Castanaut errors.
8
+ class CastanautError < RuntimeError
9
+ end
10
+
11
+ # Raised if Castanaut was invoked with no screenplay argument, or one
12
+ # pointing to a non-existent file.
13
+ class ScreenplayNotFound < CastanautError
14
+ end
15
+
16
+ # If Castanaut::Movie#run sees a non-zero exit status from the shell
17
+ # process, this error will be raised.
18
+ class ExternalActionError < CastanautError
19
+ end
20
+
21
+ # If the FILE_RUNNING flag file is deleted or moved during the execution
22
+ # of a movie, it will terminate and raise this exception.
23
+ class AbortedByUser < CastanautError
24
+ end
25
+
26
+ # Despite asking for permission, the osxautomation utility in cbin cannot
27
+ # be executed. This is pretty fatal to our intentions, so we abort with
28
+ # this exception.
29
+ class OSXAutomationPermissionError < CastanautError
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ module Castanaut
2
+
3
+ # Some standard keys (for use with 'hit'), presumably only for US keyboards.
4
+
5
+ #
6
+ Return = "0x24"
7
+ Enter = "0x4C"
8
+ Tab = "0x30"
9
+ Space = "0x31"
10
+ Backspace = "0x33"
11
+ Esc = "0x35"
12
+
13
+ Shift = "0x38"
14
+ CapsLock = "0x39"
15
+ Alt = "0x3A"
16
+ Ctrl = "0x3B"
17
+
18
+ LArrow = "0x7B"
19
+ RArrow = "0x7C"
20
+ DArrow = "0x7D"
21
+ UArrow = "0x7E"
22
+
23
+ Insert = "0x72"
24
+ Home = "0x73"
25
+ PageUp = "0x74"
26
+ Delete = "0x75"
27
+ End = "0x77"
28
+ PageDown = "0x79"
29
+
30
+ F1 = "0x7A"
31
+ F2 = "0x78"
32
+ F3 = "0x63"
33
+ F4 = "0x76"
34
+ F5 = "0x60"
35
+ F6 = "0x61"
36
+ F7 = "0x62"
37
+ F8 = "0x64"
38
+ F9 = "0x65"
39
+ F10 = "0x6D"
40
+ F11 = "0x67"
41
+ F12 = "0x6F"
42
+
43
+ end
@@ -0,0 +1,20 @@
1
+ module Castanaut
2
+
3
+ # When running the Castanaut library as an executable, this class manages
4
+ # the invocation of the user-specified screenplay.
5
+ class Main
6
+
7
+ # If Castanaut is not running, this runs the movie specified as the first
8
+ # argument. If it *is* already running, this nixes the flag file, which
9
+ # should cause Castanaut to stop.
10
+ def self.run(args)
11
+ if File.exists?(Castanaut::FILE_RUNNING)
12
+ File.unlink(Castanaut::FILE_RUNNING)
13
+ else
14
+ Castanaut::Movie.new(args.shift)
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end