rb-scpt 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +2 -0
- data/.gitignore +6 -0
- data/Manifest.txt +96 -0
- data/README.md +8 -0
- data/Rakefile +18 -0
- data/{src → ext/ae}/SendThreadSafe.c +1 -1
- data/{src/rbae.c → ext/ae/ae.c} +7 -4
- data/{extconf.rb → ext/ae/extconf.rb} +6 -35
- data/{src/lib → lib}/_aem/aemreference.rb +2 -1
- data/{src/lib → lib}/_aem/codecs.rb +5 -5
- data/{src/lib → lib}/_aem/connect.rb +6 -6
- data/{src/lib → lib}/_aem/encodingsupport.rb +1 -4
- data/{src/lib → lib}/_aem/findapp.rb +4 -4
- data/{src/lib → lib}/_aem/send.rb +10 -12
- data/{src/lib → lib}/_appscript/defaultterminology.rb +3 -3
- data/{src/lib → lib}/_appscript/referencerenderer.rb +2 -2
- data/{src/lib → lib}/_appscript/safeobject.rb +11 -10
- data/{src/lib → lib}/_appscript/terminology.rb +5 -5
- data/{src/lib → lib}/aem.rb +5 -5
- data/{src/lib → lib}/osax.rb +1 -1
- data/{src/lib → lib}/rb-scpt.rb +0 -2
- data/lib/version.rb +3 -0
- data/rb-scpt.gemspec +15 -10
- data/test/test_aemreference.rb +10 -10
- data/test/test_appscriptcommands.rb +23 -25
- data/test/test_appscriptreference.rb +3 -3
- data/test/test_codecs.rb +15 -13
- data/test/test_findapp.rb +10 -10
- data/test/test_mactypes.rb +10 -8
- data/test/test_osax.rb +27 -15
- data.tar.gz.sig +0 -0
- metadata +64 -40
- metadata.gz.sig +0 -0
- data/bin/rb-scpt-1.0.0.gem +0 -0
- data/bin/rb-scpt-1.0.1.gem +0 -0
- data/test/testall.sh +0 -10
- /data/{src → ext/ae}/SendThreadSafe.h +0 -0
- /data/{src/lib → lib}/_aem/mactypes.rb +0 -0
- /data/{src/lib → lib}/_aem/typewrappers.rb +0 -0
- /data/{src/lib → lib}/_appscript/reservedkeywords.rb +0 -0
- /data/{src/lib → lib}/kae.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0c86266e32295b553a490fc58c5b22a62a1bca4b2df975e46d7909c3f72bc901
|
4
|
+
data.tar.gz: 61347116bed121e3bc825768dbb5420ab878f1476d3fba6f50f3a8517977c9a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8639d9d502df996be3a2ff8332e6f48696cd3e95726efd3c6cd3260451313b3c89eb484fd2a6a879d4bef62fe08fbdd95107112c0da000dcb733ed0d611063
|
7
|
+
data.tar.gz: 707bed2d8d0f09b0814ff9a66295f5041836ac66f15dfb9f06ccab9bc24a840ed271f81d5a3c7e928e3ebb7fa9246d3f54a978a75e70b532eed532e47c90f6a6
|
checksums.yaml.gz.sig
ADDED
data/.gitignore
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
.gitignore
|
2
|
+
CHANGES
|
3
|
+
Manifest.txt
|
4
|
+
README.md
|
5
|
+
Rakefile
|
6
|
+
doc/aem-manual/01_introduction.html
|
7
|
+
doc/aem-manual/02_apioverview.html
|
8
|
+
doc/aem-manual/03_packingandunpackingdata.html
|
9
|
+
doc/aem-manual/04_references.html
|
10
|
+
doc/aem-manual/05_targetingapplications.html
|
11
|
+
doc/aem-manual/06_buildingandsendingevents.html
|
12
|
+
doc/aem-manual/07_findapp.html
|
13
|
+
doc/aem-manual/08_examples.html
|
14
|
+
doc/aem-manual/aemreferenceinheritance.gif
|
15
|
+
doc/aem-manual/index.html
|
16
|
+
doc/appscript-manual/01_introduction.html
|
17
|
+
doc/appscript-manual/02_aboutappscripting.html
|
18
|
+
doc/appscript-manual/03_quicktutorial.html
|
19
|
+
doc/appscript-manual/04_gettinghelp.html
|
20
|
+
doc/appscript-manual/05_keywordconversion.html
|
21
|
+
doc/appscript-manual/06_classesandenums.html
|
22
|
+
doc/appscript-manual/07_applicationobjects.html
|
23
|
+
doc/appscript-manual/08_realvsgenericreferences.html
|
24
|
+
doc/appscript-manual/09_referenceforms.html
|
25
|
+
doc/appscript-manual/10_referenceexamples.html
|
26
|
+
doc/appscript-manual/11_applicationcommands.html
|
27
|
+
doc/appscript-manual/12_commandexamples.html
|
28
|
+
doc/appscript-manual/13_performanceissues.html
|
29
|
+
doc/appscript-manual/14_notes.html
|
30
|
+
doc/appscript-manual/application_architecture.gif
|
31
|
+
doc/appscript-manual/application_architecture2.gif
|
32
|
+
doc/appscript-manual/finder_to_textedit_event.gif
|
33
|
+
doc/appscript-manual/index.html
|
34
|
+
doc/appscript-manual/relationships_example.gif
|
35
|
+
doc/appscript-manual/ruby_to_itunes_event.gif
|
36
|
+
doc/full.css
|
37
|
+
doc/index.html
|
38
|
+
doc/mactypes-manual/01_introduction.html
|
39
|
+
doc/mactypes-manual/02_aliasclass.html
|
40
|
+
doc/mactypes-manual/03_fileurlclass.html
|
41
|
+
doc/mactypes-manual/04_unitsclass.html
|
42
|
+
doc/mactypes-manual/index.html
|
43
|
+
doc/osax-manual/01_introduction.html
|
44
|
+
doc/osax-manual/02_interface.html
|
45
|
+
doc/osax-manual/03_examples.html
|
46
|
+
doc/osax-manual/04_notes.html
|
47
|
+
doc/osax-manual/index.html
|
48
|
+
doc/rb-appscript-logo.png
|
49
|
+
ext/ae/ae.c
|
50
|
+
ext/ae/SendThreadSafe.c
|
51
|
+
ext/ae/SendThreadSafe.h
|
52
|
+
ext/ae/extconf.rb
|
53
|
+
lib/_aem/aemreference.rb
|
54
|
+
lib/_aem/codecs.rb
|
55
|
+
lib/_aem/connect.rb
|
56
|
+
lib/_aem/encodingsupport.rb
|
57
|
+
lib/_aem/findapp.rb
|
58
|
+
lib/_aem/mactypes.rb
|
59
|
+
lib/_aem/send.rb
|
60
|
+
lib/_aem/typewrappers.rb
|
61
|
+
lib/_appscript/defaultterminology.rb
|
62
|
+
lib/_appscript/referencerenderer.rb
|
63
|
+
lib/_appscript/reservedkeywords.rb
|
64
|
+
lib/_appscript/safeobject.rb
|
65
|
+
lib/_appscript/terminology.rb
|
66
|
+
lib/aem.rb
|
67
|
+
lib/kae.rb
|
68
|
+
lib/osax.rb
|
69
|
+
lib/rb-scpt.rb
|
70
|
+
lib/version.rb
|
71
|
+
rb-scpt.gemspec
|
72
|
+
sample/AB_export_vcard.rb
|
73
|
+
sample/AB_list_people_with_emails.rb
|
74
|
+
sample/Add_iCal_event.rb
|
75
|
+
sample/Create_daily_iCal_todos.rb
|
76
|
+
sample/Export_Address_Book_phone_numbers.rb
|
77
|
+
sample/Hello_world.rb
|
78
|
+
sample/List_iTunes_playlist_names.rb
|
79
|
+
sample/Make_Mail_message.rb
|
80
|
+
sample/Open_file_in_TextEdit.rb
|
81
|
+
sample/Organize_Mail_messages.rb
|
82
|
+
sample/Print_folder_tree.rb
|
83
|
+
sample/Select_all_HTML_files.rb
|
84
|
+
sample/Set_iChat_status.rb
|
85
|
+
sample/Simple_Finder_GUI_Scripting.rb
|
86
|
+
sample/Stagger_Finder_windows.rb
|
87
|
+
sample/TextEdit_demo.rb
|
88
|
+
sample/iTunes_top40_to_html.rb
|
89
|
+
test/README
|
90
|
+
test/test_aemreference.rb
|
91
|
+
test/test_appscriptcommands.rb
|
92
|
+
test/test_appscriptreference.rb
|
93
|
+
test/test_codecs.rb
|
94
|
+
test/test_findapp.rb
|
95
|
+
test/test_mactypes.rb
|
96
|
+
test/test_osax.rb
|
data/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# rb-scpt
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
Ruby AppleScript (rb-scpt) is a high-level, user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts.
|
5
|
+
|
6
|
+
## Contributing
|
7
|
+
|
8
|
+
All contributions to this repo are welcome, in fact wanted. Please ensure that all work is done off of the `develop` branch with a PR back into master. New versions of the gem will be built from master.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rake/extensiontask"
|
2
|
+
Rake::ExtensionTask.new "ae"
|
3
|
+
|
4
|
+
task :default => :test
|
5
|
+
|
6
|
+
task :test => :compile
|
7
|
+
|
8
|
+
task :clean do
|
9
|
+
rm_f Dir["**/*~", "*.gem", "**/*.bundle"]
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "build the gem"
|
13
|
+
task :gem => [:clean, :clobber] do
|
14
|
+
system "gem build"
|
15
|
+
end
|
16
|
+
|
17
|
+
require "minitest/test_task"
|
18
|
+
Minitest::TestTask.create
|
data/{src/rbae.c → ext/ae/ae.c}
RENAMED
@@ -9,7 +9,7 @@
|
|
9
9
|
* - Jordan Breeding (64-bit support patch)
|
10
10
|
*/
|
11
11
|
|
12
|
-
#include "
|
12
|
+
#include "ruby/ruby.h"
|
13
13
|
#include <Carbon/Carbon.h>
|
14
14
|
#include <CoreFoundation/CoreFoundation.h>
|
15
15
|
#include "SendThreadSafe.h"
|
@@ -222,7 +222,8 @@ rbAE_AEDesc_newUnflatten(VALUE class, VALUE data)
|
|
222
222
|
AEDesc desc;
|
223
223
|
|
224
224
|
Check_Type(data, T_STRING);
|
225
|
-
|
225
|
+
|
226
|
+
err = AEUnflattenDescFromBytes(RSTRING_PTR(data), RSTRING_LEN(data), &desc);
|
226
227
|
if (err != noErr) rbAE_raiseMacOSError("Can't create AEDesc.", err);
|
227
228
|
return rbAE_wrapAEDesc(&desc);
|
228
229
|
}
|
@@ -746,8 +747,9 @@ rbAE_GenericEventHandler(const AppleEvent *request, AppleEvent *reply, SRefCon r
|
|
746
747
|
/*******/
|
747
748
|
|
748
749
|
static VALUE
|
749
|
-
rbAE_AEInstallEventHandler(VALUE self, VALUE eventClass, VALUE eventID,
|
750
|
+
rbAE_AEInstallEventHandler(VALUE self, VALUE eventClass, VALUE eventID, VALUE _handler)
|
750
751
|
{
|
752
|
+
SRefCon handler = (SRefCon)_handler;
|
751
753
|
/*
|
752
754
|
* eventClass and eventID must be four-character code strings
|
753
755
|
*
|
@@ -821,8 +823,9 @@ rbAE_GenericCoercionHandler(const AEDesc *fromDesc, DescType toType, SRefCon ref
|
|
821
823
|
/*******/
|
822
824
|
|
823
825
|
static VALUE
|
824
|
-
rbAE_AEInstallCoercionHandler(VALUE self, VALUE fromType, VALUE toType,
|
826
|
+
rbAE_AEInstallCoercionHandler(VALUE self, VALUE fromType, VALUE toType, VALUE _handler)
|
825
827
|
{
|
828
|
+
SRefCon handler = (SRefCon)_handler;
|
826
829
|
/*
|
827
830
|
* fromType and toType must be four-character code strings
|
828
831
|
*
|
@@ -3,19 +3,19 @@
|
|
3
3
|
# Original copyright below:
|
4
4
|
#
|
5
5
|
# Copyright (c) 2006, Apple Computer, Inc. All rights reserved.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without
|
8
8
|
# modification, are permitted provided that the following conditions
|
9
9
|
# are met:
|
10
10
|
# 1. Redistributions of source code must retain the above copyright
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
12
|
# 2. Redistributions in binary form must reproduce the above copyright
|
13
13
|
# notice, this list of conditions and the following disclaimer in the
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
15
|
# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
16
16
|
# its contributors may be used to endorse or promote products derived
|
17
|
-
# from this software without specific prior written permission.
|
18
|
-
#
|
17
|
+
# from this software without specific prior written permission.
|
18
|
+
#
|
19
19
|
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
|
20
20
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
21
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -29,37 +29,8 @@
|
|
29
29
|
# POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
|
31
31
|
require 'mkmf'
|
32
|
-
require 'rbconfig'
|
33
32
|
|
34
33
|
$CFLAGS << ' -Wall'
|
35
34
|
$LDFLAGS << ' -framework Carbon -framework ApplicationServices'
|
36
35
|
|
37
|
-
|
38
|
-
# (adapted code from RubyAEOSA - FUJIMOTO Hisakuni <hisa -at- fobj - com>)
|
39
|
-
|
40
|
-
maj, min = RUBY_VERSION.split('.')
|
41
|
-
is_ruby_18 = (maj <= '1' and min.to_i < 9)
|
42
|
-
if is_ruby_18
|
43
|
-
header_path = RbConfig::CONFIG['archdir']
|
44
|
-
else
|
45
|
-
header_path = File.join(RbConfig::CONFIG['rubyhdrdir'], 'ruby')
|
46
|
-
end
|
47
|
-
ruby_h = File.join(header_path, 'ruby.h')
|
48
|
-
intern_h = File.join(header_path, 'intern.h')
|
49
|
-
new_filename_prefix = 'osx_'
|
50
|
-
|
51
|
-
[ ruby_h, intern_h ].each do |src_path|
|
52
|
-
dst_fname = File.join('./src', new_filename_prefix + File.basename(src_path))
|
53
|
-
$stderr.puts "create #{File.expand_path(dst_fname)} ..."
|
54
|
-
File.open(dst_fname, 'w') do |dstfile|
|
55
|
-
IO.foreach(src_path) do |line|
|
56
|
-
line = line.gsub(/\bID\b/, 'RB_ID')
|
57
|
-
line = line.gsub(/\bT_DATA\b/, 'RB_T_DATA')
|
58
|
-
line = line.gsub(/\b(?:ruby\/)?intern.h\b/, "#{new_filename_prefix}intern.h")
|
59
|
-
line = line.gsub('#include "defines.h"', '#include "ruby/defines.h"') if not is_ruby_18
|
60
|
-
dstfile.puts line
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
create_makefile('ae', 'src')
|
36
|
+
create_makefile "ae"
|
@@ -72,9 +72,9 @@ class UnitTypeCodecs
|
|
72
72
|
|
73
73
|
def add_types(type_defs)
|
74
74
|
# type_defs is a list of lists, where each sublist is of form:
|
75
|
-
#
|
75
|
+
# [typename, typecode, packproc, unpackproc]
|
76
76
|
# or:
|
77
|
-
#
|
77
|
+
# [typename, typecode]
|
78
78
|
# If optional packproc and unpackproc are omitted, default pack/unpack procs
|
79
79
|
# are used instead; these pack/unpack AEDesc data as a double precision float.
|
80
80
|
type_defs.each do |name, code, packer, unpacker|
|
@@ -191,7 +191,7 @@ class Codecs
|
|
191
191
|
# them into AEDescs of typeUTF8Text. To force the old-style behaviour where
|
192
192
|
# strings are treated as byte strings containing UTF-8 data, call:
|
193
193
|
#
|
194
|
-
#
|
194
|
+
# some_application.AS_app_data.use_ascii_8bit_strings
|
195
195
|
#
|
196
196
|
# This will cause Strings to use the binary ASCII-8BIT encoding; as in Ruby 1.8,
|
197
197
|
# the user is responsible for ensuring that strings contain UTF-8 data.
|
@@ -233,7 +233,7 @@ class Codecs
|
|
233
233
|
case val
|
234
234
|
when AEMReference::Query then val.AEM_pack_self(self)
|
235
235
|
|
236
|
-
when
|
236
|
+
when Integer then
|
237
237
|
if SInt32Bounds === val
|
238
238
|
AE::AEDesc.new(KAE::TypeSInt32, [val].pack('l'))
|
239
239
|
elsif SInt64Bounds === val
|
@@ -294,7 +294,7 @@ class Codecs
|
|
294
294
|
# (assuming target app knows how to handle new UInt64 type):
|
295
295
|
#
|
296
296
|
# def pack_uint64(val)
|
297
|
-
#
|
297
|
+
# AE::AEDesc.new(KAE::TypeUInt64, [val.to_f].pack('Q'))
|
298
298
|
# end
|
299
299
|
AE::AEDesc.new(KAE::TypeFloat, [val.to_f].pack('d')) # pack as 64-bit float for compatibility (lossy conversion)
|
300
300
|
end
|
@@ -169,8 +169,8 @@ module Connect
|
|
169
169
|
|
170
170
|
def Connect.local_app(path)
|
171
171
|
# Make an AEAddressDesc identifying a local application. (Application will be launched if not already running.)
|
172
|
-
#
|
173
|
-
#
|
172
|
+
# path : string -- full path to application, e.g. '/Applications/TextEdit.app'
|
173
|
+
# Result : AEAddressDesc
|
174
174
|
#
|
175
175
|
# Always creates AEAddressDesc by process serial number; that way there's no confusion if multiple versions of the same app are running.
|
176
176
|
path = @@encoding_support.to_utf8_string(path)
|
@@ -189,16 +189,16 @@ module Connect
|
|
189
189
|
|
190
190
|
def Connect.local_app_by_pid(pid)
|
191
191
|
# Make an AEAddressDesc identifying a running application by Unix process id.
|
192
|
-
#
|
193
|
-
#
|
192
|
+
# pid : integer -- unsigned 32-bit integer
|
193
|
+
# Result : AEAddressDesc
|
194
194
|
return AE::AEDesc.new(KAE::TypeKernelProcessID, [pid].pack('L'))
|
195
195
|
end
|
196
196
|
|
197
197
|
def Connect.remote_app(url)
|
198
198
|
url = @@encoding_support.to_utf8_string(url)
|
199
199
|
# Make an AEAddressDesc identifying a running application on another machine.
|
200
|
-
#
|
201
|
-
#
|
200
|
+
# url : string -- URL for remote application, e.g. 'eppc://user:password@0.0.0.1/TextEdit'
|
201
|
+
# Result : AEAddressDesc
|
202
202
|
raise ArgumentError, "Invalid url: #{url}" if not url.include?(':') # workaround: process will crash if no colon in URL (OS bug)
|
203
203
|
return AE::AEDesc.new(KAE::TypeApplicationURL, url)
|
204
204
|
end
|
@@ -67,11 +67,8 @@ module AEMEncodingSupport
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
70
|
def AEMEncodingSupport.encoding_support
|
72
|
-
|
73
|
-
version, sub_version = RUBY_VERSION.split('.').collect {|n| n.to_i} [0, 2]
|
74
|
-
return (version >= 1 and sub_version >= 9) ? AEMEncodingSupport::EnableStringEncodings : AEMEncodingSupport::DisableStringEncodings
|
71
|
+
RUBY_VERSION.to_f >= 1.9 ? EnableStringEncodings : DisableStringEncodings
|
75
72
|
end
|
76
73
|
|
77
74
|
end
|
@@ -42,8 +42,8 @@ module FindApp
|
|
42
42
|
# Absolute paths are also accepted. An '.app' suffix is optional.
|
43
43
|
#
|
44
44
|
# Examples:
|
45
|
-
#
|
46
|
-
#
|
45
|
+
# FindApp.by_name('TextEdit')
|
46
|
+
# FindApp.by_name('Finder.app')
|
47
47
|
#
|
48
48
|
if name[0, 1] != '/' # application name only, not its full path
|
49
49
|
begin
|
@@ -69,7 +69,7 @@ module FindApp
|
|
69
69
|
# Find the application with the given bundle id and return its full path.
|
70
70
|
#
|
71
71
|
# Examples:
|
72
|
-
#
|
72
|
+
# FindApp.by_id('com.apple.textedit')
|
73
73
|
#
|
74
74
|
return _find_app(nil, id, nil)
|
75
75
|
end
|
@@ -78,7 +78,7 @@ module FindApp
|
|
78
78
|
# Find the application with the given creator type and return its full path.
|
79
79
|
#
|
80
80
|
# Examples:
|
81
|
-
#
|
81
|
+
# FindApp.by_creator('ttxt')
|
82
82
|
#
|
83
83
|
return _find_app(creator, nil, nil)
|
84
84
|
end
|
@@ -61,11 +61,11 @@ module Send
|
|
61
61
|
#
|
62
62
|
# [1] Should be the sum of zero or more of the following kae module constants:
|
63
63
|
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
64
|
+
# KAENoReply | KAEQueueReply | KAEWaitReply
|
65
|
+
# KAEDontReconnect
|
66
|
+
# KAEWantReceipt
|
67
|
+
# KAENeverInteract | KAECanInteract | KAEAlwaysInteract
|
68
|
+
# KAECanSwitchLayer
|
69
69
|
|
70
70
|
begin
|
71
71
|
reply_event = _send_apple_event(flags, timeout)
|
@@ -75,11 +75,9 @@ module Send
|
|
75
75
|
end
|
76
76
|
else # Decode application's reply, if any. May be a return value, error number (and optional message), or nothing.
|
77
77
|
if reply_event.type != KAE::TypeNull
|
78
|
-
event_result = {
|
79
|
-
|
80
|
-
|
81
|
-
event_result[key] = value
|
82
|
-
end
|
78
|
+
event_result = reply_event.length.times.to_h { |i|
|
79
|
+
reply_event.get_item(i.next, KAE::TypeWildCard)
|
80
|
+
}
|
83
81
|
if event_result.has_key?(KAE::KeyErrorNumber) # The application raised an error.
|
84
82
|
# Error info is unpacked using default codecs for reliability.
|
85
83
|
e_num = DefaultCodecs.unpack(event_result[KAE::KeyErrorNumber])
|
@@ -103,8 +101,8 @@ module Send
|
|
103
101
|
# Represents an error raised by the Apple Event Manager or target application when a command fails.
|
104
102
|
#
|
105
103
|
# Methods:
|
106
|
-
#
|
107
|
-
#
|
104
|
+
# number : integer -- MacOS error number
|
105
|
+
# message : string -- application error message if any, or default error description if available
|
108
106
|
|
109
107
|
# Most applications don't provide error description strings, so define default descriptions for the common ones.
|
110
108
|
# Following default error descriptions are cribbed from the AppleScript Language Guide/MacErrors.h:
|
@@ -221,12 +221,12 @@ class ReferenceRenderer
|
|
221
221
|
def ReferenceRenderer.render(app_data, aem_reference)
|
222
222
|
# Take an aem reference, e.g.:
|
223
223
|
#
|
224
|
-
#
|
224
|
+
# app.elements('docu').by_index(1).property('ctxt')
|
225
225
|
#
|
226
226
|
# and an AppData instance containing application's location and terminology,
|
227
227
|
# and render an appscript-style reference string, e.g.:
|
228
228
|
#
|
229
|
-
#
|
229
|
+
# "AS.app('/Applications/TextEdit.app').documents[1].text"
|
230
230
|
#
|
231
231
|
# Used by AS::Reference#to_s
|
232
232
|
#
|
@@ -24,10 +24,10 @@
|
|
24
24
|
# require 'appscript'
|
25
25
|
#
|
26
26
|
# module X
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
27
|
+
# def name
|
28
|
+
# puts 'X.name was called'
|
29
|
+
# return 999
|
30
|
+
# end
|
31
31
|
# end
|
32
32
|
# include X
|
33
33
|
#
|
@@ -226,18 +226,19 @@ end
|
|
226
226
|
# hooks in Module that will hide any defined.
|
227
227
|
|
228
228
|
class Module
|
229
|
-
|
230
|
-
|
229
|
+
alias so_method_added method_added
|
230
|
+
def method_added name
|
231
231
|
# puts "ADDED %-32s %s" % [name, self]
|
232
|
-
result =
|
232
|
+
result = so_method_added(name)
|
233
233
|
if self == Object
|
234
234
|
AS_SafeObject.hide(name)
|
235
235
|
end
|
236
236
|
return result
|
237
237
|
end
|
238
|
-
|
239
|
-
|
240
|
-
|
238
|
+
|
239
|
+
alias so_included included
|
240
|
+
def included mod
|
241
|
+
result = so_included(mod)
|
241
242
|
# puts "INCLUDED %-32s %s" % [mod, self]
|
242
243
|
if mod == Object
|
243
244
|
public_instance_methods(true).each { |name| AS_SafeObject.hide(name) }
|
@@ -54,7 +54,7 @@ module TerminologyParser
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# Ruby 1.9 has changed the way that a character ordinal is obtained
|
57
|
-
maj, min,
|
57
|
+
maj, min, _rev = RUBY_VERSION.split('.')
|
58
58
|
if (maj == '1' and min.to_i < 9) # is Ruby 1.8
|
59
59
|
def _length
|
60
60
|
return @_str[@_ptr]
|
@@ -447,15 +447,15 @@ module Terminology
|
|
447
447
|
#
|
448
448
|
# Call the #dump method to dump faulty aetes to Ruby module, e.g.:
|
449
449
|
#
|
450
|
-
#
|
450
|
+
# Terminology.dump('MyApp', 'MyAppGlue', '/path/to/ruby/modules/myappglue.rb')
|
451
451
|
#
|
452
452
|
# Patch any errors by hand, then import the patched module into your script
|
453
453
|
# and pass it to appscript's app() constructor via its 'terms' argument, e.g.:
|
454
454
|
#
|
455
|
-
#
|
456
|
-
#
|
455
|
+
# require 'appscript'; include Appscript
|
456
|
+
# require 'myappglue'
|
457
457
|
#
|
458
|
-
#
|
458
|
+
# myapp = app('MyApp', terms => MyAppGlue)
|
459
459
|
#
|
460
460
|
# Note that dumped terminologies aren't used by appscript's built-in help system.
|
461
461
|
#
|
data/{src/lib → lib}/aem.rb
RENAMED
@@ -210,11 +210,11 @@ module AEM
|
|
210
210
|
|
211
211
|
def event(event, params={}, atts={}, return_id=KAE::KAutoGenerateReturnID, codecs=DefaultCodecs)
|
212
212
|
# Construct an Apple event targetted at this application.
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
213
|
+
# event : string -- 8-letter code indicating event's class, e.g. 'coregetd'
|
214
|
+
# params : hash -- a dict of form {AE_code:anything,...} containing zero or more event parameters (message arguments)
|
215
|
+
# atts : hash -- a dict of form {AE_code:anything,...} containing zero or more event attributes (event info)
|
216
|
+
# return_id : integer -- reply event's ID
|
217
|
+
# codecs : Codecs -- codecs object to use when packing/unpacking this event
|
218
218
|
return self.class::Event.new(@address_desc, event, params, atts, @_transaction, return_id, codecs)
|
219
219
|
end
|
220
220
|
|
data/{src/lib → lib}/osax.rb
RENAMED
@@ -647,7 +647,7 @@ module OSAX
|
|
647
647
|
osax_name = osax_name.downcase
|
648
648
|
m = /^(.+).osax$/.match(osax_name)
|
649
649
|
osax_name = m[1] if m != nil
|
650
|
-
osax_path,
|
650
|
+
osax_path, _terms = OSAXCache.fetch(osax_name) do
|
651
651
|
raise ArgumentError, "Scripting addition not found: #{original_name.inspect}"
|
652
652
|
end
|
653
653
|
sp = OSAX::SdefParser.new
|
data/{src/lib → lib}/rb-scpt.rb
RENAMED
@@ -9,8 +9,6 @@ require "_aem/mactypes"
|
|
9
9
|
|
10
10
|
module Appscript
|
11
11
|
|
12
|
-
Version = '1.0.1'
|
13
|
-
|
14
12
|
# The following methods and classes are of interest to end users:
|
15
13
|
# app, con, its, CommandError, ApplicationNotFoundError, CantLaunchApplicationError
|
16
14
|
# Other classes are only of interest to implementors who need to hook in their own code.
|
data/lib/version.rb
ADDED
data/rb-scpt.gemspec
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
|
3
|
+
require "./lib/version.rb"
|
4
|
+
|
3
5
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
-
s.homepage
|
7
|
-
s.summary="This is a fork of the original rb-appscript. Ruby AppleScript (rb-scpt) is a high-level, user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts."
|
8
|
-
s.files
|
9
|
-
s.extensions =
|
10
|
-
s.test_files =
|
11
|
-
s.authors
|
12
|
-
s.email
|
13
|
-
|
6
|
+
s.name = "rb-scpt"
|
7
|
+
s.version = Appscript::Version
|
8
|
+
s.homepage = "https://github.com/BrendanThompson/rb-scpt"
|
9
|
+
s.summary = "This is a fork of the original rb-appscript. Ruby AppleScript (rb-scpt) is a high-level, user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts."
|
10
|
+
s.files = File.readlines("Manifest.txt", chomp:true)
|
11
|
+
s.extensions = s.files.grep(/extconf.rb/)
|
12
|
+
s.test_files = s.files.grep(/^test/)
|
13
|
+
s.authors = ["hhas","Brendan Thompson"]
|
14
|
+
s.email = 'brendan@btsystems.com.au'
|
15
|
+
|
16
|
+
s.license = "AML"
|
17
|
+
|
18
|
+
s.required_ruby_version = ">= 2.7"
|
14
19
|
end
|
data/test/test_aemreference.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require "_aem/aemreference"
|
5
5
|
require "_aem/typewrappers"
|
6
6
|
require "_aem/codecs"
|
7
7
|
|
8
8
|
|
9
|
-
class TC_AEMReferences < Test
|
9
|
+
class TC_AEMReferences < Minitest::Test
|
10
10
|
|
11
11
|
def test_reference_forms
|
12
12
|
[
|
@@ -93,22 +93,22 @@ class TC_AEMReferences < Test::Unit::TestCase
|
|
93
93
|
val2 = DefaultCodecs.unpack(d)
|
94
94
|
assert_equal(val, val2)
|
95
95
|
val2 = DefaultCodecs.unpack(d)
|
96
|
-
|
96
|
+
assert_operator val, :eql?, val2
|
97
97
|
val2 = DefaultCodecs.unpack(d)
|
98
98
|
assert_equal(val2, val)
|
99
99
|
val2 = DefaultCodecs.unpack(d)
|
100
|
-
|
100
|
+
assert_operator val2, :eql?, val
|
101
101
|
rescue
|
102
102
|
puts 'EXPECTED: ' + res
|
103
103
|
raise
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
#
|
106
|
+
refute_equal(AEMReference::App.property('ctxt').property('ctxt'), AEMReference::Con.property('ctxt').property('ctxt'))
|
107
|
+
refute_equal(AEMReference::App.property('foob').property('ctxt'), AEMReference::App.property('ctxt').property('ctxt'))
|
108
|
+
refute_equal(AEMReference::App.elements('ctxt').property('ctxt'), AEMReference::App.property('ctxt').property('ctxt'))
|
109
|
+
refute_equal(AEMReference::App.elements('ctxt').property('ctxt'), 333)
|
110
|
+
refute_equal(333, AEMReference::App.property('ctxt').property('ctxt'))
|
111
|
+
# by-filter references do basic type checking to ensure an its-based reference is given
|
112
112
|
assert_raises(TypeError) { AEMReference::App.elements('docu').by_filter(1) }
|
113
113
|
|
114
114
|
end
|
@@ -1,29 +1,23 @@
|
|
1
1
|
#!/usr/local/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require 'rb-scpt'
|
5
5
|
|
6
|
-
|
7
|
-
#class AS_SafeObject
|
8
|
-
# def self.hide(name)
|
9
|
-
# end
|
10
|
-
#end
|
11
|
-
|
12
|
-
class TC_AppscriptNewApp < Test::Unit::TestCase
|
6
|
+
class TC_AppscriptNewApp < Minitest::Test
|
13
7
|
|
14
8
|
def test_by_name
|
15
9
|
[
|
16
|
-
'/Applications/TextEdit.app',
|
10
|
+
'/System/Applications/TextEdit.app',
|
17
11
|
'Finder.app',
|
18
12
|
'System Events'
|
19
13
|
].each do |name|
|
20
14
|
a = Appscript.app(name)
|
21
|
-
|
15
|
+
refute_nil(a)
|
22
16
|
assert_instance_of(Appscript::Application, a)
|
23
17
|
assert_instance_of(Appscript::Reference, a.name)
|
24
18
|
end
|
25
|
-
assert_equal('app("/Applications/TextEdit.app")', Appscript.app('TextEdit').to_s)
|
26
|
-
assert_equal('app("/Applications/TextEdit.app")', Appscript.app.by_name('TextEdit').to_s)
|
19
|
+
assert_equal('app("/System/Applications/TextEdit.app")', Appscript.app('TextEdit').to_s)
|
20
|
+
assert_equal('app("/System/Applications/TextEdit.app")', Appscript.app.by_name('TextEdit').to_s)
|
27
21
|
|
28
22
|
assert_raises(Appscript::ApplicationNotFoundError) { Appscript.app('/non-existent/app') }
|
29
23
|
assert_raises(Appscript::ApplicationNotFoundError) { Appscript.app('non-existent.app') }
|
@@ -35,11 +29,11 @@ class TC_AppscriptNewApp < Test::Unit::TestCase
|
|
35
29
|
'com.apple.finder',
|
36
30
|
].each do |name|
|
37
31
|
a = Appscript.app.by_id(name)
|
38
|
-
|
32
|
+
refute_nil(a)
|
39
33
|
assert_instance_of(Appscript::Application, a)
|
40
34
|
assert_instance_of(Appscript::Reference, a.name)
|
41
35
|
end
|
42
|
-
assert_equal('app("/Applications/TextEdit.app")', Appscript.app.by_id('com.apple.textedit').to_s)
|
36
|
+
assert_equal('app("/System/Applications/TextEdit.app")', Appscript.app.by_id('com.apple.textedit').to_s)
|
43
37
|
|
44
38
|
assert_raises(Appscript::ApplicationNotFoundError) { Appscript.app.by_id('non.existent.app') }
|
45
39
|
end
|
@@ -47,7 +41,7 @@ class TC_AppscriptNewApp < Test::Unit::TestCase
|
|
47
41
|
def test_by_creator
|
48
42
|
a = Appscript.app.by_creator('ttxt')
|
49
43
|
assert_instance_of(Appscript::Reference, a.name)
|
50
|
-
assert_equal('app("/Applications/TextEdit.app")', a.to_s)
|
44
|
+
assert_equal('app("/System/Applications/TextEdit.app")', a.to_s)
|
51
45
|
assert_raises(Appscript::ApplicationNotFoundError) { Appscript.app.by_id('!@$o') }
|
52
46
|
end
|
53
47
|
|
@@ -60,14 +54,14 @@ class TC_AppscriptNewApp < Test::Unit::TestCase
|
|
60
54
|
end
|
61
55
|
|
62
56
|
def test_by_aem_app
|
63
|
-
a = Appscript.app.by_aem_app(AEM::Application.by_path('/Applications/TextEdit.app'))
|
57
|
+
a = Appscript.app.by_aem_app(AEM::Application.by_path('/System/Applications/TextEdit.app'))
|
64
58
|
assert_instance_of(Appscript::Reference, a.name)
|
65
|
-
assert_equal('app.by_aem_app(AEM::Application.by_path("/Applications/TextEdit.app"))', a.to_s)
|
59
|
+
assert_equal('app.by_aem_app(AEM::Application.by_path("/System/Applications/TextEdit.app"))', a.to_s)
|
66
60
|
end
|
67
61
|
end
|
68
62
|
|
69
63
|
|
70
|
-
class TC_AppscriptCommands < Test
|
64
|
+
class TC_AppscriptCommands < Minitest::Test
|
71
65
|
|
72
66
|
def setup
|
73
67
|
@te = Appscript.app('TextEdit')
|
@@ -75,6 +69,8 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
75
69
|
end
|
76
70
|
|
77
71
|
def test_commands_1
|
72
|
+
skip "Not on CI" if ENV["CI"]
|
73
|
+
|
78
74
|
assert_equal('TextEdit', @te.name.get)
|
79
75
|
d = @te.make(:new=>:document, :with_properties=>{:text=>'test test_commands'})
|
80
76
|
assert_instance_of(Appscript::Reference, d)
|
@@ -105,6 +101,8 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
105
101
|
end
|
106
102
|
|
107
103
|
def test_commands_2
|
104
|
+
skip "Not on CI" if ENV["CI"]
|
105
|
+
|
108
106
|
d = @te.make(:new=>:document, :at=>@te.documents.end)
|
109
107
|
|
110
108
|
@te.set(d.text, :to=> 'test1')
|
@@ -118,7 +116,7 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
118
116
|
|
119
117
|
assert_raises(Appscript::CommandError) { @te.documents[10000].get }
|
120
118
|
|
121
|
-
|
119
|
+
assert_kind_of(Integer, @te.documents.count)
|
122
120
|
assert_equal(@te.documents.count, @te.count(:each=>:document))
|
123
121
|
end
|
124
122
|
|
@@ -134,16 +132,16 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
134
132
|
assert_equal(r, @f.items[f].get)
|
135
133
|
|
136
134
|
assert_equal(@f.home.items.get, @f.home.items.get)
|
137
|
-
|
135
|
+
refute_equal(@f.disks['non-existent'], @f.disks[1].get)
|
138
136
|
end
|
139
137
|
|
140
138
|
def test_command_error
|
141
|
-
|
139
|
+
e = assert_raises Appscript::CommandError do
|
142
140
|
@f.items[10000].get
|
143
|
-
rescue Appscript::CommandError => e
|
144
|
-
assert_equal(-1728, e.to_i)
|
145
|
-
assert_equal("CommandError\n\t\tOSERROR: -1728\n\t\tMESSAGE: Can't get reference.\n\t\tOFFENDING OBJECT: app(\"/System/Library/CoreServices/Finder.app\").items[10000]\n\t\tCOMMAND: app(\"/System/Library/CoreServices/Finder.app\").items[10000].get()\n", e.to_s)
|
146
|
-
assert_instance_of(AEM::EventError, e.real_error)
|
147
141
|
end
|
142
|
+
|
143
|
+
assert_equal(-1728, e.to_i)
|
144
|
+
assert_equal("CommandError\n\t\tOSERROR: -1728\n\t\tMESSAGE: Can't get reference.\n\t\tOFFENDING OBJECT: 10000\n\t\tEXPECTED TYPE: :file_url\n\t\tCOMMAND: app(\"/System/Library/CoreServices/Finder.app\").items[10000].get()\n", e.to_s)
|
145
|
+
assert_instance_of(AEM::EventError, e.real_error)
|
148
146
|
end
|
149
147
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require "rb-scpt"
|
5
5
|
|
6
|
-
class TC_AppscriptReferences < Test
|
6
|
+
class TC_AppscriptReferences < Minitest::Test
|
7
7
|
|
8
8
|
def setup
|
9
9
|
@te = Appscript.app('TextEdit')
|
@@ -96,7 +96,7 @@ class TC_AppscriptReferences < Test::Unit::TestCase
|
|
96
96
|
val2 = @te.AS_app_data.unpack(d)
|
97
97
|
if val.class == @te.AS_app_data.unpack(d).class # note: Appscript::Reference and Appscript::GenericReference currently aren't comparable with each other, so the next test would always fail for those
|
98
98
|
assert_equal(val, val2)
|
99
|
-
|
99
|
+
assert_operator val, :eql?, val2
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
data/test/test_codecs.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require 'aem'
|
5
5
|
require 'kae'
|
6
6
|
require 'ae'
|
@@ -27,10 +27,7 @@ def ut16(s)
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
class TC_Codecs < Test::Unit::TestCase
|
30
|
+
class TC_Codecs < Minitest::Test
|
34
31
|
|
35
32
|
def setup
|
36
33
|
@c = AEM::Codecs.new
|
@@ -81,8 +78,13 @@ class TC_Codecs < Test::Unit::TestCase
|
|
81
78
|
data = num(data)
|
82
79
|
d = @c.pack(val)
|
83
80
|
assert_equal(type, d.type)
|
84
|
-
assert_equal(data, d.data)
|
85
|
-
|
81
|
+
assert_equal(data.b, d.data)
|
82
|
+
|
83
|
+
if type == KAE::TypeFloat then
|
84
|
+
assert_in_epsilon(val, @c.unpack(d))
|
85
|
+
else
|
86
|
+
assert_equal(val, @c.unpack(d))
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
@@ -104,7 +106,7 @@ class TC_Codecs < Test::Unit::TestCase
|
|
104
106
|
data = ut16(data)
|
105
107
|
d = @c.pack(val)
|
106
108
|
assert_equal(KAE::TypeUnicodeText, d.type)
|
107
|
-
assert_equal(data, d.data)
|
109
|
+
assert_equal(data.b, d.data)
|
108
110
|
assert_equal(val, @c.unpack(d))
|
109
111
|
end
|
110
112
|
assert_raises(TypeError) { @c.pack("\x88") } # non-valid UTF8 strings should raise error when coercing from typeUTF8Text to typeUnicodeText
|
@@ -119,17 +121,17 @@ class TC_Codecs < Test::Unit::TestCase
|
|
119
121
|
data = num(data)
|
120
122
|
d = @c.pack(t)
|
121
123
|
assert_equal(KAE::TypeLongDateTime, d.type)
|
122
|
-
assert_equal(data, d.data)
|
124
|
+
assert_equal(data.b, d.data)
|
123
125
|
assert_equal(t, @c.unpack(AE::AEDesc.new(KAE::TypeLongDateTime, data)))
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
127
129
|
def test_file
|
128
|
-
path = '/Applications/TextEdit.app'
|
130
|
+
path = '/System/Applications/TextEdit.app'
|
129
131
|
d = @c.pack(MacTypes::Alias.path(path))
|
130
132
|
assert_equal(path, @c.unpack(d).to_s)
|
131
133
|
|
132
|
-
path = '/Applications/TextEdit.app'
|
134
|
+
path = '/System/Applications/TextEdit.app'
|
133
135
|
d = @c.pack(MacTypes::FileURL.path(path))
|
134
136
|
assert_equal(path, @c.unpack(d).to_s)
|
135
137
|
end
|
@@ -144,10 +146,10 @@ class TC_Codecs < Test::Unit::TestCase
|
|
144
146
|
d = @c.pack(val)
|
145
147
|
val2 = @c.unpack(d)
|
146
148
|
assert_equal(val, val2)
|
147
|
-
|
149
|
+
assert_operator val, :eql?, val2
|
148
150
|
val2 = @c.unpack(d)
|
149
151
|
assert_equal(val2, val)
|
150
|
-
|
152
|
+
assert_operator val2, :eql?, val
|
151
153
|
end
|
152
154
|
assert_raises(ArgumentError) { AEM::AEType.new(3) }
|
153
155
|
assert_raises(ArgumentError) { AEM::AEType.new("docum") }
|
data/test/test_findapp.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitest/autorun"
|
4
4
|
require "_aem/findapp"
|
5
5
|
|
6
6
|
|
7
|
-
class TC_FindApp < Test
|
7
|
+
class TC_FindApp < Minitest::Test
|
8
8
|
|
9
9
|
def test_find
|
10
10
|
[
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
assert_equal(
|
11
|
+
"/System/Applications/Calendar.app",
|
12
|
+
"Calendar.app",
|
13
|
+
"Calendar",
|
14
|
+
].each do |name|
|
15
|
+
assert_equal("/System/Applications/Calendar.app", FindApp.by_name(name))
|
16
16
|
end
|
17
|
-
assert_equal(
|
18
|
-
assert_equal(
|
19
|
-
assert_raises(FindApp::ApplicationNotFoundError) { FindApp.by_name(
|
17
|
+
assert_equal("/System/Applications/TextEdit.app", FindApp.by_creator("ttxt"))
|
18
|
+
assert_equal("/System/Library/CoreServices/Finder.app", FindApp.by_id("com.apple.finder"))
|
19
|
+
assert_raises(FindApp::ApplicationNotFoundError) { FindApp.by_name("NON-EXISTENT-APP") }
|
20
20
|
|
21
21
|
# assert_equal("/Users/has/\306\222\303\270u\314\210.app", FindApp.by_name("\306\222\303\270u\314\210.app")) # utf8 paths work ok
|
22
22
|
end
|
data/test/test_mactypes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require "_aem/mactypes"
|
5
5
|
|
6
6
|
|
7
|
-
class TC_MacTypes < Test
|
7
|
+
class TC_MacTypes < Minitest::Test
|
8
8
|
|
9
9
|
def setup
|
10
10
|
@path1 = `mktemp -t codecs-test`.chomp
|
@@ -18,6 +18,8 @@ class TC_MacTypes < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_alias
|
21
|
+
skip "MacTypes::Alias needs to be ported off of Carbon's aliases"
|
22
|
+
|
21
23
|
# make alias
|
22
24
|
f = MacTypes::Alias.path(@path1)
|
23
25
|
|
@@ -42,9 +44,9 @@ class TC_MacTypes < Test::Unit::TestCase
|
|
42
44
|
# check alias keeps track of moved file
|
43
45
|
`mv #{@path1} #{@path2}`
|
44
46
|
# puts "alias path 2: #{f}" # /private/tmp/moved-codecs-test.HWr1EnE3
|
45
|
-
assert_equal(p2, f.to_s)
|
47
|
+
assert_equal(p2.b, f.to_s)
|
46
48
|
|
47
|
-
assert_equal(p2, normalize(f.path))
|
49
|
+
assert_equal(p2.b, normalize(f.path))
|
48
50
|
|
49
51
|
# check a FileNotFoundError is raised if getting path/FileURL for a filesystem object that no longer exists
|
50
52
|
`rm #{@path2}`
|
@@ -52,7 +54,7 @@ class TC_MacTypes < Test::Unit::TestCase
|
|
52
54
|
assert_raises(MacTypes::FileNotFoundError) { f.to_file_url } # File not found.
|
53
55
|
|
54
56
|
assert_equal(MacTypes::Alias.path("/Library/Scripts/"), MacTypes::Alias.path("/Library/Scripts/"))
|
55
|
-
|
57
|
+
refute_equal(MacTypes::Alias.path("/Library/Scripts/"), MacTypes::Alias.path("/Applications/"))
|
56
58
|
end
|
57
59
|
|
58
60
|
|
@@ -63,7 +65,7 @@ class TC_MacTypes < Test::Unit::TestCase
|
|
63
65
|
assert_equal('/non/existent path', g.to_s)
|
64
66
|
|
65
67
|
assert_equal('furl', g.desc.type)
|
66
|
-
assert_equal('file
|
68
|
+
assert_equal('file:///non/existent%20path', g.desc.data)
|
67
69
|
|
68
70
|
assert_equal('MacTypes::FileURL.path("/non/existent path")', g.to_file_url.inspect)
|
69
71
|
|
@@ -71,7 +73,7 @@ class TC_MacTypes < Test::Unit::TestCase
|
|
71
73
|
assert_raises(MacTypes::FileNotFoundError) { g.to_alias } # File "/non/existent path" not found.
|
72
74
|
|
73
75
|
assert_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::FileURL.path("/Library/Scripts/"))
|
74
|
-
|
75
|
-
|
76
|
+
refute_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::FileURL.path("/Applications/"))
|
77
|
+
refute_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::Alias.path("/Library/Scripts/"))
|
76
78
|
end
|
77
79
|
end
|
data/test/test_osax.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
require 'osax'
|
5
5
|
|
6
|
-
class TC_OSAX < Test
|
6
|
+
class TC_OSAX < Minitest::Test
|
7
7
|
|
8
8
|
def test_1
|
9
|
-
sa = OSAX.osax('
|
9
|
+
sa = OSAX.osax('StandardAdditions')
|
10
10
|
|
11
11
|
assert_equal(65, sa.ASCII_number('A'))
|
12
12
|
|
@@ -18,35 +18,47 @@ class TC_OSAX < Test::Unit::TestCase
|
|
18
18
|
assert_raises(RuntimeError) { sa.non_existent_command }
|
19
19
|
end
|
20
20
|
|
21
|
+
# These calls to `sa.ASCII_number` aren't valid anymore. They will
|
22
|
+
# intentionally raise a -10004 (privilege violation occurred) error
|
23
|
+
# due to unnecessary cross-application scripting (ie, the command is
|
24
|
+
# perfectly fine in the current application rather than the "remote"
|
25
|
+
# application). See:
|
26
|
+
#
|
27
|
+
# https://developer.apple.com/library/archive/releasenotes/AppleScript/RN-AppleScript/RN-10_6/RN-10_6.html#//apple_ref/doc/uid/TP40000982-CH106-SW6
|
28
|
+
#
|
29
|
+
# As such, maybe these tests should be performing something with the
|
30
|
+
# finder? Hrm. Nope! That's an error too. `sa` is the
|
31
|
+
# StandardAdditions osax and nothing shall change that. I'm not
|
32
|
+
# really sure what these tests were trying to achive tbh.
|
33
|
+
|
21
34
|
def test_2
|
22
|
-
sa = OSAX.osax('
|
23
|
-
assert_equal(65, sa.ASCII_number('A'))
|
35
|
+
sa = OSAX.osax('StandardAdditions').by_name('Finder')
|
36
|
+
# assert_equal(65, sa.ASCII_number('A'))
|
24
37
|
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
25
38
|
end
|
26
39
|
|
27
40
|
def test_3
|
28
|
-
sa = OSAX.osax('
|
29
|
-
assert_equal(65, sa.ASCII_number('A'))
|
41
|
+
sa = OSAX.osax('StandardAdditions').by_creator('MACS')
|
42
|
+
# assert_equal(65, sa.ASCII_number('A'))
|
30
43
|
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
31
44
|
end
|
32
45
|
|
33
46
|
def test_4
|
34
|
-
sa = OSAX.osax('
|
35
|
-
assert_equal(65, sa.ASCII_number('A'))
|
47
|
+
sa = OSAX.osax('StandardAdditions').by_id('com.apple.Finder')
|
48
|
+
# assert_equal(65, sa.ASCII_number('A'))
|
36
49
|
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
37
50
|
end
|
38
51
|
|
39
52
|
def test_5
|
40
|
-
|
53
|
+
pid = `top -l1 | grep Finder | awk '{ print $1 }'`.to_i
|
54
|
+
sa = OSAX.osax('StandardAdditions').by_pid(pid)
|
55
|
+
# assert_equal(65, sa.ASCII_number('A'))
|
41
56
|
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
42
|
-
assert_equal(65, sa.ASCII_number('A'))
|
43
57
|
end
|
44
58
|
|
45
59
|
def test_6
|
46
|
-
sa = OSAX.osax('
|
47
|
-
assert_equal(65, sa.ASCII_number('A'))
|
60
|
+
sa = OSAX.osax('StandardAdditions').by_aem_app(AEM::Application.by_path("/System/Library/CoreServices/Finder.app/"))
|
61
|
+
# assert_equal(65, sa.ASCII_number('A'))
|
48
62
|
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
49
63
|
end
|
50
|
-
|
51
|
-
|
52
64
|
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,26 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-scpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hhas
|
8
8
|
- Brendan Thompson
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
15
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
16
|
+
GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
|
17
|
+
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
18
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
19
|
+
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
20
|
+
taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
|
21
|
+
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
22
|
+
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
23
|
+
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
24
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
25
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
26
|
+
AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
|
27
|
+
XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
|
28
|
+
bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
|
29
|
+
B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
|
30
|
+
S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
|
31
|
+
deKfBjgVAq7EYHu1AczzlUly
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2024-04-26 00:00:00.000000000 Z
|
13
34
|
dependencies: []
|
14
|
-
description:
|
35
|
+
description:
|
15
36
|
email: brendan@btsystems.com.au
|
16
37
|
executables: []
|
17
38
|
extensions:
|
18
|
-
- extconf.rb
|
39
|
+
- ext/ae/extconf.rb
|
19
40
|
extra_rdoc_files: []
|
20
41
|
files:
|
42
|
+
- ".gitignore"
|
21
43
|
- CHANGES
|
22
|
-
-
|
23
|
-
-
|
44
|
+
- Manifest.txt
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
24
47
|
- doc/aem-manual/01_introduction.html
|
25
48
|
- doc/aem-manual/02_apioverview.html
|
26
49
|
- doc/aem-manual/03_packingandunpackingdata.html
|
@@ -64,7 +87,28 @@ files:
|
|
64
87
|
- doc/osax-manual/04_notes.html
|
65
88
|
- doc/osax-manual/index.html
|
66
89
|
- doc/rb-appscript-logo.png
|
67
|
-
-
|
90
|
+
- ext/ae/SendThreadSafe.c
|
91
|
+
- ext/ae/SendThreadSafe.h
|
92
|
+
- ext/ae/ae.c
|
93
|
+
- ext/ae/extconf.rb
|
94
|
+
- lib/_aem/aemreference.rb
|
95
|
+
- lib/_aem/codecs.rb
|
96
|
+
- lib/_aem/connect.rb
|
97
|
+
- lib/_aem/encodingsupport.rb
|
98
|
+
- lib/_aem/findapp.rb
|
99
|
+
- lib/_aem/mactypes.rb
|
100
|
+
- lib/_aem/send.rb
|
101
|
+
- lib/_aem/typewrappers.rb
|
102
|
+
- lib/_appscript/defaultterminology.rb
|
103
|
+
- lib/_appscript/referencerenderer.rb
|
104
|
+
- lib/_appscript/reservedkeywords.rb
|
105
|
+
- lib/_appscript/safeobject.rb
|
106
|
+
- lib/_appscript/terminology.rb
|
107
|
+
- lib/aem.rb
|
108
|
+
- lib/kae.rb
|
109
|
+
- lib/osax.rb
|
110
|
+
- lib/rb-scpt.rb
|
111
|
+
- lib/version.rb
|
68
112
|
- rb-scpt.gemspec
|
69
113
|
- sample/AB_export_vcard.rb
|
70
114
|
- sample/AB_list_people_with_emails.rb
|
@@ -83,26 +127,6 @@ files:
|
|
83
127
|
- sample/Stagger_Finder_windows.rb
|
84
128
|
- sample/TextEdit_demo.rb
|
85
129
|
- sample/iTunes_top40_to_html.rb
|
86
|
-
- src/SendThreadSafe.c
|
87
|
-
- src/SendThreadSafe.h
|
88
|
-
- src/lib/_aem/aemreference.rb
|
89
|
-
- src/lib/_aem/codecs.rb
|
90
|
-
- src/lib/_aem/connect.rb
|
91
|
-
- src/lib/_aem/encodingsupport.rb
|
92
|
-
- src/lib/_aem/findapp.rb
|
93
|
-
- src/lib/_aem/mactypes.rb
|
94
|
-
- src/lib/_aem/send.rb
|
95
|
-
- src/lib/_aem/typewrappers.rb
|
96
|
-
- src/lib/_appscript/defaultterminology.rb
|
97
|
-
- src/lib/_appscript/referencerenderer.rb
|
98
|
-
- src/lib/_appscript/reservedkeywords.rb
|
99
|
-
- src/lib/_appscript/safeobject.rb
|
100
|
-
- src/lib/_appscript/terminology.rb
|
101
|
-
- src/lib/aem.rb
|
102
|
-
- src/lib/kae.rb
|
103
|
-
- src/lib/osax.rb
|
104
|
-
- src/lib/rb-scpt.rb
|
105
|
-
- src/rbae.c
|
106
130
|
- test/README
|
107
131
|
- test/test_aemreference.rb
|
108
132
|
- test/test_appscriptcommands.rb
|
@@ -111,11 +135,11 @@ files:
|
|
111
135
|
- test/test_findapp.rb
|
112
136
|
- test/test_mactypes.rb
|
113
137
|
- test/test_osax.rb
|
114
|
-
- test/testall.sh
|
115
138
|
homepage: https://github.com/BrendanThompson/rb-scpt
|
116
|
-
licenses:
|
139
|
+
licenses:
|
140
|
+
- AML
|
117
141
|
metadata: {}
|
118
|
-
post_install_message:
|
142
|
+
post_install_message:
|
119
143
|
rdoc_options: []
|
120
144
|
require_paths:
|
121
145
|
- lib
|
@@ -123,25 +147,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
147
|
requirements:
|
124
148
|
- - ">="
|
125
149
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
150
|
+
version: '2.7'
|
127
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
152
|
requirements:
|
129
153
|
- - ">="
|
130
154
|
- !ruby/object:Gem::Version
|
131
155
|
version: '0'
|
132
156
|
requirements: []
|
133
|
-
|
134
|
-
|
135
|
-
signing_key:
|
157
|
+
rubygems_version: 3.5.3
|
158
|
+
signing_key:
|
136
159
|
specification_version: 4
|
137
160
|
summary: This is a fork of the original rb-appscript. Ruby AppleScript (rb-scpt) is
|
138
161
|
a high-level, user-friendly Apple event bridge that allows you to control scriptable
|
139
162
|
Mac OS X applications using ordinary Ruby scripts.
|
140
163
|
test_files:
|
164
|
+
- test/README
|
165
|
+
- test/test_aemreference.rb
|
166
|
+
- test/test_appscriptcommands.rb
|
167
|
+
- test/test_appscriptreference.rb
|
141
168
|
- test/test_codecs.rb
|
169
|
+
- test/test_findapp.rb
|
142
170
|
- test/test_mactypes.rb
|
143
|
-
- test/test_appscriptcommands.rb
|
144
|
-
- test/test_aemreference.rb
|
145
171
|
- test/test_osax.rb
|
146
|
-
- test/test_findapp.rb
|
147
|
-
- test/test_appscriptreference.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/bin/rb-scpt-1.0.0.gem
DELETED
Binary file
|
data/bin/rb-scpt-1.0.1.gem
DELETED
Binary file
|
data/test/testall.sh
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/data/{src/lib → lib}/kae.rb
RENAMED
File without changes
|