rb-appscript 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGES +30 -0
  2. data/LICENSE +1 -1
  3. data/README +7 -3
  4. data/TODO +7 -1
  5. data/doc/aem-manual/01_introduction.html +23 -9
  6. data/doc/aem-manual/02_apioverview.html +25 -11
  7. data/doc/aem-manual/03_packingandunpackingdata.html +22 -17
  8. data/doc/aem-manual/04_references.html +49 -36
  9. data/doc/aem-manual/05_targettingapplications.html +25 -14
  10. data/doc/aem-manual/06_buildingandsendingevents.html +47 -21
  11. data/doc/aem-manual/07_findapp.html +22 -11
  12. data/doc/aem-manual/08_examples.html +21 -10
  13. data/doc/aem-manual/index.html +28 -12
  14. data/doc/appscript-manual/01_introduction.html +40 -27
  15. data/doc/appscript-manual/02_aboutappscripting.html +28 -15
  16. data/doc/appscript-manual/03_quicktutorial.html +29 -16
  17. data/doc/appscript-manual/04_gettinghelp.html +31 -16
  18. data/doc/appscript-manual/05_keywordconversion.html +23 -10
  19. data/doc/appscript-manual/06_classesandenums.html +32 -19
  20. data/doc/appscript-manual/07_applicationobjects.html +31 -18
  21. data/doc/appscript-manual/08_realvsgenericreferences.html +23 -11
  22. data/doc/appscript-manual/09_referenceforms.html +33 -20
  23. data/doc/appscript-manual/10_referenceexamples.html +30 -17
  24. data/doc/appscript-manual/11_applicationcommands.html +25 -13
  25. data/doc/appscript-manual/12_commandexamples.html +26 -15
  26. data/doc/appscript-manual/13_performanceissues.html +46 -20
  27. data/doc/appscript-manual/14_notes.html +29 -19
  28. data/doc/appscript-manual/index.html +27 -11
  29. data/doc/full.css +95 -9
  30. data/doc/index.html +27 -10
  31. data/doc/mactypes-manual/01_introduction.html +56 -0
  32. data/doc/mactypes-manual/02_aliasclass.html +134 -0
  33. data/doc/mactypes-manual/03_fileurlclass.html +136 -0
  34. data/doc/mactypes-manual/04_unitsclass.html +102 -0
  35. data/doc/mactypes-manual/index.html +26 -227
  36. data/doc/osax-manual/01_introduction.html +69 -0
  37. data/doc/osax-manual/02_interface.html +149 -0
  38. data/doc/osax-manual/03_examples.html +75 -0
  39. data/doc/osax-manual/04_notes.html +80 -0
  40. data/doc/osax-manual/index.html +26 -195
  41. data/doc/rb-appscript-logo.png +0 -0
  42. data/rb-appscript.gemspec +2 -2
  43. data/sample/TextEdit_demo.rb +1 -1
  44. data/src/lib/_aem/aemreference.rb +1 -1
  45. data/src/lib/_aem/codecs.rb +42 -8
  46. data/src/lib/_aem/connect.rb +3 -1
  47. data/src/lib/_aem/findapp.rb +1 -1
  48. data/src/lib/_aem/mactypes.rb +1 -1
  49. data/src/lib/_aem/send.rb +162 -142
  50. data/src/lib/_aem/typewrappers.rb +2 -2
  51. data/src/lib/_appscript/defaultterminology.rb +76 -46
  52. data/src/lib/_appscript/referencerenderer.rb +1 -1
  53. data/src/lib/_appscript/reservedkeywords.rb +2 -2
  54. data/src/lib/_appscript/safeobject.rb +1 -1
  55. data/src/lib/_appscript/terminology.rb +30 -19
  56. data/src/lib/aem.rb +1 -6
  57. data/src/lib/appscript.rb +65 -20
  58. data/src/lib/osax.rb +21 -18
  59. data/src/rbae.c +1 -1
  60. data/test/test_appscriptcommands.rb +1 -1
  61. metadata +12 -3
@@ -0,0 +1,102 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+
5
+ <title>rb-mactypes manual | 4. Units class</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <style type="text/css" media="all"><!--@import url(../full.css);--></style>
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
14
+
15
+ <!-- top navigation -->
16
+ <div class="navbar">
17
+ <a href="03_fileurlclass.html">Previous</a> &bull;
18
+ <a href="index.html">Up</a>
19
+
20
+ <span>
21
+ <a href="../appscript-manual/index.html">appscript</a> /
22
+ <strong><a href="../mactypes-manual/index.html">mactypes</a></strong> /
23
+ <a href="../osax-manual/index.html">osax</a> /
24
+ <a href="../aem-manual/index.html">aem</a>
25
+ </span>
26
+ </div>
27
+
28
+ <!-- content -->
29
+ <div id="content">
30
+
31
+ <h2>4. The <code>MacTypes::Units</code> class</h2>
32
+
33
+ <p>The <code>Units</code> class represents a measurement of some sort, e.g. 3 inches, 98.5 degrees Fahrenheit.</p>
34
+
35
+ <pre><code>class Units
36
+
37
+ Constructor:
38
+
39
+ Units.new(value, type)
40
+ value : Fixnum | Bignum | Float -- the amount, e.g. 3.5
41
+ type : Symbol -- the unit of measurement, e.g. :centimeters
42
+
43
+ Methods:
44
+
45
+ ==
46
+
47
+ hash
48
+
49
+ inspect
50
+
51
+ value -- returns the amount
52
+
53
+ type -- returns the unit of measurement
54
+
55
+ to_i -- returns the amount as an integer
56
+
57
+ to_f -- returns the amount as a float
58
+
59
+ to_s -- returns the measurement as a string, e.g. "3.5 centimeters"</code></pre>
60
+
61
+ <p>The following unit types are defined as standard:</p>
62
+
63
+ <pre><code>:centimeters :cubic_inches
64
+ :meters :cubic_feet
65
+ :kilometers :cubic_yards
66
+ :inches
67
+ :feet :liters
68
+ :yards :quarts
69
+ :miles :gallons
70
+
71
+ :square_meters :grams
72
+ :square_kilometers :kilograms
73
+ :square_feet :ounces
74
+ :square_yards :pounds
75
+ :square_miles
76
+ :degrees_Celsius
77
+ :cubic_centimeters :degrees_Fahrenheit
78
+ :cubic_meters :degrees_Kelvin</code></pre>
79
+
80
+ <p>Additional application-specific unit types can be added if needed.</p>
81
+
82
+
83
+ <h3>Examples</h3>
84
+
85
+ <pre><code>MacTypes::Units.new(14, :inches)
86
+
87
+ MacTypes::Units.new(3.5, :square_meters)</code></pre>
88
+
89
+
90
+ </div>
91
+
92
+ <!-- bottom navigation -->
93
+
94
+ <div class="footer">
95
+ <a href="03_fileurlclass.html">Previous</a> &bull;
96
+ <a href="index.html">Up</a>
97
+
98
+ <span>&copy; 2006-2008 HAS</span>
99
+ </div>
100
+
101
+ </body>
102
+ </html>
@@ -2,7 +2,7 @@
2
2
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
3
  <head>
4
4
 
5
- <title>mactypes</title>
5
+ <title>rb-mactypes manual</title>
6
6
 
7
7
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
8
  <style type="text/css" media="all"><!--@import url(../full.css);--></style>
@@ -10,247 +10,46 @@
10
10
  </head>
11
11
  <body>
12
12
 
13
- <h1>mactypes</h1>
13
+ <h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
14
14
 
15
15
  <!-- top navigation -->
16
16
  <div class="navbar">
17
- <a href="../index.html">Up</a>
18
-
17
+ <a href="../index.html">Previous</a> &bull;
18
+ <a href="../index.html">Up</a> &bull;
19
+ <a href="01_introduction.html">Next</a>
20
+
21
+ <span>
22
+ <a href="../appscript-manual/index.html">appscript</a> /
23
+ <strong><a href="../mactypes-manual/index.html">mactypes</a></strong> /
24
+ <a href="../osax-manual/index.html">osax</a> /
25
+ <a href="../aem-manual/index.html">aem</a>
26
+ </span>
19
27
  </div>
20
28
 
21
29
  <!-- content -->
22
30
  <div id="content">
23
- <h2>What is mactypes?</h2>
24
31
 
25
- <p>The mactypes module provides user-friendly wrappers for OS X Alias and FileURL objects, commonly used by scriptable applications to identify filesystem objects and locations, and for unit type values used by some applications to represent lengths, etc. It is automatically imported when requiring appscript, aem or osax.</p>
32
+ <h2>Contents</h2>
26
33
 
27
- <p class="hilitebox">Note that most scriptable applications do not use or understand POSIX paths, and while the Apple Event Manager does provide some built-in coercions for converting between path strings and alias/file objects, these work with HFS paths only. Therefore, when specifying files and folders to scriptable applications, use <code>MacTypes::Alias</code> and <code>MacTypes::FileURL</code> objects - not path strings - unless otherwise indicated.</p>
28
-
29
-
30
- <h2><code>MacTypes::Alias</code></h2>
31
-
32
- <p>The <code>Alias</code> class represents a persistent reference to a filesystem object. Aliases keep track of filesystem objects even if they're renamed or moved to another location on the same disk.</p>
33
-
34
-
35
- <h3>Methods</h3>
36
-
37
- <pre><code>Alias -- a persistent reference to a filesystem object
38
- Constructors:
39
-
40
- Alias.path(path) -- make Alias object from POSIX path string
41
-
42
- Alias.hfs_path(path) -- make Alias object from HFS path string
43
-
44
- Alias.url(url) -- make Alias object from a local file:// URL string
45
-
46
- Alias.desc(desc) -- make Alias object from an AE::AEDesc
47
- of TypeAlias
48
-
49
- Methods:
50
-
51
- ==
52
-
53
- hash
54
-
55
- inspect
56
-
57
- path -- returns POSIX path string to the object's current location
58
-
59
- hfs_path -- returns HFS path string to the object's current location
60
-
61
- url -- returns file:// URL string to the object's current location
62
-
63
- desc -- returns AE::AEDesc of TypeAlias
64
-
65
- to_s -- synonym for #path
66
-
67
- to_alias -- returns self
68
-
69
- to_file_url -- returns a MacTypes::FileURL object</code></pre>
70
-
71
-
72
- <h3>Examples</h3>
73
-
74
- <pre><code>require "appscript"
75
-
76
- f = MacTypes::Alias.path('/Users/foo/some file')
77
-
78
- puts f.to_s
79
- # /Users/foo/some file
80
-
81
- puts f.url
82
- # file://localhost/Users/foo/some%20file
83
-
84
- puts f.inspect
85
- # MacTypes::Alias.path("/Users/foo/some file")
86
-
87
- Appscript.app('TextEdit').open(f)
88
- # opens document in TextEdit</code></pre>
89
-
90
-
91
- <h3>Notes</h3>
92
-
93
- <p>Comparing an <code>Alias</code> object against a <code>FileURL</code> object always returns false, even if both point to the same location.</p>
94
-
95
- <p>Remember that aliases can change when the corresponding filesystem object is moved, so take care when using <code>Alias</code> objects in situations that involve comparing or hashing them (e.g. <code>Hash</code> keys).</p>
96
-
97
-
98
- <h2><code>MacTypes::FileURL</code></h2>
99
-
100
- <p>The <code>FileURL</code> class represents a fixed filesystem location. This may be deterministic (i.e. existing locations only) or non-deterministic depending on how the object is created.</p>
101
-
102
- <h3>Methods</h3>
103
-
104
- <pre><code>FileURL -- identifies a fixed filesystem location
105
- Constructors:
106
-
107
- FileURL.path(path) -- make FileURL object from POSIX path string
108
-
109
- FileURL.hfs_path(path) -- make FileURL object from HFS path string
110
-
111
- FileURL.url(url) -- make FileURL object from a local file:// URL string
112
-
113
- FileURL.desc(desc) -- make FileURL object from an AE::AEDesc
114
- of TypeFSS, TypeFSRef or TypeFileURL
115
-
116
- Methods:
117
-
118
- ==
119
-
120
- hash
121
-
122
- inspect
123
-
124
- path -- returns POSIX path string
125
-
126
- hfs_path -- returns HFS path string
127
-
128
- url -- returns file:// URL string
129
-
130
- desc -- returns AE::AEDesc of TypeFSRef, TypeFSS or TypeFileURL
131
-
132
- to_s -- synonym for #path
133
-
134
- to_alias -- returns a MacTypes::Alias object
135
-
136
- to_file_url -- returns a new MacTypes::FileURL object</code></pre>
137
-
138
-
139
- <h3>Examples</h3>
140
-
141
- <pre><code>require "appscript"
142
-
143
- f = MacTypes::FileURL.path('/Users/foo/new file')
144
-
145
- puts f.to_s
146
- # /Users/foo/new file
147
-
148
- puts f.url
149
- # file://localhost/Users/foo/some%20file
150
-
151
- puts f.inspect
152
- # MacTypes::FileURL.path("/Users/foo/new file")
153
-
154
- Appscript.app('TextEdit').documents[1].save(:in => f)
155
- # saves front TextEdit document at the given location</code></pre>
156
-
157
-
158
- <h3>Notes</h3>
159
-
160
- <p>Unlike the <code>Alias</code> class which wraps <code>TypeAlias</code> values only, the <code>FileURL</code> class provides a uniform wrapper for several file-related types that may be returned by applications: <code>TypeFSS</code>, <code>TypeFSRef</code> and <code>TypeFileURL</code>. When passing <code>FileURL</code> values to applications, you should not normally need to worry about which value type a <code>FileURL</code> object contains as well-designed applications will ask the Apple Event Manager to coerce the given value to the desired type as necessary.</p>
161
-
162
- <p>When dealing with less well-behaved applications, however, you may need to pass an AEDesc of a specific type. In this case you should use the <code>desc</code> method to obtain an <code>AE::AEDesc</code> object, then call its <code>coerce</code> method to obtain an AEDesc of the desired type. For example, if an older Carbon application refuses to accept a FileURL identifying a non-existing file location, you may need to provide a FSSpec insteaf:</p>
163
-
164
- <pre><code>require "appscript"
165
-
166
- file_url = MacTypes::FileURL.path('/Users/foo/new file')
167
-
168
- fs_spec = file_url.desc.coerce(KAE::TypeFSS)
169
-
170
- Appscript.app('older app').documents[1].save(:in => fs_spec)</code></pre>
171
-
172
- <p>When used in an application command, a <code>FileURL</code> object returned by appscript will always pack into the same <code>TypeFSRef</code>, <code>TypeFileURL</code> or <code>TypeFSS</code> AEDesc it was created from. A <code>FileURL</code> object returned by <code>FileURL.path</code>, <code>Alias#to_file_url</code> or <code>FileURL#to_file_url</code> will always pack into an AEDesc of <code>TypeFileURL</code>.</p>
173
-
174
- <p>When comparing <code>FileURL</code> objects for equality, be aware that <code>FileURL#==</code> always performs case-sensitive comparisons, regardless of how the underlying filesystem handles case-[in]sensitivity.</p>
175
-
176
- <p>Note that AEDescs of <code>TypeFSRef</code> can represent existing filesystem locations only. AEDescs of <code>TypeFileURL</code> can represent both existing and non-existing locations. AEDescs of <code>TypeFSS</code> (FSSpecs) are deprecated on Mac OS X due to lack of proper Unicode and long filename support, and are retained for backwards compatibility with older applications only.</p>
177
-
178
- <p>Be aware that <code>FileURL#==</code> does not normalize file URLs; thus minor differences in capitalization, etc. can result in <code>FileURL#==</code> returning <code>false</code> even if both objects happen to identify the same filesystem location.</p>
179
-
180
-
181
-
182
-
183
- <h2><code>MacTypes::FileNotFoundError</code></h2>
184
-
185
- <p><code>FileNotFoundError</code> is a subclass of <code>RuntimeError</code>. It is raised by <code>Alias</code> and <code>FileURL</code> objects when an operation that only works for existing filesystem objects/locations fails. For example:</p>
186
-
187
- <pre><code>require "appscript"
188
-
189
- MacTypes::Alias.path('/some/non/existent/location')
190
- # raises FileNotFoundError</code></pre>
191
-
192
-
193
- <h2><code>MacTypes::Units</code></h2>
194
-
195
- <p>The <code>Units</code> class represents a measurement of some sort, e.g. 3 inches, 98.5 degrees Fahrenheit.</p>
196
-
197
- <pre><code>class Units
198
-
199
- Constructor:
200
-
201
- Units.new(value, type)
202
- value : Fixnum | Bignum | Float -- the amount, e.g. 3.5
203
- type : Symbol -- the unit of measurement, e.g. :centimeters
204
-
205
- Methods:
206
-
207
- ==
208
-
209
- hash
210
-
211
- inspect
212
-
213
- value -- returns the amount
214
-
215
- type -- returns the unit of measurement
216
-
217
- to_i -- returns the amount as an integer
218
-
219
- to_f -- returns the amount as a float
220
-
221
- to_s -- returns the measurement as a string, e.g. "3.5 centimeters"</code></pre>
222
-
223
- <p>The following unit types are defined as standard:</p>
224
-
225
- <pre><code>:centimeters :cubic_inches
226
- :meters :cubic_feet
227
- :kilometers :cubic_yards
228
- :inches
229
- :feet :liters
230
- :yards :quarts
231
- :miles :gallons
232
-
233
- :square_meters :grams
234
- :square_kilometers :kilograms
235
- :square_feet :ounces
236
- :square_yards :pounds
237
- :square_miles
238
- :degrees_Celsius
239
- :cubic_centimeters :degrees_Fahrenheit
240
- :cubic_meters :degrees_Kelvin</code></pre>
241
-
242
- <p>Additional application-specific unit types can be added if needed.</p>
34
+ <ol>
35
+ <li><a href="01_introduction.html">Introduction</a></li>
36
+ <li><a href="02_aliasclass.html">Alias class</a></li>
37
+ <li><a href="03_fileurlclass.html">FileURL class</a></li>
38
+ <li><a href="04_unitsclass.html">Units class</a></li>
243
39
 
40
+ </ol>
244
41
 
245
42
  </div>
246
43
 
247
44
  <!-- bottom navigation -->
248
- <div class="navbar">
249
- <a href="../index.html">Up</a>
250
-
45
+
46
+ <div class="footer">
47
+ <a href="../index.html">Previous</a> &bull;
48
+ <a href="../index.html">Up</a> &bull;
49
+ <a href="01_introduction.html">Next</a>
50
+
51
+ <span>&copy; 2006-2008 HAS</span>
251
52
  </div>
252
53
 
253
- <!--footer-->
254
- <p class="footer">&copy; 2006-2008 HAS</p>
255
54
  </body>
256
55
  </html>
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+
5
+ <title>rb-osax manual | 1. Introduction</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <style type="text/css" media="all"><!--@import url(../full.css);--></style>
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
14
+
15
+ <!-- top navigation -->
16
+ <div class="navbar">
17
+ <a href="index.html">Previous</a> &bull;
18
+ <a href="index.html">Up</a> &bull;
19
+ <a href="02_interface.html">Next</a>
20
+
21
+ <span>
22
+ <a href="../appscript-manual/index.html">appscript</a> /
23
+ <a href="../mactypes-manual/index.html">mactypes</a> /
24
+ <strong><a href="../osax-manual/index.html">osax</a></strong> /
25
+ <a href="../aem-manual/index.html">aem</a>
26
+ </span>
27
+ </div>
28
+
29
+ <!-- content -->
30
+ <div id="content">
31
+
32
+ <h2>1. Introduction</h2>
33
+
34
+ <h3>About osax</h3>
35
+
36
+ <p>The <code>OSAX</code> module provides an easy way to call scripting additions (a.k.a. OSAXen) from Ruby. It exports a single public class, <code>ScriptingAddition</code>, and two functions, <code>osax</code> and <code>scripting_additions</code>.</p>
37
+
38
+ <p>The <code>ScriptingAddition</code> class represents a single scripting addition. It is similar to an appscript application object, except that it defines commands for the specified scripting addition instead of the application's normal commands. </p>
39
+
40
+ <p>Once you've created a <code>ScriptingAddition</code> instance, you can invoke its commands in exactly the same way as you would call a scriptable application's commands in appscript.</p>
41
+
42
+ <p>For example:</p>
43
+
44
+ <pre><code>require "osax"
45
+
46
+ sa = OSAX::ScriptingAddition.new("StandardAdditions")
47
+
48
+ sa.say("Hello world", :using=&gt;"Victoria")</code></pre>
49
+
50
+ <p>The default application commands (<code>run</code>, <code>activate</code>, <code>quit</code>, etc.) are also available; see the appscript manual for details on those.</p>
51
+
52
+ <p>By default, <code>ScriptingAddition</code> objects are targeted at the current application. You can obtain a <code>ScriptingAddition</code> object targeted at another application by calling one of its <code>by...</code> methods.</p>
53
+
54
+
55
+
56
+ </div>
57
+
58
+ <!-- bottom navigation -->
59
+
60
+ <div class="footer">
61
+ <a href="index.html">Previous</a> &bull;
62
+ <a href="index.html">Up</a> &bull;
63
+ <a href="02_interface.html">Next</a>
64
+
65
+ <span>&copy; 2006-2008 HAS</span>
66
+ </div>
67
+
68
+ </body>
69
+ </html>