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.
- data/CHANGES +30 -0
- data/LICENSE +1 -1
- data/README +7 -3
- data/TODO +7 -1
- data/doc/aem-manual/01_introduction.html +23 -9
- data/doc/aem-manual/02_apioverview.html +25 -11
- data/doc/aem-manual/03_packingandunpackingdata.html +22 -17
- data/doc/aem-manual/04_references.html +49 -36
- data/doc/aem-manual/05_targettingapplications.html +25 -14
- data/doc/aem-manual/06_buildingandsendingevents.html +47 -21
- data/doc/aem-manual/07_findapp.html +22 -11
- data/doc/aem-manual/08_examples.html +21 -10
- data/doc/aem-manual/index.html +28 -12
- data/doc/appscript-manual/01_introduction.html +40 -27
- data/doc/appscript-manual/02_aboutappscripting.html +28 -15
- data/doc/appscript-manual/03_quicktutorial.html +29 -16
- data/doc/appscript-manual/04_gettinghelp.html +31 -16
- data/doc/appscript-manual/05_keywordconversion.html +23 -10
- data/doc/appscript-manual/06_classesandenums.html +32 -19
- data/doc/appscript-manual/07_applicationobjects.html +31 -18
- data/doc/appscript-manual/08_realvsgenericreferences.html +23 -11
- data/doc/appscript-manual/09_referenceforms.html +33 -20
- data/doc/appscript-manual/10_referenceexamples.html +30 -17
- data/doc/appscript-manual/11_applicationcommands.html +25 -13
- data/doc/appscript-manual/12_commandexamples.html +26 -15
- data/doc/appscript-manual/13_performanceissues.html +46 -20
- data/doc/appscript-manual/14_notes.html +29 -19
- data/doc/appscript-manual/index.html +27 -11
- data/doc/full.css +95 -9
- data/doc/index.html +27 -10
- data/doc/mactypes-manual/01_introduction.html +56 -0
- data/doc/mactypes-manual/02_aliasclass.html +134 -0
- data/doc/mactypes-manual/03_fileurlclass.html +136 -0
- data/doc/mactypes-manual/04_unitsclass.html +102 -0
- data/doc/mactypes-manual/index.html +26 -227
- data/doc/osax-manual/01_introduction.html +69 -0
- data/doc/osax-manual/02_interface.html +149 -0
- data/doc/osax-manual/03_examples.html +75 -0
- data/doc/osax-manual/04_notes.html +80 -0
- data/doc/osax-manual/index.html +26 -195
- data/doc/rb-appscript-logo.png +0 -0
- data/rb-appscript.gemspec +2 -2
- data/sample/TextEdit_demo.rb +1 -1
- data/src/lib/_aem/aemreference.rb +1 -1
- data/src/lib/_aem/codecs.rb +42 -8
- data/src/lib/_aem/connect.rb +3 -1
- data/src/lib/_aem/findapp.rb +1 -1
- data/src/lib/_aem/mactypes.rb +1 -1
- data/src/lib/_aem/send.rb +162 -142
- data/src/lib/_aem/typewrappers.rb +2 -2
- data/src/lib/_appscript/defaultterminology.rb +76 -46
- data/src/lib/_appscript/referencerenderer.rb +1 -1
- data/src/lib/_appscript/reservedkeywords.rb +2 -2
- data/src/lib/_appscript/safeobject.rb +1 -1
- data/src/lib/_appscript/terminology.rb +30 -19
- data/src/lib/aem.rb +1 -6
- data/src/lib/appscript.rb +65 -20
- data/src/lib/osax.rb +21 -18
- data/src/rbae.c +1 -1
- data/test/test_appscriptcommands.rb +1 -1
- metadata +12 -3
data/doc/full.css
CHANGED
@@ -1,20 +1,106 @@
|
|
1
|
-
body {font-family:
|
1
|
+
body {font-family:Arial,sans-serif; line-height:140%; color:#000; background-color:#fff; margin: 0 12% 0 8%;}
|
2
|
+
|
3
|
+
/*headings*/
|
4
|
+
|
5
|
+
h2, h3, h4 {font-family: Palatino, Georgia, Serif; color:#00457e; background-color:transparent; font-weight:bold;}
|
6
|
+
|
7
|
+
h1 {font-family:Arial,sans-serif;color:#00457e; background-color:transparent; font-weight:bold;}
|
8
|
+
|
9
|
+
h1 {line-height:110%; padding: 0; margin-top:.7em; margin-bottom: .5em;}
|
10
|
+
h2 {font-size:1.6em; padding:0 0 1px; border-bottom:solid #f77700 2px; margin:1.4em 0 1em;}
|
11
|
+
h3 {font-size:1.3em; padding:0 0 0px; border-bottom:dotted #f77700 1px; margin:2em 0 0.8em 0;}
|
12
|
+
h4 {font-size:1.1em; margin:1.8em 0 0.6em 0;}
|
13
|
+
|
14
|
+
|
15
|
+
/*body text*/
|
16
|
+
|
17
|
+
|
18
|
+
p, li {margin: 1em 0;}
|
19
|
+
pre {font-size:1em;}
|
20
|
+
|
21
|
+
|
22
|
+
dl, pre {
|
23
|
+
line-height:130%; color:#000; background-color:#cedbef;
|
24
|
+
padding:1.8em 2em 2em; margin:1.2em 0em; border-bottom:solid #92b4db 6px;
|
25
|
+
}
|
26
|
+
|
27
|
+
dt, code {color:#00457e; background-color:transparent;}
|
2
28
|
|
3
|
-
#content {margin:2em 0 2.25em;}
|
4
29
|
dt {font-weight:bold;}
|
5
|
-
|
30
|
+
|
31
|
+
|
32
|
+
.hilitebox {padding:0.5em 0 0.55em; margin:1.3em 2em 1.4em; border:solid #f77700; border-width: 2px 0 2px; }
|
33
|
+
|
34
|
+
code {font-family:Courier,Monospace;}
|
35
|
+
|
36
|
+
pre code {color:#00406e; background-color:transparent;}
|
37
|
+
|
38
|
+
|
39
|
+
dd pre, .hilitebox pre {
|
40
|
+
color:#000; background-color:#cedbef;
|
41
|
+
padding:1.8em 2em 2em; margin:1.2em 2em 1.2em 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
dd+dt {margin-top:1em;}
|
46
|
+
h3+p {margin-top:-0.3em;}
|
47
|
+
h2+h3 {margin-top: 1.2em;}
|
48
|
+
h4+p {margin-top:-0.35em;}
|
49
|
+
|
50
|
+
|
6
51
|
.comment {color:#666; background-color:transparent;}
|
7
52
|
|
8
|
-
hr {height: 1px; background-color: #
|
53
|
+
hr {height: 1px; background-color: #00457e; border: 0px solid #00457e; margin-top:3em;}
|
9
54
|
|
55
|
+
dl hr {
|
56
|
+
color:#e8e8ff; background-color:transparent; height:1px;
|
57
|
+
border:dashed #00457e; border-width: 1px 0 0; margin:0 -2em;
|
58
|
+
}
|
10
59
|
|
11
|
-
table {
|
60
|
+
table {
|
61
|
+
line-height:130%; width:100%; color:#00457e; background-color:#cedbef;
|
62
|
+
border-bottom:solid #cedbef 10px; margin:1.2em 0em 2.4em;
|
63
|
+
border-collapse:collapse; padding: 0 0 2em;
|
64
|
+
}
|
12
65
|
|
13
|
-
th, td {padding: 0.4em 1.6em; margin: 0; border-width: 0;}
|
66
|
+
tr, th, td {padding: 0.4em 1.6em; margin: 0; border-width: 0;}
|
14
67
|
|
15
|
-
th {text-align:left; font-size:0.95em; color:#
|
68
|
+
th {text-align:left; font-size:0.95em; color:#00457e; background-color:#92b4db;}
|
16
69
|
|
17
70
|
thead {background-color:#ccd;}
|
18
|
-
|
19
71
|
|
20
|
-
|
72
|
+
|
73
|
+
/*links*/
|
74
|
+
|
75
|
+
/*a {font-style:italic;}*/
|
76
|
+
|
77
|
+
|
78
|
+
a:link {color:#00457e; background-color:transparent;}
|
79
|
+
a:visited {color:#445555; background-color:transparent;}
|
80
|
+
|
81
|
+
a img {border-width:0;}
|
82
|
+
|
83
|
+
/* navigation*/
|
84
|
+
|
85
|
+
.navbar {
|
86
|
+
font-size:0.9em; font-weight:bold; color:#e06000; background-color: #cedbef;
|
87
|
+
padding: 0.45em 13px 0.3em; margin:0 0 0; border-bottom:solid #92b4db 6px;
|
88
|
+
}
|
89
|
+
|
90
|
+
.navbar span {float:right; font-weight:normal;}
|
91
|
+
|
92
|
+
.navbar span strong a {color: #e06000;}
|
93
|
+
|
94
|
+
|
95
|
+
.navbar a:link, .navbar a:visited, .footer a:link, .footer a:visited {font-style:normal; text-decoration:none;}
|
96
|
+
.navbar a:hover, .navbar a:active, .footer a:hover, .footer a:active {text-decoration:underline;}
|
97
|
+
|
98
|
+
/*footer*/
|
99
|
+
|
100
|
+
.footer {
|
101
|
+
font-size:0.9em; font-weight:bold; color:#e06000; background-color: #cedbef;
|
102
|
+
text-align:left; padding: 0.3em 13px 0.5em; margin:3.8em 0 0; border-top:solid #92b4db 6px;
|
103
|
+
}
|
104
|
+
|
105
|
+
.footer span {float:right; font-weight: normal; color:#00457e; background-color:#cedbef;}
|
106
|
+
|
data/doc/index.html
CHANGED
@@ -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>
|
5
|
+
<title>rb-appscript manual | Index</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,22 +10,39 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
|
13
|
-
<h1
|
13
|
+
<h1><img src="rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
|
14
|
+
|
15
|
+
<!-- top navigation -->
|
16
|
+
<div class="navbar">
|
17
|
+
|
18
|
+
|
19
|
+
<span>
|
20
|
+
<a href="appscript-manual/index.html">appscript</a> /
|
21
|
+
<a href="mactypes-manual/index.html">mactypes</a> /
|
22
|
+
<a href="osax-manual/index.html">osax</a> /
|
23
|
+
<a href="aem-manual/index.html">aem</a>
|
24
|
+
</span>
|
25
|
+
</div>
|
14
26
|
|
15
27
|
|
16
28
|
<!-- content -->
|
17
29
|
<div id="content">
|
18
30
|
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
<li><a href="
|
23
|
-
<li><a href="
|
24
|
-
</
|
31
|
+
<h2>Manuals</h2>
|
32
|
+
|
33
|
+
<ul>
|
34
|
+
<li><a href="appscript-manual/index.html">rb-appscript</a> - high-level, user-friendly Apple event bridge</li>
|
35
|
+
<li><a href="mactypes-manual/index.html">rb-mactypes</a> - extra classes representing file and unit types</li>
|
36
|
+
<li><a href="osax-manual/index.html">rb-osax</a> - scripting addition support</li>
|
37
|
+
<li><a href="aem-manual/index.html">rb-aem</a> - lower-level interface to Mac OS X's Apple Event Manager</li>
|
38
|
+
</ul>
|
39
|
+
|
40
|
+
</div>
|
25
41
|
|
42
|
+
<div class="footer">
|
43
|
+
|
44
|
+
<span>© 2006-2008 HAS</span>
|
26
45
|
</div>
|
27
46
|
|
28
|
-
<!--footer-->
|
29
|
-
<p class="footer">© 2006-2008 HAS</p>
|
30
47
|
</body>
|
31
48
|
</html>
|
@@ -0,0 +1,56 @@
|
|
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 | 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> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="02_aliasclass.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>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<!-- content -->
|
30
|
+
<div id="content">
|
31
|
+
<h2>1. Introduction</h2>
|
32
|
+
|
33
|
+
<h3>About MacTypes</h3>
|
34
|
+
|
35
|
+
<p>The <code> MacTypes</code> module provides user-friendly wrappers for Apple event descriptors that do not have direct equivalents in the Ruby language. It contains Ruby classes for specifying filesystem objects and locations, and unit type values (lengths, weights, etc.), and is used in conjunction with the <code>Appscript</code>, <code>OSAX</code> and/or <code>AEM</code> modules. It is automatically imported when requiring appscript, aem or osax.</p>
|
36
|
+
|
37
|
+
|
38
|
+
<h3>Notes</h3>
|
39
|
+
|
40
|
+
<p>Be aware 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>
|
41
|
+
|
42
|
+
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<!-- bottom navigation -->
|
46
|
+
|
47
|
+
<div class="footer">
|
48
|
+
<a href="index.html">Previous</a> •
|
49
|
+
<a href="index.html">Up</a> •
|
50
|
+
<a href="02_aliasclass.html">Next</a>
|
51
|
+
|
52
|
+
<span>© 2006-2008 HAS</span>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
</body>
|
56
|
+
</html>
|
@@ -0,0 +1,134 @@
|
|
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 | 2. Alias 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="01_introduction.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="03_fileurlclass.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>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<!-- content -->
|
30
|
+
<div id="content">
|
31
|
+
|
32
|
+
<h2>2. The <code>MacTypes::Alias</code> class</h2>
|
33
|
+
|
34
|
+
<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>
|
35
|
+
|
36
|
+
|
37
|
+
<h3>Methods</h3>
|
38
|
+
|
39
|
+
<pre><code>Alias -- a persistent reference to a filesystem object
|
40
|
+
Constructors:
|
41
|
+
|
42
|
+
Alias.path(path) -- make Alias object from POSIX path string
|
43
|
+
|
44
|
+
Alias.hfs_path(path) -- make Alias object from HFS path string
|
45
|
+
|
46
|
+
Alias.url(url) -- make Alias object from a local file:// URL string
|
47
|
+
|
48
|
+
Alias.desc(desc) -- make Alias object from an AE::AEDesc
|
49
|
+
of TypeAlias
|
50
|
+
|
51
|
+
Methods:
|
52
|
+
|
53
|
+
==
|
54
|
+
|
55
|
+
hash
|
56
|
+
|
57
|
+
inspect
|
58
|
+
|
59
|
+
path -- returns POSIX path string to the object's current location
|
60
|
+
|
61
|
+
hfs_path -- returns HFS path string to the object's current location
|
62
|
+
|
63
|
+
url -- returns file:// URL string to the object's current location
|
64
|
+
|
65
|
+
desc -- returns AE::AEDesc of TypeAlias
|
66
|
+
|
67
|
+
to_s -- synonym for #path
|
68
|
+
|
69
|
+
to_alias -- returns self
|
70
|
+
|
71
|
+
to_file_url -- returns a MacTypes::FileURL object</code></pre>
|
72
|
+
|
73
|
+
|
74
|
+
<h3>Examples</h3>
|
75
|
+
|
76
|
+
<pre><code>require "appscript"
|
77
|
+
|
78
|
+
f = MacTypes::Alias.path('/Users/foo/some file')
|
79
|
+
|
80
|
+
puts f.to_s
|
81
|
+
# /Users/foo/some file
|
82
|
+
|
83
|
+
puts f.url
|
84
|
+
# file://localhost/Users/foo/some%20file
|
85
|
+
|
86
|
+
puts f.inspect
|
87
|
+
# MacTypes::Alias.path("/Users/foo/some file")
|
88
|
+
|
89
|
+
Appscript.app('TextEdit').open(f)
|
90
|
+
# opens document in TextEdit
|
91
|
+
|
92
|
+
MacTypes::Alias.path('/some/non/existent/location')
|
93
|
+
# File "/some/non/existent/location" not found.
|
94
|
+
# (MacTypes::FileNotFoundError)</code></pre>
|
95
|
+
|
96
|
+
|
97
|
+
<h3>Notes</h3>
|
98
|
+
|
99
|
+
<!-- TO DO: relative paths, normalisation
|
100
|
+
|
101
|
+
<p>When creating an <code>Alias</code> instance, POSIX paths may be either relative or absolute and are automatically normalised using <code>os.path.abspath</code>. Paths to non-existent filesystem locations will result in a <code>MacTypes::FileNotFoundError</code> being raised.</p>
|
102
|
+
|
103
|
+
-->
|
104
|
+
|
105
|
+
<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>
|
106
|
+
|
107
|
+
<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. using aliases as <code>Hash</code> keys).</p>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<!-- TO DO: where to put FileNotFoundError section? -->
|
112
|
+
|
113
|
+
<h3><code>MacTypes::FileNotFoundError</code></h3>
|
114
|
+
|
115
|
+
<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>
|
116
|
+
|
117
|
+
<pre><code>require "appscript"
|
118
|
+
|
119
|
+
MacTypes::Alias.path('/some/non/existent/location')
|
120
|
+
# raises FileNotFoundError</code></pre>
|
121
|
+
|
122
|
+
|
123
|
+
<!-- bottom navigation -->
|
124
|
+
|
125
|
+
<div class="footer">
|
126
|
+
<a href="01_introduction.html">Previous</a> •
|
127
|
+
<a href="index.html">Up</a> •
|
128
|
+
<a href="03_fileurlclass.html">Next</a>
|
129
|
+
|
130
|
+
<span>© 2006-2008 HAS</span>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</body>
|
134
|
+
</html>
|
@@ -0,0 +1,136 @@
|
|
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 | 3. FileURL 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="02_aliasclass.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="04_unitsclass.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>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<!-- content -->
|
30
|
+
<div id="content">
|
31
|
+
|
32
|
+
|
33
|
+
<h2>3. The <code>MacTypes::FileURL</code> class</h2>
|
34
|
+
|
35
|
+
<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>
|
36
|
+
|
37
|
+
<h3>Methods</h3>
|
38
|
+
|
39
|
+
<pre><code>FileURL -- identifies a fixed filesystem location
|
40
|
+
Constructors:
|
41
|
+
|
42
|
+
FileURL.path(path) -- make FileURL object from POSIX path string
|
43
|
+
|
44
|
+
FileURL.hfs_path(path) -- make FileURL object from HFS path string
|
45
|
+
|
46
|
+
FileURL.url(url) -- make FileURL object from a local file:// URL string
|
47
|
+
|
48
|
+
FileURL.desc(desc) -- make FileURL object from an AE::AEDesc
|
49
|
+
of TypeFSS, TypeFSRef or TypeFileURL
|
50
|
+
|
51
|
+
Methods:
|
52
|
+
|
53
|
+
==
|
54
|
+
|
55
|
+
hash
|
56
|
+
|
57
|
+
inspect
|
58
|
+
|
59
|
+
path -- returns POSIX path string
|
60
|
+
|
61
|
+
hfs_path -- returns HFS path string
|
62
|
+
|
63
|
+
url -- returns file:// URL string
|
64
|
+
|
65
|
+
desc -- returns AE::AEDesc of TypeFSRef, TypeFSS or TypeFileURL
|
66
|
+
|
67
|
+
to_s -- synonym for #path
|
68
|
+
|
69
|
+
to_alias -- returns a MacTypes::Alias object
|
70
|
+
|
71
|
+
to_file_url -- returns a new MacTypes::FileURL object</code></pre>
|
72
|
+
|
73
|
+
|
74
|
+
<h3>Examples</h3>
|
75
|
+
|
76
|
+
<pre><code>require "appscript"
|
77
|
+
|
78
|
+
f = MacTypes::FileURL.path('/Users/foo/new file')
|
79
|
+
|
80
|
+
puts f.to_s
|
81
|
+
# /Users/foo/new file
|
82
|
+
|
83
|
+
puts f.url
|
84
|
+
# file://localhost/Users/foo/some%20file
|
85
|
+
|
86
|
+
puts f.inspect
|
87
|
+
# MacTypes::FileURL.path("/Users/foo/new file")
|
88
|
+
|
89
|
+
Appscript.app('TextEdit').documents[1].save(:in => f)
|
90
|
+
# saves front TextEdit document at the given location</code></pre>
|
91
|
+
|
92
|
+
|
93
|
+
<h3>Notes</h3>
|
94
|
+
|
95
|
+
<!-- TO DO: relative paths, normalisations
|
96
|
+
|
97
|
+
<p>When creating a <code>File</code> instance, POSIX paths may be either relative or absolute and are automatically normalised using <code>os.path.abspath</code>.</p>
|
98
|
+
|
99
|
+
-->
|
100
|
+
|
101
|
+
<!-- TO DO: check this section for consistency with py-appscript manual -->
|
102
|
+
|
103
|
+
<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>
|
104
|
+
|
105
|
+
<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 instead:</p>
|
106
|
+
|
107
|
+
<pre><code>require "appscript"
|
108
|
+
|
109
|
+
file_url = MacTypes::FileURL.path('/Users/foo/new file')
|
110
|
+
|
111
|
+
fs_spec = file_url.desc.coerce(KAE::TypeFSS)
|
112
|
+
|
113
|
+
Appscript.app('older app').documents[1].save(:in => fs_spec)</code></pre>
|
114
|
+
|
115
|
+
<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>
|
116
|
+
|
117
|
+
<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>
|
118
|
+
|
119
|
+
<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>
|
120
|
+
|
121
|
+
<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>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<!-- bottom navigation -->
|
126
|
+
|
127
|
+
<div class="footer">
|
128
|
+
<a href="02_aliasclass.html">Previous</a> •
|
129
|
+
<a href="index.html">Up</a> •
|
130
|
+
<a href="04_unitsclass.html">Next</a>
|
131
|
+
|
132
|
+
<span>© 2006-2008 HAS</span>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</body>
|
136
|
+
</html>
|