rb-scpt 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rb-scpt-1.0.1.gem +0 -0
- data/extconf.rb +12 -12
- data/rb-scpt.gemspec +10 -10
- data/sample/AB_export_vcard.rb +16 -16
- data/sample/AB_list_people_with_emails.rb +4 -4
- data/sample/Add_iCal_event.rb +12 -12
- data/sample/Create_daily_iCal_todos.rb +28 -28
- data/sample/Export_Address_Book_phone_numbers.rb +52 -52
- data/sample/Hello_world.rb +10 -10
- data/sample/List_iTunes_playlist_names.rb +3 -3
- data/sample/Make_Mail_message.rb +24 -24
- data/sample/Open_file_in_TextEdit.rb +5 -5
- data/sample/Organize_Mail_messages.rb +46 -46
- data/sample/Print_folder_tree.rb +5 -5
- data/sample/Select_all_HTML_files.rb +6 -6
- data/sample/Set_iChat_status.rb +12 -12
- data/sample/Simple_Finder_GUI_Scripting.rb +6 -6
- data/sample/Stagger_Finder_windows.rb +9 -9
- data/sample/TextEdit_demo.rb +71 -71
- data/sample/iTunes_top40_to_html.rb +28 -30
- data/src/SendThreadSafe.c +293 -293
- data/src/SendThreadSafe.h +108 -108
- data/src/lib/_aem/aemreference.rb +997 -998
- data/src/lib/_aem/codecs.rb +609 -610
- data/src/lib/_aem/connect.rb +197 -197
- data/src/lib/_aem/encodingsupport.rb +67 -67
- data/src/lib/_aem/findapp.rb +75 -75
- data/src/lib/_aem/mactypes.rb +241 -242
- data/src/lib/_aem/send.rb +268 -268
- data/src/lib/_aem/typewrappers.rb +52 -52
- data/src/lib/_appscript/defaultterminology.rb +266 -266
- data/src/lib/_appscript/referencerenderer.rb +230 -233
- data/src/lib/_appscript/reservedkeywords.rb +106 -106
- data/src/lib/_appscript/safeobject.rb +125 -125
- data/src/lib/_appscript/terminology.rb +448 -449
- data/src/lib/aem.rb +238 -238
- data/src/lib/kae.rb +1487 -1487
- data/src/lib/osax.rb +647 -647
- data/src/lib/rb-scpt.rb +1065 -1065
- data/src/rbae.c +595 -595
- data/test/test_aemreference.rb +104 -107
- data/test/test_appscriptcommands.rb +131 -134
- data/test/test_appscriptreference.rb +96 -99
- data/test/test_codecs.rb +166 -168
- data/test/test_findapp.rb +13 -16
- data/test/test_mactypes.rb +70 -72
- data/test/test_osax.rb +46 -48
- data/test/testall.sh +4 -4
- metadata +8 -7
@@ -8,109 +8,109 @@
|
|
8
8
|
# This list is mirrored in ch.6 of the appscript manual and in py-osaterminology's makeidentifier module
|
9
9
|
|
10
10
|
ReservedKeywords = [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
]
|
11
|
+
"==",
|
12
|
+
"===",
|
13
|
+
"=~",
|
14
|
+
"AS_aem_reference",
|
15
|
+
"AS_aem_reference=",
|
16
|
+
"AS_app_data",
|
17
|
+
"AS_app_data=",
|
18
|
+
"AS_new_reference",
|
19
|
+
"AS_resolve",
|
20
|
+
"ID",
|
21
|
+
"[]",
|
22
|
+
"__id__",
|
23
|
+
"__send__",
|
24
|
+
"_aem_application_class",
|
25
|
+
"_call",
|
26
|
+
"_resolve_range_boundary",
|
27
|
+
"_send_command",
|
28
|
+
"abort_transaction",
|
29
|
+
"after",
|
30
|
+
"and",
|
31
|
+
"any",
|
32
|
+
"app",
|
33
|
+
"before",
|
34
|
+
"begin_transaction",
|
35
|
+
"beginning",
|
36
|
+
"begins_with",
|
37
|
+
"by_aem_app",
|
38
|
+
"by_creator",
|
39
|
+
"by_id",
|
40
|
+
"by_name",
|
41
|
+
"by_pid",
|
42
|
+
"by_url",
|
43
|
+
"class",
|
44
|
+
"clone",
|
45
|
+
"commands",
|
46
|
+
"con",
|
47
|
+
"contains",
|
48
|
+
"current",
|
49
|
+
"display",
|
50
|
+
"does_not_contain",
|
51
|
+
"does_not_end_with",
|
52
|
+
"does_not_begin_with",
|
53
|
+
"dup",
|
54
|
+
"elements",
|
55
|
+
"end",
|
56
|
+
"end_transaction",
|
57
|
+
"ends_with",
|
58
|
+
"eq",
|
59
|
+
"eql?",
|
60
|
+
"equal?",
|
61
|
+
"extend",
|
62
|
+
"first",
|
63
|
+
"freeze",
|
64
|
+
"frozen?",
|
65
|
+
"ge",
|
66
|
+
"gt",
|
67
|
+
"hash",
|
68
|
+
"help",
|
69
|
+
"id",
|
70
|
+
"ignore",
|
71
|
+
"inspect",
|
72
|
+
"instance_eval",
|
73
|
+
"instance_of?",
|
74
|
+
"instance_variable_get",
|
75
|
+
"instance_variable_set",
|
76
|
+
"instance_variables",
|
77
|
+
"is_a?",
|
78
|
+
"is_in",
|
79
|
+
"is_not_in",
|
80
|
+
"is_running?",
|
81
|
+
"its",
|
82
|
+
"keywords",
|
83
|
+
"kind_of?",
|
84
|
+
"last",
|
85
|
+
"launch",
|
86
|
+
"le",
|
87
|
+
"lt",
|
88
|
+
"method",
|
89
|
+
"method_missing",
|
90
|
+
"methods",
|
91
|
+
"middle",
|
92
|
+
"ne",
|
93
|
+
"next",
|
94
|
+
"nil?",
|
95
|
+
"not",
|
96
|
+
"object_id",
|
97
|
+
"or",
|
98
|
+
"parameters",
|
99
|
+
"previous",
|
100
|
+
"private_methods",
|
101
|
+
"properties",
|
102
|
+
"protected_methods",
|
103
|
+
"public_methods",
|
104
|
+
"respond_to?",
|
105
|
+
"result_type",
|
106
|
+
"send",
|
107
|
+
"singleton_methods",
|
108
|
+
"taint",
|
109
|
+
"tainted?",
|
110
|
+
"timeout",
|
111
|
+
"to_a",
|
112
|
+
"to_s",
|
113
|
+
"type",
|
114
|
+
"untaint",
|
115
|
+
"wait_reply",
|
116
|
+
]
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# Appscript::Reference and Appscript#GenericReference with stable superclasses.
|
13
13
|
|
14
14
|
# Unfortunately, Ruby makes it ludicrously easy for users to accidentally add new methods
|
15
|
-
# to the Object class. And if these methods' names are the same as application keywords,
|
15
|
+
# to the Object class. And if these methods' names are the same as application keywords,
|
16
16
|
# Ruby will invoke them instead of Reference#method_missing, resulting in incorrect behaviour.
|
17
17
|
#
|
18
18
|
# e.g. The following code demonstrates the problem in an unpatched copy of appscript 0.2.1.
|
@@ -43,10 +43,10 @@
|
|
43
43
|
# then applied to Module#method_added and Module#included to detect any subsequent
|
44
44
|
# method additions and immediately remove those from AS_SafeObject as well.
|
45
45
|
|
46
|
-
# Having to insert traps into other users' runtimes isn't exactly an ideal solution, but
|
46
|
+
# Having to insert traps into other users' runtimes isn't exactly an ideal solution, but
|
47
47
|
# unless/until Ruby comes up with a safe, sane system for including modules in main that
|
48
48
|
# doesn't pollute every other namespace as well, it may be the only practical solution. The
|
49
|
-
# only other alternative would be a major redesign+rewrite of the appscript module to use
|
49
|
+
# only other alternative would be a major redesign+rewrite of the appscript module to use
|
50
50
|
# metaclasses (c.f. js-appscript) instead of method_missing, but this is not really desireable
|
51
51
|
# as it'd be much more complicated to implement, slower to initialise, and less elegant to
|
52
52
|
# use (since GenericReferences would have to be dropped).
|
@@ -61,58 +61,58 @@
|
|
61
61
|
#
|
62
62
|
# THE RUBY LICENSE
|
63
63
|
# (http://www.ruby-lang.org/en/LICENSE.txt)
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# You may redistribute this software and/or modify it under either the terms of
|
66
66
|
# the GPL (see below), or the conditions below:
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# 1. You may make and give away verbatim copies of the source form of the
|
69
69
|
# software without restriction, provided that you duplicate all of the
|
70
70
|
# original copyright notices and associated disclaimers.
|
71
|
-
#
|
71
|
+
#
|
72
72
|
# 2. You may modify your copy of the software in any way, provided that
|
73
73
|
# you do at least ONE of the following:
|
74
|
-
#
|
74
|
+
#
|
75
75
|
# a) place your modifications in the Public Domain or otherwise
|
76
76
|
# make them Freely Available, such as by posting said
|
77
77
|
# modifications to Usenet or an equivalent medium, or by allowing
|
78
78
|
# the author to include your modifications in the software.
|
79
|
-
#
|
79
|
+
#
|
80
80
|
# b) use the modified software only within your corporation or
|
81
81
|
# organization.
|
82
|
-
#
|
82
|
+
#
|
83
83
|
# c) rename any non-standard executables so the names do not conflict
|
84
84
|
# with standard executables, which must also be provided.
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# d) make other distribution arrangements with the author.
|
87
|
-
#
|
87
|
+
#
|
88
88
|
# 3. You may distribute the software in object code or executable
|
89
89
|
# form, provided that you do at least ONE of the following:
|
90
|
-
#
|
90
|
+
#
|
91
91
|
# a) distribute the executables and library files of the software,
|
92
92
|
# together with instructions (in the manual page or equivalent)
|
93
93
|
# on where to get the original distribution.
|
94
|
-
#
|
94
|
+
#
|
95
95
|
# b) accompany the distribution with the machine-readable source of
|
96
96
|
# the software.
|
97
|
-
#
|
97
|
+
#
|
98
98
|
# c) give non-standard executables non-standard names, with
|
99
99
|
# instructions on where to get the original software distribution.
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# d) make other distribution arrangements with the author.
|
102
|
-
#
|
102
|
+
#
|
103
103
|
# 4. You may modify and include the part of the software into any other
|
104
104
|
# software (possibly commercial). But some files in the distribution
|
105
105
|
# are not written by the author, so that they are not under these terms.
|
106
|
-
#
|
106
|
+
#
|
107
107
|
# For the list of those files and their copying conditions, see the
|
108
108
|
# file LEGAL.
|
109
|
-
#
|
109
|
+
#
|
110
110
|
# 5. The scripts and library files supplied as input to or produced as
|
111
111
|
# output from the software do not automatically fall under the
|
112
112
|
# copyright of the software, but belong to whomever generated them,
|
113
113
|
# and may be sold commercially, and may be aggregated with this
|
114
114
|
# software.
|
115
|
-
#
|
115
|
+
#
|
116
116
|
# 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
117
117
|
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
118
118
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
@@ -126,92 +126,92 @@ require '_appscript/reservedkeywords'
|
|
126
126
|
|
127
127
|
class AS_SafeObject
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
129
|
+
EXCLUDE = ReservedKeywords + [
|
130
|
+
"Array",
|
131
|
+
"Float",
|
132
|
+
"Integer",
|
133
|
+
"String",
|
134
|
+
"`",
|
135
|
+
"abort",
|
136
|
+
"at_exit",
|
137
|
+
"autoload",
|
138
|
+
"autoload?",
|
139
|
+
"binding",
|
140
|
+
"block_given?",
|
141
|
+
"callcc",
|
142
|
+
"caller",
|
143
|
+
"catch",
|
144
|
+
"chomp",
|
145
|
+
"chomp!",
|
146
|
+
"chop",
|
147
|
+
"chop!",
|
148
|
+
"eval",
|
149
|
+
"exec",
|
150
|
+
"exit",
|
151
|
+
"exit!",
|
152
|
+
"fail",
|
153
|
+
"fork",
|
154
|
+
"format",
|
155
|
+
"getc",
|
156
|
+
"gets",
|
157
|
+
"global_variables",
|
158
|
+
"gsub",
|
159
|
+
"gsub!",
|
160
|
+
"initialize",
|
161
|
+
"initialize_copy",
|
162
|
+
"iterator?",
|
163
|
+
"lambda",
|
164
|
+
"load",
|
165
|
+
"local_variables",
|
166
|
+
"loop",
|
167
|
+
"open",
|
168
|
+
"p",
|
169
|
+
"print",
|
170
|
+
"printf",
|
171
|
+
"proc",
|
172
|
+
"putc",
|
173
|
+
"puts",
|
174
|
+
"raise",
|
175
|
+
"rand",
|
176
|
+
"readline",
|
177
|
+
"readlines",
|
178
|
+
"remove_instance_variable",
|
179
|
+
"require",
|
180
|
+
"scan",
|
181
|
+
"select",
|
182
|
+
"set_trace_func",
|
183
|
+
"singleton_method_added",
|
184
|
+
"singleton_method_removed",
|
185
|
+
"singleton_method_undefined",
|
186
|
+
"sleep",
|
187
|
+
"split",
|
188
|
+
"sprintf",
|
189
|
+
"srand",
|
190
|
+
"sub",
|
191
|
+
"sub!",
|
192
|
+
"syscall",
|
193
|
+
"system",
|
194
|
+
"test",
|
195
|
+
"throw",
|
196
|
+
"trace_var",
|
197
|
+
"trap",
|
198
|
+
"untrace_var",
|
199
|
+
"warn"
|
200
|
+
] + [
|
201
|
+
/^__/, /^instance_/, /^object_/, /\?$/, /^\W$/,
|
202
|
+
]
|
203
|
+
|
204
|
+
def self.hide(name)
|
205
|
+
case name.to_s # Ruby1.9 returns method names as symbols, not strings as in 1.8
|
206
|
+
when *EXCLUDE
|
207
|
+
else
|
208
|
+
undef_method(name) rescue nil
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
public_instance_methods(true).each { |m| hide(m) }
|
213
|
+
#private_instance_methods(true).each { |m| hide(m) }
|
214
|
+
protected_instance_methods(true).each { |m| hide(m) }
|
215
215
|
|
216
216
|
end
|
217
217
|
|
@@ -226,24 +226,24 @@ end
|
|
226
226
|
# hooks in Module that will hide any defined.
|
227
227
|
|
228
228
|
class Module
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
229
|
+
madded = method(:method_added)
|
230
|
+
define_method(:method_added) do |name|
|
231
|
+
# puts "ADDED %-32s %s" % [name, self]
|
232
|
+
result = madded.call(name)
|
233
|
+
if self == Object
|
234
|
+
AS_SafeObject.hide(name)
|
235
|
+
end
|
236
|
+
return result
|
237
|
+
end
|
238
|
+
mincluded = method(:included)
|
239
|
+
define_method(:included) do |mod|
|
240
|
+
result = mincluded.call(mod)
|
241
|
+
# puts "INCLUDED %-32s %s" % [mod, self]
|
242
|
+
if mod == Object
|
243
|
+
public_instance_methods(true).each { |name| AS_SafeObject.hide(name) }
|
244
|
+
#private_instance_methods(true).each { |name| AS_SafeObject.hide(name) }
|
245
|
+
protected_instance_methods(true).each { |name| AS_SafeObject.hide(name) }
|
246
|
+
end
|
247
|
+
return result
|
248
|
+
end
|
249
249
|
end
|