rb-scpt 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/test/test_findapp.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
begin; require 'rubygems'; rescue LoadError; end
|
4
|
-
|
5
3
|
require 'test/unit'
|
6
4
|
require "_aem/findapp"
|
7
5
|
|
8
6
|
|
9
7
|
class TC_FindApp < Test::Unit::TestCase
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
def test_find
|
10
|
+
[
|
11
|
+
['/Applications/iCal.app', '/Applications/iCal.app'],
|
12
|
+
['ical.app', '/Applications/iCal.app'],
|
13
|
+
['ICAL', '/Applications/iCal.app'],
|
14
|
+
].each do |val, res|
|
15
|
+
assert_equal(res, FindApp.by_name(val))
|
16
|
+
end
|
17
|
+
assert_equal('/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') }
|
22
20
|
|
23
|
-
|
24
|
-
|
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
|
+
end
|
25
23
|
end
|
26
|
-
|
data/test/test_mactypes.rb
CHANGED
@@ -1,79 +1,77 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
begin; require 'rubygems'; rescue LoadError; end
|
4
|
-
|
5
3
|
require 'test/unit'
|
6
4
|
require "_aem/mactypes"
|
7
5
|
|
8
6
|
|
9
7
|
class TC_MacTypes < Test::Unit::TestCase
|
10
|
-
|
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
|
-
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@path1 = `mktemp -t codecs-test`.chomp
|
11
|
+
dir, fname = File.split(@path1)
|
12
|
+
@path2 = File.join(dir, 'moved-' + fname)
|
13
|
+
# puts "path: #{@path1}" # e.g. /tmp/codecs-test.HWr1EnE3
|
14
|
+
end
|
15
|
+
|
16
|
+
def normalize(path)
|
17
|
+
return path.gsub(/\/+/, '/') # quick-n-dirty
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_alias
|
21
|
+
# make alias
|
22
|
+
f = MacTypes::Alias.path(@path1)
|
23
|
+
|
24
|
+
|
25
|
+
assert_equal(MacTypes::Alias.path(@path1), f)
|
26
|
+
|
27
|
+
# get path
|
28
|
+
# note that initial /tmp/codecs-test... path will automatically change to /private/tmp/codecs-test...
|
29
|
+
p1 = normalize('/private'+@path1)
|
30
|
+
p2 = normalize('/private'+@path2)
|
31
|
+
|
32
|
+
assert_equal(p1, normalize(f.path))
|
33
|
+
|
34
|
+
#puts "alias path 1: #{f}" # e.g. /private/tmp/codecs-test.HWr1EnE3
|
35
|
+
assert_equal(p1, f.to_s)
|
36
|
+
|
37
|
+
# get desc
|
38
|
+
#puts f.desc.type, f.desc.data # alis, [binary data]
|
39
|
+
assert_equal('alis', f.desc.type)
|
40
|
+
|
41
|
+
|
42
|
+
# check alias keeps track of moved file
|
43
|
+
`mv #{@path1} #{@path2}`
|
44
|
+
# puts "alias path 2: #{f}" # /private/tmp/moved-codecs-test.HWr1EnE3
|
45
|
+
assert_equal(p2, f.to_s)
|
46
|
+
|
47
|
+
assert_equal(p2, normalize(f.path))
|
48
|
+
|
49
|
+
# check a FileNotFoundError is raised if getting path/FileURL for a filesystem object that no longer exists
|
50
|
+
`rm #{@path2}`
|
51
|
+
assert_raises(MacTypes::FileNotFoundError) { f.to_s } # File not found.
|
52
|
+
assert_raises(MacTypes::FileNotFoundError) { f.to_file_url } # File not found.
|
53
|
+
|
54
|
+
assert_equal(MacTypes::Alias.path("/Library/Scripts/"), MacTypes::Alias.path("/Library/Scripts/"))
|
55
|
+
assert_not_equal(MacTypes::Alias.path("/Library/Scripts/"), MacTypes::Alias.path("/Applications/"))
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def test_file_url
|
60
|
+
|
61
|
+
g = MacTypes::FileURL.path('/non/existent path')
|
62
|
+
|
63
|
+
assert_equal('/non/existent path', g.to_s)
|
64
|
+
|
65
|
+
assert_equal('furl', g.desc.type)
|
66
|
+
assert_equal('file://localhost/non/existent%20path', g.desc.data)
|
67
|
+
|
68
|
+
assert_equal('MacTypes::FileURL.path("/non/existent path")', g.to_file_url.inspect)
|
69
|
+
|
70
|
+
# check a not-found error is raised if getting Alias for a filesystem object that doesn't exist
|
71
|
+
assert_raises(MacTypes::FileNotFoundError) { g.to_alias } # File "/non/existent path" not found.
|
72
|
+
|
73
|
+
assert_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::FileURL.path("/Library/Scripts/"))
|
74
|
+
assert_not_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::FileURL.path("/Applications/"))
|
75
|
+
assert_not_equal(MacTypes::FileURL.path("/Library/Scripts/"), MacTypes::Alias.path("/Library/Scripts/"))
|
76
|
+
end
|
77
|
+
end
|
data/test/test_osax.rb
CHANGED
@@ -1,54 +1,52 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
begin; require 'rubygems'; rescue LoadError; end
|
4
|
-
|
5
3
|
require 'test/unit'
|
6
4
|
require 'osax'
|
7
5
|
|
8
6
|
class TC_OSAX < Test::Unit::TestCase
|
9
|
-
|
10
|
-
|
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
|
-
end
|
7
|
+
|
8
|
+
def test_1
|
9
|
+
sa = OSAX.osax('Standardadditions')
|
10
|
+
|
11
|
+
assert_equal(65, sa.ASCII_number('A'))
|
12
|
+
|
13
|
+
assert_equal(MacTypes::Alias.path("/Applications/"), sa.path_to(:applications_folder))
|
14
|
+
|
15
|
+
assert_equal(MacTypes::Alias.path("/Library/Scripts/"),
|
16
|
+
sa.path_to(:scripts_folder, :from=>:local_domain))
|
17
|
+
|
18
|
+
assert_raises(RuntimeError) { sa.non_existent_command }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_2
|
22
|
+
sa = OSAX.osax('Standardadditions').by_name('Finder')
|
23
|
+
assert_equal(65, sa.ASCII_number('A'))
|
24
|
+
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_3
|
28
|
+
sa = OSAX.osax('Standardadditions').by_creator('MACS')
|
29
|
+
assert_equal(65, sa.ASCII_number('A'))
|
30
|
+
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_4
|
34
|
+
sa = OSAX.osax('Standardadditions').by_id('com.apple.finder')
|
35
|
+
assert_equal(65, sa.ASCII_number('A'))
|
36
|
+
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_5
|
40
|
+
sa = OSAX.osax('Standardadditions').by_pid(`top -l1 | grep Finder | awk '{ print $1 }'`.to_i)
|
41
|
+
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
42
|
+
assert_equal(65, sa.ASCII_number('A'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_6
|
46
|
+
sa = OSAX.osax('Standardadditions').by_aem_app(AEM::Application.by_path("/System/Library/CoreServices/Finder.app/"))
|
47
|
+
assert_equal(65, sa.ASCII_number('A'))
|
48
|
+
assert_equal(MacTypes::Alias.path("/System/Library/CoreServices/Finder.app/"), sa.path_to(nil))
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
data/test/testall.sh
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hhas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: brendan@btsystems.com.au
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- CHANGES
|
22
22
|
- bin/rb-scpt-1.0.0.gem
|
23
|
+
- bin/rb-scpt-1.0.1.gem
|
23
24
|
- doc/aem-manual/01_introduction.html
|
24
25
|
- doc/aem-manual/02_apioverview.html
|
25
26
|
- doc/aem-manual/03_packingandunpackingdata.html
|
@@ -130,17 +131,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: '0'
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.6.13
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: This is a fork of the original rb-appscript. Ruby AppleScript (rb-scpt) is
|
137
138
|
a high-level, user-friendly Apple event bridge that allows you to control scriptable
|
138
139
|
Mac OS X applications using ordinary Ruby scripts.
|
139
140
|
test_files:
|
140
|
-
- test/test_aemreference.rb
|
141
|
-
- test/test_appscriptcommands.rb
|
142
|
-
- test/test_appscriptreference.rb
|
143
141
|
- test/test_codecs.rb
|
144
|
-
- test/test_findapp.rb
|
145
142
|
- test/test_mactypes.rb
|
143
|
+
- test/test_appscriptcommands.rb
|
144
|
+
- test/test_aemreference.rb
|
146
145
|
- test/test_osax.rb
|
146
|
+
- test/test_findapp.rb
|
147
|
+
- test/test_appscriptreference.rb
|