rb-appscript 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/CHANGES +45 -0
  2. data/README +5 -1
  3. data/TODO +3 -23
  4. data/doc/aem-manual/04_references.html +6 -6
  5. data/doc/aem-manual/05_targettingapplications.html +3 -3
  6. data/doc/aem-manual/07_findapp.html +1 -1
  7. data/doc/appscript-manual/04_gettinghelp.html +81 -7
  8. data/doc/appscript-manual/05_keywordconversion.html +18 -18
  9. data/doc/appscript-manual/07_applicationobjects.html +4 -4
  10. data/doc/appscript-manual/08_realvsgenericreferences.html +2 -2
  11. data/doc/appscript-manual/09_referenceforms.html +12 -14
  12. data/doc/appscript-manual/11_applicationcommands.html +1 -1
  13. data/doc/appscript-manual/14_notes.html +12 -12
  14. data/doc/osax-manual/index.html +2 -0
  15. data/rb-appscript.gemspec +2 -2
  16. data/sample/AB_list_people_with_emails.rb +3 -0
  17. data/sample/Add_iCal_event.rb +3 -0
  18. data/sample/Create_daily_iCal_todos.rb +2 -0
  19. data/sample/Export_Address_Book_phone_numbers.rb +3 -0
  20. data/sample/Hello_world.rb +3 -0
  21. data/sample/List_iTunes_playlist_names.rb +3 -0
  22. data/sample/Make_Mail_message.rb +3 -0
  23. data/sample/Open_file_in_TextEdit.rb +3 -0
  24. data/sample/Organize_Mail_messages.rb +3 -0
  25. data/sample/Print_folder_tree.rb +3 -0
  26. data/sample/Select_all_HTML_files.rb +3 -0
  27. data/sample/Set_iChat_status.rb +3 -0
  28. data/sample/Simple_Finder_GUI_Scripting.rb +6 -3
  29. data/sample/Stagger_Finder_windows.rb +3 -0
  30. data/sample/TextEdit_demo.rb +3 -0
  31. data/sample/iTunes_top40_to_html.rb +3 -0
  32. data/src/SendThreadSafe.c +380 -0
  33. data/src/SendThreadSafe.h +139 -0
  34. data/src/lib/_aem/aemreference.rb +46 -18
  35. data/src/lib/_aem/codecs.rb +19 -3
  36. data/src/lib/_aem/mactypes.rb +2 -6
  37. data/src/lib/_aem/send.rb +1 -1
  38. data/src/lib/_aem/typewrappers.rb +2 -2
  39. data/src/lib/_appscript/referencerenderer.rb +10 -4
  40. data/src/lib/_appscript/reservedkeywords.rb +4 -4
  41. data/src/lib/_appscript/terminology.rb +43 -35
  42. data/src/lib/aem.rb +8 -4
  43. data/src/lib/appscript.rb +78 -15
  44. data/src/lib/kae.rb +4 -0
  45. data/src/lib/osax.rb +9 -6
  46. data/src/rbae.c +102 -23
  47. data/test/test_aemreference.rb +4 -4
  48. data/test/test_appscriptcommands.rb +2 -2
  49. data/test/test_appscriptreference.rb +4 -4
  50. data/test/test_codecs.rb +14 -1
  51. data/test/test_findapp.rb +1 -1
  52. data/test/test_mactypes.rb +1 -1
  53. data/test/test_osax.rb +1 -1
  54. data/test/testall.sh +1 -1
  55. metadata +4 -2
data/CHANGES CHANGED
@@ -1,3 +1,48 @@
1
+ 2007-08-17 -- 0.4.0 (beta 1)
2
+
3
+ - renamed the following aem/appscript methods to be consistent with AppleScript:
4
+
5
+ start -> beginning
6
+ starts_with -> begins_with
7
+ does_not_start_with -> does_not_begin_with
8
+ start_transaction -> begin_transaction
9
+
10
+ Users should update existing code as necessary.
11
+
12
+ - aem and appscript no longer accept non-test references as test clauses. Previously, a reference such as 'its.visible' would automatically be expanded to the comparison test 'its.visible.eq(true)' as a convenience. However, this shortcut didn't apply when these non-test references appeared as arguments to the #and and #or logical test methods, which meant that this shortcut behaviour was inconsistent and potentially confusing; therefore it has been removed. Users should update existing code as necessary.
13
+
14
+ - added AE::AEDesc#send_thread_safe; this is now used by AEM instead of AE::AEDesc.send to allow reply events to be received on non-main threads (note: this is a non-issue in non-threaded processes or in processes that only use Ruby 1.x's green threads within the main native thread, but as the additional overhead isn't noticeable it does no harm to make it the default behaviour anyway).
15
+
16
+ - added AE::AEDesc#flatten and AE::AEDesc.unflatten for serialising AEDescs
17
+
18
+ - added support for custom reference roots in AEM and Appscript
19
+
20
+ - AEM::Application#inspect now displays correct class name when Application class is subclassed
21
+
22
+ - Appscript::Reference#[] now accepts real references and aem specifiers as by-filter test clauses (previously only accepted GenericReference)
23
+
24
+ - added note about rubygems to appscript manual; added rubygems support to sample scripts
25
+
26
+ - aete parser no longer raises error if aete isn't fully parsed (i.e. same as AppleScript) [SI]
27
+
28
+ - added Appscript::Reference#help
29
+
30
+
31
+ 2007-04-10 -- 0.3.1
32
+
33
+ - 64-bit support in rbae.c [JB]
34
+
35
+ - Terminology.dump will use 'ascrgdte' event to obtain aetes if AE.get_app_terminology is unavailable
36
+
37
+ - added TypeUInt16, TypeUInt64 support to Codecs#unpack
38
+
39
+ - added Codecs#pack_uint16; by default, this packs numbers in range (2**63)..(2**64 - 1) as 64-bit floats (lossy), but clients could override this to pack as TypeUInt64 where supported by OS and applications
40
+
41
+ - changed timeout for ascrgdte event to 120 sec
42
+
43
+ - terminology parser no longer errors on zero-length aetes
44
+
45
+
1
46
  2007-01-18 -- 0.3.0
2
47
 
3
48
  - removed 'AS' alias; client scripts should refer to Appscript module, e.g.:
data/README CHANGED
@@ -27,7 +27,11 @@ Please note that the version of Ruby included with Mac OS X 10.4 is missing the
27
27
  ======================================================================
28
28
  NOTES
29
29
 
30
- - rb-appscript 0.3.0 contains a couple of API changes from rb-appscript 0.2.x; see the CHANGES file and documentation for details
30
+ - rb-appscript 0.4.0 is the first beta release. Except for bug fixes, no further changes are planned prior to the 1.0 release.
31
+
32
+ - rb-appscript 0.4.0 contains a couple of API changes from earlier versions; see the CHANGES file and documentation for details
33
+
34
+ - rb-appscript 0.4.0 provides preliminary 64-bit support for OS X 10.5 in the following modules: AE, AEM, Appscript. Note that the OSAX module currently remains 32-bit only; this will be addressed after OS X 10.5 is released.
31
35
 
32
36
  ======================================================================
33
37
  AUTHOR
data/TODO CHANGED
@@ -1,27 +1,7 @@
1
1
  TO DO
2
2
 
3
- - see if there's a way to provide a SafeObject base class for Appscript::Reference and Appscript::GenericReference that doesn't depend on inserting callbacks into Module (or are Rubyists fine with the current approach?)
3
+ - Add a libxml2-based sdef parser for use by Terminology.dump, OSAX::ScriptingAddition in 64-bit Leopard as OSAGetAppTerminology is not available there. Also use weak binding for OSAGetAppTerminology, OSACopyScriptingDefinition in rbae.c
4
4
 
5
- - see if it's possible to work better with irb's autocomplete (autocomplete support is currently limited to start of a reference; not sure why)
5
+ - can numbers in range (2**63)..(2**64 - 1) safely be packed as typeUInt64 on 10.5+? Or stick with packing those as lossy 64-bit floating point for compatibility?
6
6
 
7
- - ae/aem/appscript-defined exception classes aren't quite idiomatic Ruby
8
-
9
- - any additional tests
10
-
11
- - improve/polish documentation
12
-
13
- - see also TO DO comments in rbae.c
14
-
15
- -------
16
-
17
- - _aem/connect.rb module refers directly to Send::Event instead of going via the AEM::Application::Event hook, which might cause problems when used in an OSA component or other situation where client needs to customise all event creation and/or dispatch.
18
-
19
- - support sending and receiving events on non-main threads
20
-
21
- - provide an example project (or source for) that uses ruby2exe to build a standalone 'applet'
22
-
23
- - any more built-in Ruby class<->AE type converters needed?
24
-
25
- - in AEM::CommandError, extract and report any kOSA... error parameters, if present
26
-
27
- - implement built-in help by bridging to osadict
7
+ - _aem/connect.rb module refers directly to Send::Event instead of going via the AEM::Application::Event hook, which might cause problems when used in an OSA component or other situation where client needs to customise all event creation and/or dispatch.
@@ -117,7 +117,7 @@ p ref
117
117
 
118
118
  <p><img src="aemreferenceinheritance.gif" title="aem reference class hierarchy" />
119
119
 
120
- <p>Note that the user shouldn't instantiate these classes directly; instead, aem will instantiate them as appropriate when the client calls the properties and methods of one of the three root objects - <code>app</code>, <code>con</code>, <code>its</code> - of of other aem reference objects.</p>
120
+ <p>Note that the user shouldn't instantiate these classes directly; instead, aem will instantiate them as appropriate when the client calls the methods of other aem reference objects, starting with the <code>app</code>, <code>con</code> and <code>its</code> objects that form the root of all aem references.</p>
121
121
 
122
122
  <p>In fact, it really isn't necessary to remember the reference class hierarchy at all, only to know which concrete classes implement which methods. All user-accessible properties and methods are defined by just four superclasses:</p>
123
123
 
@@ -154,7 +154,7 @@ p ref
154
154
 
155
155
  Methods:
156
156
 
157
- start
157
+ beginning
158
158
  Result : InsertionSpecifier
159
159
 
160
160
  end
@@ -213,7 +213,7 @@ p ref
213
213
  val : anything
214
214
  Result : Test
215
215
 
216
- starts_with(val) -- self starts with value
216
+ begins_with(val) -- self begins with value
217
217
  val : anything
218
218
  Result : Test
219
219
 
@@ -311,7 +311,7 @@ p ref
311
311
  <h3>Insertion location reference form</h3>
312
312
 
313
313
  <pre><code>InsertionSpecifier &lt; Specifier -- refers to insertion point before or after/at
314
- start or end of element(s); e.g. ref.before</code></pre>
314
+ beginning or end of element(s); e.g. ref.before</code></pre>
315
315
 
316
316
  <h3>Property reference forms</h3>
317
317
 
@@ -350,14 +350,14 @@ ElementByRelativePosition &lt; SingleElement -- refers to the previous or next e
350
350
  <h3>Multiple element reference forms</h3>
351
351
 
352
352
  <pre><code>ElementsByRange &lt; MultipleElements -- refers to a range of elements
353
- in the referenced container object(s) (including start and
353
+ in the referenced container object(s) (including beginning and
354
354
  end points); e.g. ref.by_range(AEM.con.elements('cpar').by_index(2),
355
355
  AEM.con.elements('cpar').last)
356
356
 
357
357
 
358
358
  ElementsByFilter &lt; MultipleElements -- refers to all elements in the
359
359
  referenced container object(s) that fulfill a given condition;
360
- e.g. ref.by_filter(AEM.its.name.startswith('a'))
360
+ e.g. ref.by_filter(AEM.its.name.begins_with('a'))
361
361
 
362
362
 
363
363
  AllElements(MultipleElements) -- refers to all elements of
@@ -61,8 +61,8 @@
61
61
 
62
62
  event(...) -- construct an Apple event (see next chapter for details)
63
63
 
64
- start_transaction(session=nil) -- start a new transaction;
65
- all Events constructed after start_transaction is
64
+ begin_transaction(session=nil) -- begin a new transaction;
65
+ all Events constructed after begin_transaction is
66
66
  called will belong to the same transaction until
67
67
  end_transaction or abort_transaction is called
68
68
  session : anything -- optional value identifying the
@@ -104,7 +104,7 @@ KAE::TypeProcessSerialNumber</code></pre>
104
104
 
105
105
  <h2>Transactions</h2>
106
106
 
107
- <p>The <code>start_transaction</code> and <code>end_transaction</code> methods are used to start and stop transaction sessions for applications that support this. All events <em>created</em> while a transaction session is active will be identified as part of that transaction.</p>
107
+ <p>The <code>begin_transaction</code> and <code>end_transaction</code> methods are used to start and stop transaction sessions for applications that support this. All events <em>created</em> while a transaction session is active will be identified as part of that transaction.</p>
108
108
 
109
109
  <p>Note that during a transaction, sending the application an event not created during that transaction will cause an error. Similarly, sending the application an event created during a transaction after that transaction has ended will cause an error.</p>
110
110
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  <h2>The <code>FindApp</code> module</h2>
27
27
 
28
- <p>The findapp module is used to obtain the full path to an application given it file name, bundle ID, or creator code. It exports the following functions:</p>
28
+ <p>The <code>FindApp</code> module is used to obtain the full path to an application given it file name, bundle ID, or creator code. It exports the following functions:</p>
29
29
 
30
30
  <pre><code>by_name(name) -- Find the application with the given name.
31
31
  name : string -- application's name, e.g. 'Finder.app'. The '.app' suffix
@@ -20,7 +20,80 @@
20
20
 
21
21
  <!-- content -->
22
22
  <div id="content">
23
- <p>There are several ways to get information about applications' scripting interfaces: the <code>osadict</code> command-line tool, the ASDictionary application, and introspection.</p>
23
+ <p>When developing appscript-based scripts, there are several ways to get information about applications' scripting interfaces: the built-in <code>help</code> method, the ASDictionary and <code>osadict</code> tools, and introspection.</p>
24
+
25
+
26
+
27
+ <h2>Built-in <code>help</code> method</h2>
28
+
29
+ <p>Appscript's <code>Application</code> and <code>Reference</code> classes include a powerful interactive help system that allows you to explore applications' scripting interfaces from within running scripts and Ruby's interactive <code>irb</code> interpreter. The <code>help</code> method can provide information on any suite, class, command or reference, and display the inheritance and relationships for a selected class or the entire application.</p>
30
+
31
+ <div class="hilitebox">
32
+ <p>Rb-appscript's built-in <code>help</code> method relies on the AppscriptHelpAgent application, available separately from the <a href="http://rb-appscript.rubyforge.org">appscript website</a>. See the AppscriptHelpAgent Read Me for installation instructions.</p>
33
+
34
+ <p>Note that AppscriptHelpAgent is <em>not</em> required to access any other feature of rb-appscript, and its installation it is entirely optional. If AppscriptHelpAgent is not installed, invoking <code>help</code> will simply result in a "No help available" message being displayed and the script will continue to run as normal.</p>
35
+ </div>
36
+
37
+ <p>Built-in help is invoked by calling an <code>app</code> object's <code>help</code> method, optionally passing it a string indicating the type of information you want. For example, to view the help system's own help, call the <code>help</code> method with <code>'-h'</code> as its argument:</p>
38
+
39
+ <pre><code>app('TextEdit').help('-h')</code></pre>
40
+
41
+ <p>To print a description of any class or command or view inheritance and relationships, pass the <code>help</code> method a help string containing one or more of the following options:</p>
42
+
43
+ <dl>
44
+ <dt>-h</dt>
45
+ <dd>show help</dd>
46
+ <dt>-o</dt>
47
+ <dd>overview of all suites, classes and commands</dd>
48
+ <dt>-k</dt>
49
+ <dd>list all built-in keywords (type names)</dd>
50
+ <dt>-u [suite-name]</dt>
51
+ <dd>summary of named suite or all suites</dd>
52
+ <dt>-t [class-or-command-name]</dt>
53
+ <dd>terminology for named class/command or current reference</dd>
54
+ <dt>-i [class-name]</dt>
55
+ <dd>inheritance tree for named class or all classes</dd>
56
+ <dt>-r [class-name]</dt>
57
+ <dd>one-to-one and one-to-many relationships for named class or current reference</dd>
58
+ <dt>-s [property-or-element-name]</dt>
59
+ <dd>values of properties and elements of object(s) currently referenced</dd>
60
+ </dl>
61
+
62
+ <p>Arguments (shown in brackets) are optional. Additional information on usage is available via <code>help('-h')</code>.</p>
63
+
64
+ <p>Examples:</p>
65
+
66
+ <pre><code>app('Finder').help('-o')
67
+ app('Finder').help('-t window')
68
+ app('Finder').files.help # same as help('-t')
69
+ app('Finder').help('-d item -r folder -i container')
70
+ app('Finder').files.help('-s')</code></pre>
71
+
72
+
73
+ <p>To print detailed information on a specific reference, call its <code>help</code> method without arguments. Examples:</p>
74
+
75
+ <pre><code>app('TextEdit').help
76
+ app('TextEdit').version.help
77
+ app('TextEdit').documents.help</code></pre>
78
+
79
+
80
+ <p>To print detailed information on a specific command, call the <code>help</code> method on an application or reference object with the <code>-t</code> option followed by the command's name. Examples:</p>
81
+
82
+ <pre><code>app('TextEdit').help('-t open')
83
+ app('TextEdit').documents.help('-t count -t close')</code></pre>
84
+
85
+ <div class="hilitebox">
86
+ <p>Tip: <code>help</code> calls can safely be inserted at any point in a reference without disrupting your script's execution:</p>
87
+
88
+ <pre><code>c = app('TextEdit')<strong>.help.help('-o -i -s')</strong>.documents.<strong>help</strong>[1]<strong>.help</strong>.count</code></pre>
89
+ </div>
90
+
91
+
92
+
93
+ <h2>ASDictionary</h2>
94
+
95
+ <p>ASDictionary, available from the <a href="http://sourceforge.net/projects/appscript"> py-appscript website</a>, provides a convenient GUI interface for exporting application terminology resources in plain text and HTML formats. ASDictionary can export HTML dictionaries in both single-file format and a frame-based format similar to rdoc's.</p>
96
+
24
97
 
25
98
 
26
99
  <h2>osadict</h2>
@@ -49,14 +122,10 @@ iCal&gt; exit
49
122
  osadict -Ns rb StandardAdditions -t display dialog</code></pre>
50
123
 
51
124
 
52
- <h2>ASDictionary</h2>
53
-
54
- <p>ASDictionary, available from the <a href="http://sourceforge.net/projects/appscript"> py-appscript website</a>, renders application terminology resources in plain text and HTML formats. It provides a convenient drag-n-drop alternative to using the <code>osadict -H ...</code> command.</p>
55
-
56
125
 
57
126
  <h2>Introspection</h2>
58
127
 
59
- <p>Appscript's <code>Application</code> and <code>Reference</code> classes define several methods for obtaining information on the target application: </p>
128
+ <p>Appscript's <code>Application</code> and <code>Reference</code> classes define several instance methods for obtaining information on the target application: </p>
60
129
 
61
130
  <dl>
62
131
  <dt><code>properties</code></dt>
@@ -75,7 +144,7 @@ osadict -Ns rb StandardAdditions -t display dialog</code></pre>
75
144
  <dd>Takes a command's name as string and returns the names of its parameters.</dd>
76
145
  </dl>
77
146
 
78
- <p>Like Ruby's standard <code>methods</code> method, all of these methods return a list of strings.</p>
147
+ <p>As with Ruby's <code>Object#methods</code>, all of these methods return a list of strings.</p>
79
148
 
80
149
  <p>Examples</p>
81
150
 
@@ -88,6 +157,11 @@ p te.parameters('make')
88
157
  # ["at", "new", "with_data", "with_properties"]</code></pre>
89
158
 
90
159
 
160
+ <h2>Notes</h2>
161
+
162
+ <p>While appscript's documentation systems try to be reasonably forgiving of flawed or faulty terminology resources, there may be a few particularly problematic applications on which they fail. Should this happen, use ASDictionary to export the application's terminology in plain text format instead.</p>
163
+
164
+
91
165
  <h2>Other sources of help</h2>
92
166
 
93
167
  <ul>
@@ -37,11 +37,14 @@
37
37
 
38
38
  <li>Names that match the methods already defined on appscript's Application and Reference classes have an underscore appended. The reserved method names are:
39
39
 
40
- <pre><code>abort_transaction instance_variable_get
41
- after instance_variable_set
42
- and instance_variables
43
- any is_in
44
- before is_not_in
40
+ <pre><code>abort_transaction ignore
41
+ after inspect
42
+ and instance_eval
43
+ any instance_variable_get
44
+ before instance_variable_set
45
+ begin_transaction instance_variables
46
+ beginning is_in
47
+ begins_with is_not_in
45
48
  by_aem_app keywords
46
49
  by_creator last
47
50
  by_id launch
@@ -54,9 +57,9 @@ commands middle
54
57
  contains ne
55
58
  current next
56
59
  display not
57
- does_not_contain object_id
58
- does_not_end_with or
59
- does_not_start_with parameters
60
+ does_not_begin_with object_id
61
+ does_not_contain or
62
+ does_not_end_with parameters
60
63
  dup previous
61
64
  elements private_methods
62
65
  end properties
@@ -65,16 +68,13 @@ ends_with public_methods
65
68
  eq result_type
66
69
  extend send
67
70
  first singleton_methods
68
- freeze start
69
- ge start_transaction
70
- gt starts_with
71
- hash taint
72
- help timeout
73
- ID to_a
74
- id to_s
75
- ignore type
76
- inspect untaint
77
- instance_eval wait_reply</code></pre>
71
+ freeze taint
72
+ ge timeout
73
+ gt to_a
74
+ hash to_s
75
+ help type
76
+ ID untaint
77
+ id wait_reply</code></pre>
78
78
  </div>
79
79
  </li>
80
80
  </ul>
@@ -48,7 +48,7 @@ app.current # the host process</code></pre>
48
48
 
49
49
  <dl>
50
50
  <dt><code>name</code></dt>
51
- <dd>The application's filename or POSIX path, e.g. <code>'TextEdit'</code>, <code>'TextEdit.app'</code>, <code>'/Applications/TextEdit.app'</code>. Where a filename is provided, appscript uses LaunchServices to locate the application. Paths beginning with <code>~</code>, e.g. <code>'~/Dev/MyApp.app'</code>, will be expanded automatically. An <code>.app</code> suffix is optional. For example, given the name <code>'TextEdit'</code>, appscript will first search for an application with that exact name. If none is found, it'll automatically add a <code>.app</code> suffix (<code>'TextEdit.app'</code>) and try again.</dd>
51
+ <dd>The application's filename or POSIX path, e.g. <code>'TextEdit'</code>, <code>'TextEdit.app'</code>, <code>'/Applications/TextEdit.app'</code>. Where a filename is provided, appscript uses LaunchServices to locate the application. An <code>.app</code> suffix is optional. e.g. Given the name <code>'TextEdit'</code>, appscript first searches for an application with that exact filename; if none is found, it automatically adds an <code>.app</code> suffix (<code>'TextEdit.app'</code>) and tries again.</dd>
52
52
 
53
53
  <dt><code>id</code></dt>
54
54
  <dd>The application's bundle id, e.g. <code>'com.apple.textedit'</code>. Cocoa applications often have unique bundle ids.</dd>
@@ -131,11 +131,11 @@ set(reference, :to =&gt; value) -- Set an object's data.
131
131
 
132
132
  <h2>Transaction support</h2>
133
133
 
134
- <p>Application objects implement three additional methods, <code>start_transaction</code>, <code>end_transaction</code> and <code>abort_transaction</code> that allow a sequence of related commands to be handled as a single operation by applications that support transactions, e.g. FileMaker Pro.</p>
134
+ <p>Application objects implement three additional methods, <code>begin_transaction</code>, <code>end_transaction</code> and <code>abort_transaction</code> that allow a sequence of related commands to be handled as a single operation by applications that support transactions, e.g. FileMaker Pro.</p>
135
135
 
136
- <p>Once the application object's <code>start_transaction</code> method is called, all subsequent commands to that application will be sent as part of the same transaction until <code>end_transaction</code> or <code>abort_transaction</code> is called.</p>
136
+ <p>Once the application object's <code>begin_transaction</code> method is called, all subsequent commands to that application will be sent as part of the same transaction until <code>end_transaction</code> or <code>abort_transaction</code> is called.</p>
137
137
 
138
- <p>The <code>start_transaction</code> method takes an optional <code>session</code> argument that indicates the specific transaction session to open (in applications that support this).</p>
138
+ <p>The <code>begin_transaction</code> method takes an optional <code>session</code> argument that indicates the specific transaction session to open (in applications that support this).</p>
139
139
 
140
140
  <p class="hilitebox">Remember to call <code>end_transaction</code> or <code>abort_transaction</code> at the end of every transaction. (This includes transactions interrupted by a raised exception.) If a transaction is accidentally left open, appscript will try to end it automatically when the application object is garbage-collected, but this is not guaranteed to succeed.</p>
141
141
 
@@ -36,11 +36,11 @@ app.by_url('eppc://my-mac.local/Finder').home.folders.name</code></pre>
36
36
 
37
37
  <pre><code>app.documents.end
38
38
  con.word[3]
39
- its.name.starts_with('d')</code></pre>
39
+ its.name.begins_with('d')</code></pre>
40
40
 
41
41
  <p>Generic references are only evaluated when used used within real references, either as selectors:</p>
42
42
 
43
- <pre><code>app('Finder').home.folders[<em>its.name.starts_with('d')</em>].get
43
+ <pre><code>app('Finder').home.folders[<em>its.name.begins_with('d')</em>].get
44
44
 
45
45
  app('Tex-Edit Plus').windows[1].text[<em>con.words[2]</em>, <em>con.words[-2]</em>].get</code></pre>
46
46
 
@@ -106,7 +106,7 @@ files.any</code></pre>
106
106
  before the specified element
107
107
  elements[selector].next(class) -- nearest element of a given class to appear
108
108
  after the specified element
109
- class : Symbol -- class of element (see <a href="4_classesandenums.html">Classes and Enumerated Types</a>)</code></pre>
109
+ class : Symbol -- class of element (see <a href="06_classesandenums.html">Classes and Enumerated Types</a>)</code></pre>
110
110
 
111
111
  <p>Examples:</p>
112
112
  <pre><code>words[3].next(:word)
@@ -115,11 +115,11 @@ paragraphs[-1].previous(:character)</code></pre>
115
115
 
116
116
  <h3>by Range</h3>
117
117
 
118
- <p>Range references select all elements between and including two references indicating the start and end of the range. The start and end references are normally declared relative to the container of the elements being selected. Appscript defines an object, <code>con</code> (short for 'container'), to indicate this container; for example, to indicate the third paragraph of the currrent container object:</p>
118
+ <p>Range references select all elements between and including two references indicating the start and stop of the range. The start and stop references are normally declared relative to the container of the elements being selected. Appscript defines an object, <code>con</code> (short for 'container'), to indicate this container; for example, to indicate the third paragraph of the currrent container object:</p>
119
119
 
120
120
  <pre><code>con.paragraphs[3]</code></pre>
121
121
 
122
- <p>For convenience, the range reference also allows start and end references to be written in shorthand form where their element class is the same as the elements being selected; thus:</p>
122
+ <p>For convenience, the range reference also allows start and stop references to be written in shorthand form where their element class is the same as the elements being selected; thus:</p>
123
123
 
124
124
  <pre><code>ref.paragraphs[con.paragraphs[3], con.paragraphs[-1]]</code></pre>
125
125
 
@@ -132,16 +132,16 @@ paragraphs[-1].previous(:character)</code></pre>
132
132
  <pre><code>ref.words[con.characters[5], con.paragraphs[-2]]</code></pre>
133
133
 
134
134
  <p>Syntax:</p>
135
- <pre><code>elements[start, end]
136
- start : Fixnum | Bignum | String | Reference -- start of range
137
- end : Fixnum | Bignum | String | Reference -- end of range</code></pre>
135
+ <pre><code>elements[start, stop]
136
+ start : Fixnum | Bignum | String | Reference -- beginning of range
137
+ stop : Fixnum | Bignum | String | Reference -- end of range</code></pre>
138
138
 
139
139
  <p>Examples:</p>
140
140
  <pre><code>folders['Documents', 'Movies']
141
141
  documents[1, 3]
142
142
  text[con.characters[5], con.words[-2]]</code></pre>
143
143
 
144
- <p class="hilitebox">Note: ranges are specified as [start-position, <em>end-position</em>] (AEM-style ranges), not [start-position, <em>length</em>] (Ruby-style ranges).</p>
144
+ <p class="hilitebox">Note: ranges are specified as [start-position, <em>stop-position</em>] (AEM-style ranges), not [start-position, <em>length</em>] (Ruby-style ranges).</p>
145
145
 
146
146
  <h3>by Filter</h3>
147
147
 
@@ -167,11 +167,11 @@ reference.eq(value) # ==
167
167
  reference.ne(value) # !=
168
168
  reference.gt(value) # &gt;
169
169
  reference.ge(value) # &gt;=
170
- reference.starts_with(value)
170
+ reference.begins_with(value)
171
171
  reference.ends_with(value)
172
172
  reference.contains(value)
173
173
  reference.is_in(value)
174
- reference.does_not_start_with(value)
174
+ reference.does_not_begin_with(value)
175
175
  reference.does_not_end_with(value)
176
176
  reference.does_not_contain(value)
177
177
  reference.is_not_in(value)
@@ -180,11 +180,9 @@ reference.is_not_in(value)
180
180
  <p>Examples:</p>
181
181
  <pre><code>its.eq('')
182
182
  its.size.gt(1024)
183
- its.words.first.starts_with('A')
183
+ its.words.first.begins_with('A')
184
184
  its.characters.first.eq(its.characters.last)</code></pre>
185
185
 
186
- <p>Note that Boolean comparison tests can be written as either <code>reference.eq(true)</code> or just <code>reference</code>, e.g. <code>folderRef.files[its.locked]</code></p></li>
187
-
188
186
  <li><p>Zero or more logical tests, implemented as properties/methods on conditional tests. The <code>and</code> and <code>or</code> methods take one or more conditional or logic tests as arguments.</p>
189
187
 
190
188
  <p>Syntax:</p>
@@ -195,7 +193,7 @@ test.not</code></pre>
195
193
  <p>Examples:</p>
196
194
  <pre><code>its.eq('').not
197
195
  its.size.gt(1024).and(its.size.lt(10240))
198
- its.words[1].starts_with('A').or(
196
+ its.words[1].begins_with('A').or(
199
197
  its.words[2].contains('ce'),
200
198
  its.words[1].eq('Foo'))</code></pre></li>
201
199
  </ul>
@@ -207,7 +205,7 @@ its.words[1].starts_with('A').or(
207
205
  <p>Insertion locations can be specified at the beginning or end of all elements, or before or after a specified element or element range.</p>
208
206
 
209
207
  <p>Syntax:</p>
210
- <pre><code>elements.start
208
+ <pre><code>elements.beginning
211
209
  elements.end
212
210
  elements[selector].before
213
211
  elements[selector].after</code></pre>