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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 470ba8dfaf4bbe261d30036cd5fa9bd5788f2a9d
|
4
|
+
data.tar.gz: 30eb7123f32488069a4436957bac32d3526d4578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6e8dbdea21e3f3cf21574a413a6ca66f2a8190ccf6887044ad58790ce60e6a82b3e2ef0b94ea453cbd97cea516ab52fbe7067346853782ef1073ba724c6e6f6
|
7
|
+
data.tar.gz: 721f9a75a460b0601e1faf0bfe0b1b76e742615f1f3ffaf4346c6e0bef36953f6fd5fcf67e9b4b4e355aa55261206b781f7362618dc8999720d3457330bc241f
|
Binary file
|
data/extconf.rb
CHANGED
@@ -40,26 +40,26 @@ $LDFLAGS << ' -framework Carbon -framework ApplicationServices'
|
|
40
40
|
maj, min = RUBY_VERSION.split('.')
|
41
41
|
is_ruby_18 = (maj <= '1' and min.to_i < 9)
|
42
42
|
if is_ruby_18
|
43
|
-
|
43
|
+
header_path = RbConfig::CONFIG['archdir']
|
44
44
|
else
|
45
|
-
|
45
|
+
header_path = File.join(RbConfig::CONFIG['rubyhdrdir'], 'ruby')
|
46
46
|
end
|
47
47
|
ruby_h = File.join(header_path, 'ruby.h')
|
48
48
|
intern_h = File.join(header_path, 'intern.h')
|
49
49
|
new_filename_prefix = 'osx_'
|
50
50
|
|
51
51
|
[ ruby_h, intern_h ].each do |src_path|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
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
|
62
61
|
end
|
62
|
+
end
|
63
63
|
end
|
64
64
|
|
65
65
|
create_makefile('ae', 'src')
|
data/rb-scpt.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
s.name = "rb-scpt"
|
5
|
+
s.version = "1.0.2"
|
6
|
+
s.homepage = "https://github.com/BrendanThompson/rb-scpt"
|
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 = Dir["**/*"].delete_if { |name| ["MakeFile", "ae.bundle", "mkmf.log", "rbae.o", "SendThreadSafe.o", "src/osx_ruby.h", "src/osx_intern.h"].include?(name) }
|
9
|
+
s.extensions = "extconf.rb"
|
10
|
+
s.test_files = Dir["test/test_*.rb"]
|
11
|
+
s.authors = ["hhas","Brendan Thompson"]
|
12
|
+
s.email = 'brendan@btsystems.com.au'
|
13
|
+
s.required_ruby_version = ">= 1.8"
|
14
14
|
end
|
data/sample/AB_export_vcard.rb
CHANGED
@@ -11,21 +11,21 @@
|
|
11
11
|
# Note: if using the appscript gem, rubygems must be required first:
|
12
12
|
begin; require 'rubygems'; rescue LoadError; end
|
13
13
|
|
14
|
-
require 'appscript'
|
15
|
-
include Appscript
|
14
|
+
require 'appscript'
|
15
|
+
include Appscript
|
16
16
|
|
17
|
-
people = app('Address Book').people
|
17
|
+
people = app('Address Book').people
|
18
18
|
|
19
|
-
found_names = []
|
20
|
-
people.name.get.zip(people.vcard.get).each do |name, vcard|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
19
|
+
found_names = []
|
20
|
+
people.name.get.zip(people.vcard.get).each do |name, vcard|
|
21
|
+
name = 'unknown' if name == ''
|
22
|
+
name = name.gsub('/', ':')
|
23
|
+
filename = "#{name}.vcard"
|
24
|
+
i = 1
|
25
|
+
while found_names.include?(filename.downcase)
|
26
|
+
filename = "#{name} #{i}.vcard"
|
27
|
+
i += 1
|
28
|
+
end
|
29
|
+
found_names.push(filename.downcase)
|
30
|
+
File.open(filename, 'w') { |f| f.puts vcard }
|
31
|
+
end
|
@@ -6,8 +6,8 @@
|
|
6
6
|
# Note: if using the appscript gem, rubygems must be required first:
|
7
7
|
begin; require 'rubygems'; rescue LoadError; end
|
8
8
|
|
9
|
-
require "appscript"
|
10
|
-
include Appscript
|
9
|
+
require "appscript"
|
10
|
+
include Appscript
|
11
11
|
|
12
|
-
people_ref = app('Address Book').people[its.emails.ne([])]
|
13
|
-
p people_ref.name.get.zip(people_ref.emails.value.get)
|
12
|
+
people_ref = app('Address Book').people[its.emails.ne([])]
|
13
|
+
p people_ref.name.get.zip(people_ref.emails.value.get)
|
data/sample/Add_iCal_event.rb
CHANGED
@@ -5,17 +5,17 @@
|
|
5
5
|
# Note: if using the appscript gem, rubygems must be required first:
|
6
6
|
begin; require 'rubygems'; rescue LoadError; end
|
7
7
|
|
8
|
-
require 'appscript'
|
9
|
-
include Appscript
|
8
|
+
require 'appscript'
|
9
|
+
include Appscript
|
10
10
|
|
11
|
-
calendar_name = 'Home'
|
12
|
-
t = Time.now + 60 * 60 * 24
|
13
|
-
start = Time.local(t.year, t.month, t.day, 7)
|
14
|
-
end_ = start + 60 * 60 * 2
|
15
|
-
summary = 'First pants, then shoes.'
|
11
|
+
calendar_name = 'Home'
|
12
|
+
t = Time.now + 60 * 60 * 24
|
13
|
+
start = Time.local(t.year, t.month, t.day, 7)
|
14
|
+
end_ = start + 60 * 60 * 2
|
15
|
+
summary = 'First pants, then shoes.'
|
16
16
|
|
17
|
-
app('iCal').calendars[calendar_name].events.end.make(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
app('iCal').calendars[calendar_name].events.end.make(
|
18
|
+
:new => :event, :with_properties => {
|
19
|
+
:start_date => start,
|
20
|
+
:end_date => end_,
|
21
|
+
:summary => summary})
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Creates daily recurring todo items in iCal.
|
4
4
|
#
|
5
|
-
# Ported from 'Create daily todos.scpt' by Alexander Kellett
|
5
|
+
# Ported from 'Create daily todos.scpt' by Alexander Kellett
|
6
6
|
# <http://web.mac.com/lypanov>
|
7
7
|
#
|
8
8
|
# While iCal makes it easy to create recurring events, it lacks a similar
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# of things to do.
|
11
11
|
#
|
12
12
|
# To begin, create a new calendar with the name "Shadow". Then, add a number
|
13
|
-
# of recurring events to this calendar. All Daily To Dos events must be
|
13
|
+
# of recurring events to this calendar. All Daily To Dos events must be
|
14
14
|
# recurring events as only recurring events are converted to To Dos. Start and
|
15
15
|
# end dates are ignored.
|
16
16
|
#
|
@@ -27,49 +27,49 @@
|
|
27
27
|
# Note: if using the appscript gem, rubygems must be required first:
|
28
28
|
begin; require 'rubygems'; rescue LoadError; end
|
29
29
|
|
30
|
-
require "appscript"
|
31
|
-
include Appscript
|
30
|
+
require "appscript"
|
31
|
+
include Appscript
|
32
32
|
|
33
|
-
ICal = app("iCal")
|
33
|
+
ICal = app("iCal")
|
34
34
|
|
35
|
-
# The calendar in which recurring todo items should appear:
|
36
|
-
ToDoCalendarName = "Personal"
|
37
|
-
|
38
|
-
def create_to_do(summary_text)
|
35
|
+
# The calendar in which recurring todo items should appear:
|
36
|
+
ToDoCalendarName = "Personal"
|
37
|
+
|
38
|
+
def create_to_do(summary_text)
|
39
39
|
# Adds To Dos to calendar "Personal"
|
40
40
|
now = Time.new
|
41
41
|
midnight = Time.local(now.year(), now.month(), now.day())
|
42
42
|
to_dos = ICal.calendars[ToDoCalendarName].todos
|
43
43
|
# don't create an item if it already exists for today!
|
44
44
|
if to_dos[its.due_date.ge(midnight).and(
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
its.summary.eq(summary_text))].count < 1
|
46
|
+
to_dos.end.make(:new=>:todo, :with_properties=>{
|
47
|
+
:due_date=>midnight, :summary=>summary_text})
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
50
50
|
|
51
|
-
def get_label(recurrence, label)
|
51
|
+
def get_label(recurrence, label)
|
52
52
|
match = Regexp.new("(?:^|;)#{label}=(.*?)(?:$|;)").match(recurrence)
|
53
53
|
return match ? match[1] : nil
|
54
|
-
end
|
54
|
+
end
|
55
55
|
|
56
|
-
weekday_code = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"][Time.new.wday]
|
57
|
-
events = ICal.calendars["Shadow"].events
|
56
|
+
weekday_code = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"][Time.new.wday]
|
57
|
+
events = ICal.calendars["Shadow"].events
|
58
58
|
|
59
|
-
events.recurrence.get.zip(events.summary.get).each do |recurrence, summary|
|
59
|
+
events.recurrence.get.zip(events.summary.get).each do |recurrence, summary|
|
60
60
|
recurs_on_this_weekday = false
|
61
61
|
frequency = get_label(recurrence, "FREQ")
|
62
62
|
case frequency
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
when "WEEKLY"
|
64
|
+
days = get_label(recurrence, "BYDAY")
|
65
|
+
if days and days.split(",").include?(weekday_code)
|
66
|
+
recurs_on_this_weekday = true
|
67
|
+
end
|
68
|
+
when "DAILY"
|
69
|
+
recurs_on_this_weekday = true
|
70
70
|
end
|
71
71
|
if recurs_on_this_weekday
|
72
|
-
|
73
|
-
|
72
|
+
puts summary
|
73
|
+
create_to_do(summary)
|
74
74
|
end
|
75
|
-
end
|
75
|
+
end
|
@@ -5,55 +5,55 @@
|
|
5
5
|
# Note: if using the appscript gem, rubygems must be required first:
|
6
6
|
begin; require 'rubygems'; rescue LoadError; end
|
7
7
|
|
8
|
-
require "osax"
|
9
|
-
include Appscript, OSAX
|
10
|
-
|
11
|
-
# create Application object for Address Book
|
12
|
-
AB = app("Address Book")
|
13
|
-
|
14
|
-
# prompt user for name of Address Book group to export from
|
15
|
-
DefaultChoice = ["<All>"]
|
16
|
-
|
17
|
-
groups = DefaultChoice + AB.groups.name.get
|
18
|
-
choice = osax.choose_from_list(groups, :default_items => DefaultChoice)
|
19
|
-
if choice == false # user cancelled
|
20
|
-
|
21
|
-
elsif choice == DefaultChoice
|
22
|
-
|
23
|
-
else
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
# build a reference identifying those people with one or more phone numbers
|
28
|
-
p = ref.people[its.phones.ne([])]
|
29
|
-
|
30
|
-
# get first and last names for those people, replacing any :missing_value
|
31
|
-
# entries with empty strings
|
32
|
-
last_names = p.last_name.get.collect { |val| val.is_a?(String) ? val : "" }
|
33
|
-
first_names = p.first_name.get.collect { |val| val.is_a?(String) ? val : "" }
|
34
|
-
|
35
|
-
# get lists of phone numbers and locations for those people
|
36
|
-
locations = p.phones.label.get
|
37
|
-
numbers = p.phones.value.get
|
38
|
-
|
39
|
-
# build an array containing each person's details:
|
40
|
-
# [[last name, first name, locations, numbers], ...]
|
41
|
-
people = last_names.zip(first_names, locations, numbers)
|
42
|
-
|
43
|
-
# sort array by last and first name
|
44
|
-
people.sort! do |a, b|
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
# print table
|
49
|
-
puts " #{'_' * 70} "
|
50
|
-
people.each do |last_name, first_name, locations, numbers|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
8
|
+
require "osax"
|
9
|
+
include Appscript, OSAX
|
10
|
+
|
11
|
+
# create Application object for Address Book
|
12
|
+
AB = app("Address Book")
|
13
|
+
|
14
|
+
# prompt user for name of Address Book group to export from
|
15
|
+
DefaultChoice = ["<All>"]
|
16
|
+
|
17
|
+
groups = DefaultChoice + AB.groups.name.get
|
18
|
+
choice = osax.choose_from_list(groups, :default_items => DefaultChoice)
|
19
|
+
if choice == false # user cancelled
|
20
|
+
exit
|
21
|
+
elsif choice == DefaultChoice
|
22
|
+
ref = AB
|
23
|
+
else
|
24
|
+
ref = AB.groups[choice[0]]
|
25
|
+
end
|
26
|
+
|
27
|
+
# build a reference identifying those people with one or more phone numbers
|
28
|
+
p = ref.people[its.phones.ne([])]
|
29
|
+
|
30
|
+
# get first and last names for those people, replacing any :missing_value
|
31
|
+
# entries with empty strings
|
32
|
+
last_names = p.last_name.get.collect { |val| val.is_a?(String) ? val : "" }
|
33
|
+
first_names = p.first_name.get.collect { |val| val.is_a?(String) ? val : "" }
|
34
|
+
|
35
|
+
# get lists of phone numbers and locations for those people
|
36
|
+
locations = p.phones.label.get
|
37
|
+
numbers = p.phones.value.get
|
38
|
+
|
39
|
+
# build an array containing each person's details:
|
40
|
+
# [[last name, first name, locations, numbers], ...]
|
41
|
+
people = last_names.zip(first_names, locations, numbers)
|
42
|
+
|
43
|
+
# sort array by last and first name
|
44
|
+
people.sort! do |a, b|
|
45
|
+
a[0,2].collect { |s| s.downcase } <=> b[0,2].collect { |s| s.downcase }
|
46
|
+
end
|
47
|
+
|
48
|
+
# print table
|
49
|
+
puts " #{'_' * 70} "
|
50
|
+
people.each do |last_name, first_name, locations, numbers|
|
51
|
+
name = [last_name, first_name].delete_if { |s| s == "" }.join(', ')
|
52
|
+
puts "|#{' ' * 70}|"
|
53
|
+
# print each phone number in turn
|
54
|
+
numbers.zip(locations).each do |number, location|
|
55
|
+
puts "| #{name.ljust(32)} #{number.ljust(20)} (#{(location + ')').ljust(13)} |"
|
56
|
+
name = ""
|
57
|
+
end
|
58
|
+
puts "|#{'_' * 70}|"
|
59
|
+
end
|
data/sample/Hello_world.rb
CHANGED
@@ -3,19 +3,19 @@
|
|
3
3
|
# Note: if using the appscript gem, rubygems must be required first:
|
4
4
|
begin; require 'rubygems'; rescue LoadError; end
|
5
5
|
|
6
|
-
# 1. "Hello world" in TextEdit:
|
6
|
+
# 1. "Hello world" in TextEdit:
|
7
7
|
|
8
|
-
require "appscript"
|
9
|
-
include Appscript
|
8
|
+
require "appscript"
|
9
|
+
include Appscript
|
10
10
|
|
11
|
-
te = app('TextEdit')
|
12
|
-
te.activate
|
13
|
-
te.documents.end.make(:new => :document, :with_properties => {:text => "Hello World!\n"})
|
11
|
+
te = app('TextEdit')
|
12
|
+
te.activate
|
13
|
+
te.documents.end.make(:new => :document, :with_properties => {:text => "Hello World!\n"})
|
14
14
|
|
15
15
|
|
16
|
-
# 2. "Hello world" using StandardAdditions:
|
16
|
+
# 2. "Hello world" using StandardAdditions:
|
17
17
|
|
18
|
-
require "osax"
|
19
|
-
include OSAX
|
18
|
+
require "osax"
|
19
|
+
include OSAX
|
20
20
|
|
21
|
-
osax.display_dialog("Hello World")
|
21
|
+
osax.display_dialog("Hello World")
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Note: if using the appscript gem, rubygems must be required first:
|
6
6
|
begin; require 'rubygems'; rescue LoadError; end
|
7
7
|
|
8
|
-
require "appscript"
|
9
|
-
include Appscript
|
8
|
+
require "appscript"
|
9
|
+
include Appscript
|
10
10
|
|
11
|
-
p app('iTunes').sources[1].user_playlists.name.get
|
11
|
+
p app('iTunes').sources[1].user_playlists.name.get
|
data/sample/Make_Mail_message.rb
CHANGED
@@ -5,29 +5,29 @@
|
|
5
5
|
# Note: if using the appscript gem, rubygems must be required first:
|
6
6
|
begin; require 'rubygems'; rescue LoadError; end
|
7
7
|
|
8
|
-
require "appscript"
|
9
|
-
include Appscript
|
8
|
+
require "appscript"
|
9
|
+
include Appscript
|
10
10
|
|
11
|
-
def make_message(addresses, subject, content, show_window=false)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
11
|
+
def make_message(addresses, subject, content, show_window=false)
|
12
|
+
# Make an outgoing message in Mail.
|
13
|
+
# addresses : list of unicode -- a list of email addresses
|
14
|
+
# subject : unicode -- the message subject
|
15
|
+
# content : unicode -- the message content
|
16
|
+
# show_window : Boolean -- show message window in Mail
|
17
|
+
# Result : reference -- reference to the new outgoing message
|
18
|
+
mail = app('Mail')
|
19
|
+
msg = mail.make(
|
20
|
+
:new => :outgoing_message,
|
21
|
+
:with_properties => {:visible => show_window})
|
22
|
+
addresses.each do |an_address|
|
23
|
+
msg.to_recipients.end.make(
|
24
|
+
:new => :recipient,
|
25
|
+
:with_properties => {:address => an_address})
|
26
|
+
end
|
27
|
+
msg.subject.set(subject)
|
28
|
+
msg.content.set(content)
|
29
|
+
return msg
|
30
|
+
end
|
31
31
|
|
32
|
-
# test
|
33
|
-
p make_message(['joe@foo.com', 'jane@bar.net'], 'Hello World', 'Some body text.', true)
|
32
|
+
# test
|
33
|
+
p make_message(['joe@foo.com', 'jane@bar.net'], 'Hello World', 'Some body text.', true)
|