rb-appscript 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +28 -0
- data/README +51 -31
- data/doc/aem-manual/01_introduction.html +0 -2
- data/doc/aem-manual/02_apioverview.html +13 -9
- data/doc/aem-manual/03_packingandunpackingdata.html +41 -9
- data/doc/aem-manual/04_references.html +42 -40
- data/doc/aem-manual/{05_targettingapplications.html → 05_targetingapplications.html} +4 -6
- data/doc/aem-manual/06_buildingandsendingevents.html +40 -12
- data/doc/aem-manual/07_findapp.html +0 -2
- data/doc/aem-manual/08_examples.html +0 -2
- data/doc/aem-manual/aemreferenceinheritance.gif +0 -0
- data/doc/aem-manual/index.html +1 -3
- data/doc/appscript-manual/01_introduction.html +0 -2
- data/doc/appscript-manual/02_aboutappscripting.html +4 -6
- data/doc/appscript-manual/03_quicktutorial.html +1 -3
- data/doc/appscript-manual/04_gettinghelp.html +20 -7
- data/doc/appscript-manual/05_keywordconversion.html +5 -3
- data/doc/appscript-manual/06_classesandenums.html +32 -8
- data/doc/appscript-manual/07_applicationobjects.html +30 -41
- data/doc/appscript-manual/08_realvsgenericreferences.html +0 -2
- data/doc/appscript-manual/09_referenceforms.html +0 -2
- data/doc/appscript-manual/10_referenceexamples.html +1 -3
- data/doc/appscript-manual/11_applicationcommands.html +29 -2
- data/doc/appscript-manual/12_commandexamples.html +0 -2
- data/doc/appscript-manual/13_performanceissues.html +0 -2
- data/doc/appscript-manual/14_notes.html +0 -19
- data/doc/appscript-manual/index.html +0 -2
- data/doc/index.html +1 -4
- data/doc/mactypes-manual/01_introduction.html +0 -2
- data/doc/mactypes-manual/02_aliasclass.html +0 -10
- data/doc/mactypes-manual/03_fileurlclass.html +1 -11
- data/doc/mactypes-manual/04_unitsclass.html +0 -2
- data/doc/mactypes-manual/index.html +0 -2
- data/doc/osax-manual/01_introduction.html +0 -2
- data/doc/osax-manual/02_interface.html +0 -2
- data/doc/osax-manual/03_examples.html +0 -2
- data/doc/osax-manual/04_notes.html +6 -25
- data/doc/osax-manual/index.html +0 -2
- data/rb-appscript.gemspec +2 -3
- data/sample/AB_export_vcard.rb +0 -0
- data/sample/AB_list_people_with_emails.rb +0 -0
- data/sample/Create_daily_iCal_todos.rb +0 -0
- data/sample/Export_Address_Book_phone_numbers.rb +0 -0
- data/sample/Hello_world.rb +0 -0
- data/sample/List_iTunes_playlist_names.rb +0 -0
- data/sample/Open_file_in_TextEdit.rb +0 -0
- data/sample/Organize_Mail_messages.rb +0 -0
- data/sample/TextEdit_demo.rb +0 -0
- data/sample/iTunes_top40_to_html.rb +0 -0
- data/src/SendThreadSafe.c +0 -0
- data/src/SendThreadSafe.h +0 -0
- data/src/lib/_aem/aemreference.rb +5 -7
- data/src/lib/_aem/codecs.rb +47 -24
- data/src/lib/_aem/connect.rb +29 -8
- data/src/lib/_aem/encodingsupport.rb +77 -0
- data/src/lib/_aem/findapp.rb +0 -2
- data/src/lib/_aem/mactypes.rb +0 -2
- data/src/lib/_aem/send.rb +6 -8
- data/src/lib/_aem/typewrappers.rb +0 -2
- data/src/lib/_appscript/defaultterminology.rb +0 -2
- data/src/lib/_appscript/referencerenderer.rb +1 -3
- data/src/lib/_appscript/reservedkeywords.rb +0 -2
- data/src/lib/_appscript/safeobject.rb +58 -9
- data/src/lib/_appscript/terminology.rb +63 -46
- data/src/lib/aem.rb +3 -4
- data/src/lib/appscript.rb +12 -13
- data/src/lib/osax.rb +436 -9
- data/src/rbae.c +126 -103
- data/test/test_aemreference.rb +0 -0
- data/test/test_appscriptcommands.rb +15 -1
- data/test/test_appscriptreference.rb +0 -0
- data/test/test_codecs.rb +10 -4
- data/test/test_findapp.rb +0 -0
- data/test/test_mactypes.rb +0 -0
- data/test/test_osax.rb +0 -0
- data/test/testall.sh +0 -0
- metadata +24 -24
- data/LICENSE +0 -70
- data/TODO +0 -19
data/src/rbae.c
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
* ae -- a low-level API providing a basic Ruby wrapper around the various
|
5
5
|
* Apple Event Manager, Process Manager and Launch Services APIs used by aem
|
6
6
|
*
|
7
|
-
* Copyright (C) 2006-2009 HAS. Released under MIT License.
|
8
|
-
*
|
9
7
|
* Thanks to:
|
10
8
|
* - FUJIMOTO Hisakuni, author of RubyAEOSA
|
11
9
|
* - Jordan Breeding (64-bit support patch)
|
@@ -128,7 +126,7 @@ rbAE_wrapAEDesc(const AEDesc *desc)
|
|
128
126
|
|
129
127
|
/*******/
|
130
128
|
// Note: clients should not attempt to use retain/use borrowed AE::AEDesc instances after handler callbacks return,
|
131
|
-
// as AEM will have disposed of the underlying AEDesc objects by then
|
129
|
+
// as AEM will have disposed of the underlying AEDesc objects by then
|
132
130
|
|
133
131
|
static void
|
134
132
|
rbAE_freeBorrowedAEDesc(struct rbAE_AEDescWrapper *p)
|
@@ -177,20 +175,43 @@ rbAE_AEDesc_newList(VALUE class, VALUE isRecord)
|
|
177
175
|
|
178
176
|
|
179
177
|
static VALUE
|
180
|
-
rbAE_AEDesc_newAppleEvent(VALUE class, VALUE
|
181
|
-
VALUE
|
178
|
+
rbAE_AEDesc_newAppleEvent(VALUE class, VALUE eventClassValue, VALUE eventIDValue,
|
179
|
+
VALUE targetValue, VALUE returnIDValue, VALUE transactionIDValue)
|
182
180
|
{
|
183
181
|
OSErr err = noErr;
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
182
|
+
AEEventClass theAEEventClass = rbStringToDescType(eventClassValue);
|
183
|
+
AEEventID theAEEventID = rbStringToDescType(eventIDValue);
|
184
|
+
AEAddressDesc target = AEDESC_OF(targetValue);
|
185
|
+
AEReturnID returnID = NUM2INT(returnIDValue);
|
186
|
+
AETransactionID transactionID = NUM2LONG(transactionIDValue);
|
187
|
+
AppleEvent result;
|
188
|
+
|
189
|
+
err = AECreateAppleEvent(theAEEventClass,
|
190
|
+
theAEEventID,
|
191
|
+
&target,
|
192
|
+
returnID,
|
193
|
+
transactionID,
|
194
|
+
&result);
|
192
195
|
if (err != noErr) rbAE_raiseMacOSError("Can't create AppleEvent.", err);
|
193
|
-
return
|
196
|
+
// workaround for return ID bug in 10.6
|
197
|
+
AEDesc returnIDDesc;
|
198
|
+
if (returnID == kAutoGenerateReturnID) {
|
199
|
+
err = AEGetAttributeDesc(&result, keyReturnIDAttr, typeSInt32, &returnIDDesc);
|
200
|
+
if (err != noErr) rbAE_raiseMacOSError("Can't create AppleEvent.", err);
|
201
|
+
err = AEGetDescData(&returnIDDesc, &returnID, sizeof(returnID));
|
202
|
+
if (err != noErr) rbAE_raiseMacOSError("Can't create AppleEvent.", err);
|
203
|
+
if (returnID == -1) {
|
204
|
+
AEDisposeDesc(&result);
|
205
|
+
err = AECreateAppleEvent(theAEEventClass,
|
206
|
+
theAEEventID,
|
207
|
+
&target,
|
208
|
+
returnID,
|
209
|
+
transactionID,
|
210
|
+
&result);
|
211
|
+
if (err != noErr) rbAE_raiseMacOSError("Can't create AppleEvent.", err);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return rbAE_wrapAEDesc(&result);
|
194
215
|
}
|
195
216
|
|
196
217
|
|
@@ -358,7 +379,6 @@ rbAE_AEDesc_getItem(VALUE self, VALUE index, VALUE type)
|
|
358
379
|
AEKeyword key;
|
359
380
|
AEDesc desc;
|
360
381
|
|
361
|
-
// TO DO: this gives bus error if typeAEList and index = 0 (should be OSErr -1701); why?
|
362
382
|
err = AEGetNthDesc(&(AEDESC_OF(self)),
|
363
383
|
NUM2LONG(index),
|
364
384
|
rbStringToDescType(type),
|
@@ -520,41 +540,18 @@ static VALUE
|
|
520
540
|
rbAE_launchApplication(VALUE self, VALUE path, VALUE firstEvent, VALUE flags)
|
521
541
|
{
|
522
542
|
FSRef appRef;
|
523
|
-
#if !defined(__LP64__)
|
524
|
-
FSSpec appFSS;
|
525
|
-
#endif
|
526
|
-
AEDesc paraDesc;
|
527
|
-
Size paraSize;
|
528
|
-
AppParametersPtr paraData;
|
529
543
|
ProcessSerialNumber psn;
|
530
|
-
|
531
|
-
OSErr err = noErr;
|
544
|
+
OSStatus err = noErr;
|
532
545
|
|
533
546
|
err = FSPathMakeRef((UInt8 *)StringValuePtr(path), &appRef, NULL);
|
534
|
-
if (err !=
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
paraData = (AppParametersPtr)NewPtr(paraSize);
|
542
|
-
if (paraData == NULL) rbAE_raiseMacOSError("Can't make app parameters AEDesc.", memFullErr);
|
543
|
-
err = AEGetDescData(¶Desc, paraData, paraSize);
|
544
|
-
if (err != noErr) rbAE_raiseMacOSError("Can't get AEDesc data.", err);
|
545
|
-
launchParams.launchBlockID = extendedBlock;
|
546
|
-
launchParams.launchEPBLength = extendedBlockLen;
|
547
|
-
launchParams.launchFileFlags = 0;
|
548
|
-
launchParams.launchControlFlags = (LaunchFlags)NUM2UINT(flags);
|
549
|
-
#if defined(__LP64__)
|
550
|
-
launchParams.launchAppRef = &appRef;
|
551
|
-
#else
|
552
|
-
launchParams.launchAppSpec = &appFSS;
|
553
|
-
#endif
|
554
|
-
launchParams.launchAppParameters = paraData;
|
555
|
-
err = LaunchApplication(&launchParams);
|
547
|
+
if (err != noErr) rbAE_raiseMacOSError("Couldn't make FSRef for application.", err);
|
548
|
+
LSApplicationParameters appParams = {0,
|
549
|
+
(LSLaunchFlags)NUM2UINT(flags),
|
550
|
+
&appRef,
|
551
|
+
NULL, NULL, NULL,
|
552
|
+
&(AEDESC_OF(firstEvent))};
|
553
|
+
err = LSOpenApplication(&appParams, &psn);
|
556
554
|
if (err != noErr) rbAE_raiseMacOSError("Can't launch application.", err);
|
557
|
-
psn = launchParams.launchProcessSN;
|
558
555
|
return rb_ary_new3(2, INT2NUM(psn.highLongOfPSN), INT2NUM(psn.lowLongOfPSN));
|
559
556
|
}
|
560
557
|
|
@@ -615,6 +612,63 @@ rbAE_convertURLToPath(VALUE self, VALUE urlStr, VALUE pathStyle)
|
|
615
612
|
/**********************************************************************/
|
616
613
|
// Date conversion
|
617
614
|
|
615
|
+
static VALUE
|
616
|
+
rbAE_convertLongDateTimeToString(VALUE self, VALUE ldt)
|
617
|
+
{
|
618
|
+
Boolean bErr;
|
619
|
+
OSStatus err = 0;
|
620
|
+
CFAbsoluteTime cfTime;
|
621
|
+
CFDateFormatterRef formatter;
|
622
|
+
CFStringRef str;
|
623
|
+
char buffer[20]; // size of format string + nul
|
624
|
+
|
625
|
+
err = UCConvertLongDateTimeToCFAbsoluteTime(NUM2LL(ldt), &cfTime);
|
626
|
+
if (err != noErr) rbAE_raiseMacOSError("Can't convert LongDateTime to seconds.", err);
|
627
|
+
formatter = CFDateFormatterCreate(NULL, NULL, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
|
628
|
+
if (!formatter) rbAE_raiseMacOSError("Can't create date formatter.", err);
|
629
|
+
CFDateFormatterSetFormat(formatter, CFSTR("yyyy-MM-dd HH:mm:ss"));
|
630
|
+
str = CFDateFormatterCreateStringWithAbsoluteTime(NULL, formatter, cfTime);
|
631
|
+
CFRelease(formatter);
|
632
|
+
if (!str) rbAE_raiseMacOSError("Can't create date string.", err);
|
633
|
+
bErr = CFStringGetCString(str,
|
634
|
+
buffer,
|
635
|
+
sizeof(buffer),
|
636
|
+
kCFStringEncodingUTF8);
|
637
|
+
CFRelease(str);
|
638
|
+
if (!bErr) rb_raise(rb_eRuntimeError, "Can't convert date string.");
|
639
|
+
return rb_str_new2(buffer);
|
640
|
+
}
|
641
|
+
|
642
|
+
|
643
|
+
static VALUE
|
644
|
+
rbAE_convertStringToLongDateTime(VALUE self, VALUE datetime)
|
645
|
+
{
|
646
|
+
CFStringRef str;
|
647
|
+
CFAbsoluteTime cfTime;
|
648
|
+
CFDateFormatterRef formatter;
|
649
|
+
OSStatus err = 0;
|
650
|
+
Boolean bErr;
|
651
|
+
SInt64 ldt;
|
652
|
+
|
653
|
+
str = CFStringCreateWithBytes(NULL,
|
654
|
+
(UInt8 *)(RSTRING_PTR(datetime)),
|
655
|
+
(CFIndex)(RSTRING_LEN(datetime)),
|
656
|
+
kCFStringEncodingUTF8,
|
657
|
+
false);
|
658
|
+
if (str == NULL || CFStringGetLength(str) != 19) rb_raise(rb_eRuntimeError, "Bad datetime string.");
|
659
|
+
formatter = CFDateFormatterCreate(NULL, NULL, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
|
660
|
+
if (!formatter) rbAE_raiseMacOSError("Can't create date formatter.", err);
|
661
|
+
CFDateFormatterSetFormat(formatter, CFSTR("yyyy-MM-dd HH:mm:ss"));
|
662
|
+
bErr = CFDateFormatterGetAbsoluteTimeFromString(formatter, str, NULL, &cfTime);
|
663
|
+
CFRelease(formatter);
|
664
|
+
CFRelease(str);
|
665
|
+
if (!bErr) rb_raise(rb_eRuntimeError, "Can't convert date string.");
|
666
|
+
err = UCConvertCFAbsoluteTimeToLongDateTime(cfTime, &ldt);
|
667
|
+
if (err != noErr) rbAE_raiseMacOSError("Can't convert seconds to LongDateTime.", err);
|
668
|
+
return LL2NUM(ldt);
|
669
|
+
}
|
670
|
+
|
671
|
+
|
618
672
|
static VALUE
|
619
673
|
rbAE_convertLongDateTimeToUnixSeconds(VALUE self, VALUE ldt)
|
620
674
|
{
|
@@ -643,37 +697,31 @@ rbAE_convertUnixSecondsToLongDateTime(VALUE self, VALUE secs)
|
|
643
697
|
// Get aete
|
644
698
|
|
645
699
|
static VALUE
|
646
|
-
|
700
|
+
rbAE_OSACopyScriptingDefinition(VALUE self, VALUE path)
|
647
701
|
{
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
FSRef appRef;
|
654
|
-
FSSpec fss;
|
655
|
-
Boolean didLaunch;
|
656
|
-
AEDesc theDesc;
|
702
|
+
FSRef fsRef;
|
703
|
+
CFDataRef sdef;
|
704
|
+
CFIndex dataSize;
|
705
|
+
char *data;
|
706
|
+
VALUE res;
|
657
707
|
OSErr err = noErr;
|
658
708
|
|
659
|
-
err = FSPathMakeRef((UInt8 *)StringValuePtr(path), &
|
660
|
-
if (err != 0) rbAE_raiseMacOSError("Couldn't make FSRef.", err);
|
661
|
-
err =
|
662
|
-
if (err
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
709
|
+
err = FSPathMakeRef((UInt8 *)StringValuePtr(path), &fsRef, NULL);
|
710
|
+
if (err != 0) rbAE_raiseMacOSError("Couldn't make FSRef for path.", err);
|
711
|
+
err = OSACopyScriptingDefinition(&fsRef, 0, &sdef);
|
712
|
+
if (err) rbAE_raiseMacOSError("Couldn't get sdef.", err);
|
713
|
+
dataSize = CFDataGetLength(sdef);
|
714
|
+
data = (char *)CFDataGetBytePtr(sdef);
|
715
|
+
if (data != NULL) {
|
716
|
+
res = rb_str_new(data, dataSize);
|
717
|
+
} else {
|
718
|
+
data = malloc(dataSize);
|
719
|
+
CFDataGetBytes(sdef, CFRangeMake(0, dataSize), (UInt8 *)data);
|
720
|
+
res = rb_str_new(data, dataSize);
|
721
|
+
free(data);
|
667
722
|
}
|
668
|
-
|
669
|
-
|
670
|
-
&fss,
|
671
|
-
0,
|
672
|
-
&didLaunch,
|
673
|
-
&theDesc);
|
674
|
-
if (err != 0) rbAE_raiseMacOSError("Couldn't get aete resource.", err);
|
675
|
-
return rbAE_wrapAEDesc(&theDesc);
|
676
|
-
#endif
|
723
|
+
CFRelease(sdef);
|
724
|
+
return res;
|
677
725
|
}
|
678
726
|
|
679
727
|
|
@@ -682,8 +730,6 @@ rbAE_OSAGetAppTerminology(VALUE self, VALUE path)
|
|
682
730
|
|
683
731
|
// Based on Python's CarbonX.AE extension
|
684
732
|
|
685
|
-
// TO DO: make sure GC won't collect handler objects while they're installed as event/coercion handlers
|
686
|
-
|
687
733
|
static pascal OSErr
|
688
734
|
rbAE_GenericEventHandler(const AppleEvent *request, AppleEvent *reply, SRefCon refcon)
|
689
735
|
{
|
@@ -754,8 +800,6 @@ rbAE_AEGetEventHandler(VALUE self, VALUE eventClass, VALUE eventID)
|
|
754
800
|
/**********************************************************************/
|
755
801
|
// Install coercion handlers
|
756
802
|
|
757
|
-
// TO DO: make sure GC won't collect handler objects while they're installed as event/coercion handlers
|
758
|
-
|
759
803
|
static pascal OSErr
|
760
804
|
rbAE_GenericCoercionHandler(const AEDesc *fromDesc, DescType toType, SRefCon refcon, AEDesc *toDesc)
|
761
805
|
{
|
@@ -835,29 +879,6 @@ rbAE_AEGetCoercionHandler(VALUE self, VALUE fromType, VALUE toType)
|
|
835
879
|
|
836
880
|
/**********************************************************************/
|
837
881
|
// Process management
|
838
|
-
|
839
|
-
static VALUE
|
840
|
-
rbAE_RunApplicationEventLoop(VALUE self)
|
841
|
-
{
|
842
|
-
#if defined(__LP64__)
|
843
|
-
rb_raise(rb_eNotImpError, "AE.run_application_event_loop isn't available in 64-bit processes.\n");
|
844
|
-
#else
|
845
|
-
RunApplicationEventLoop();
|
846
|
-
#endif
|
847
|
-
return Qnil;
|
848
|
-
}
|
849
|
-
|
850
|
-
static VALUE
|
851
|
-
rbAE_QuitApplicationEventLoop(VALUE self)
|
852
|
-
{
|
853
|
-
#if defined(__LP64__)
|
854
|
-
rb_raise(rb_eNotImpError, "AE.quit_application_event_loop isn't available in 64-bit processes.\n");
|
855
|
-
#else
|
856
|
-
QuitApplicationEventLoop();
|
857
|
-
#endif
|
858
|
-
return Qnil;
|
859
|
-
}
|
860
|
-
|
861
882
|
static VALUE
|
862
883
|
rbAE_transformProcessToForegroundApplication(VALUE self)
|
863
884
|
{
|
@@ -929,12 +950,16 @@ Init_ae (void)
|
|
929
950
|
rb_define_module_function(mAE, "convert_url_to_path",
|
930
951
|
rbAE_convertURLToPath, 2);
|
931
952
|
|
953
|
+
rb_define_module_function(mAE, "convert_long_date_time_to_string",
|
954
|
+
rbAE_convertLongDateTimeToString, 1);
|
955
|
+
rb_define_module_function(mAE, "convert_string_to_long_date_time",
|
956
|
+
rbAE_convertStringToLongDateTime, 1);
|
932
957
|
rb_define_module_function(mAE, "convert_long_date_time_to_unix_seconds",
|
933
958
|
rbAE_convertLongDateTimeToUnixSeconds, 1);
|
934
959
|
rb_define_module_function(mAE, "convert_unix_seconds_to_long_date_time",
|
935
960
|
rbAE_convertUnixSecondsToLongDateTime, 1);
|
936
961
|
|
937
|
-
rb_define_module_function(mAE, "
|
962
|
+
rb_define_module_function(mAE, "copy_scripting_definition", rbAE_OSACopyScriptingDefinition, 1);
|
938
963
|
|
939
964
|
// Event handling
|
940
965
|
|
@@ -949,8 +974,6 @@ Init_ae (void)
|
|
949
974
|
rb_define_module_function(mAE, "remove_coercion_handler", rbAE_AERemoveCoercionHandler, 2);
|
950
975
|
rb_define_module_function(mAE, "get_coercion_handler", rbAE_AEGetCoercionHandler, 2);
|
951
976
|
|
952
|
-
rb_define_module_function(mAE, "run_application_event_loop", rbAE_RunApplicationEventLoop, 0);
|
953
|
-
rb_define_module_function(mAE, "quit_application_event_loop", rbAE_QuitApplicationEventLoop, 0);
|
954
977
|
rb_define_module_function(mAE, "transform_process_to_foreground_application",
|
955
978
|
rbAE_transformProcessToForegroundApplication, 0);
|
956
979
|
}
|
data/test/test_aemreference.rb
CHANGED
File without changes
|
@@ -86,6 +86,20 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
86
86
|
d.text.get(:ignore=>[:diacriticals, :punctuation, :whitespace, :expansion], :timeout=>10))
|
87
87
|
assert_nil(d.get(:wait_reply=>false))
|
88
88
|
|
89
|
+
|
90
|
+
# test Ruby 1.9+ String Encoding support
|
91
|
+
version, sub_version = RUBY_VERSION.split('.').collect {|n| n.to_i} [0, 2]
|
92
|
+
if version >= 1 and sub_version >= 9
|
93
|
+
|
94
|
+
print "(check Encoding support)"
|
95
|
+
s = "\302\251 M. Lef\303\250vre"
|
96
|
+
s.force_encoding('utf-8')
|
97
|
+
d.text.set(s)
|
98
|
+
assert_equal(s, d.text.get)
|
99
|
+
|
100
|
+
@te.AS_app_data.use_ascii_8bit
|
101
|
+
end
|
102
|
+
|
89
103
|
d.text.set("\302\251 M. Lef\303\250vre")
|
90
104
|
assert_equal("\302\251 M. Lef\303\250vre", d.text.get)
|
91
105
|
|
@@ -131,7 +145,7 @@ class TC_AppscriptCommands < Test::Unit::TestCase
|
|
131
145
|
rescue Appscript::CommandError => e
|
132
146
|
assert_equal(-1728, e.to_i)
|
133
147
|
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)
|
134
|
-
assert_instance_of(AEM::
|
148
|
+
assert_instance_of(AEM::EventError, e.real_error)
|
135
149
|
end
|
136
150
|
end
|
137
151
|
end
|
File without changes
|
data/test/test_codecs.rb
CHANGED
@@ -89,14 +89,20 @@ class TC_Codecs < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_str
|
92
|
+
s = "\xc6\x92\xe2\x88\x82\xc2\xae\xd4\xb7\xd5\x96\xd4\xb9\xe0\xa8\x89\xe3\x82\xa2\xe3\x84\xbb"
|
93
|
+
# test Ruby 1.9+ String Encoding support
|
94
|
+
version, sub_version = RUBY_VERSION.split('.').collect {|n| n.to_i} [0, 2]
|
95
|
+
if version >= 1 and sub_version >= 9
|
96
|
+
s.force_encoding('utf-8')
|
97
|
+
end
|
98
|
+
|
92
99
|
[
|
93
100
|
# note: aem has to pack UTF8 data as typeUnicodeText (UTF16) as stupid apps expect that type and will error on typeUTF8Text instead of just asking AEM to coerce it to the desired type in advance.
|
94
101
|
# note: UTF16 BOM must be omitted when packing UTF16 data into typeUnicodeText AEDescs, as a BOM will upset stupid apps like iTunes 7 that don't recognise it as a BOM and treat it as character data instead
|
95
102
|
['', ''],
|
96
103
|
['hello', "\000h\000e\000l\000l\000o"],
|
97
|
-
["\
|
98
|
-
|
99
|
-
].each do |val, data, type|
|
104
|
+
[s, "\x01\x92\"\x02\x00\xae\x057\x05V\x059\n\t0\xa21;"],
|
105
|
+
].each do |val, data|
|
100
106
|
data = ut16(data)
|
101
107
|
d = @c.pack(val)
|
102
108
|
assert_equal(KAE::TypeUnicodeText, d.type)
|
@@ -153,7 +159,7 @@ class TC_Codecs < Test::Unit::TestCase
|
|
153
159
|
end
|
154
160
|
|
155
161
|
def test_hash
|
156
|
-
val = {'foo' => 1, AEM::AEType.new('foob') => 2, AEM::AEProp.new('barr') => 3}
|
162
|
+
val = {'foo' => 1, AEM::AEType.new('foob') => 2, AEM::AEProp.new('barr') => 3}
|
157
163
|
expected_val = {'foo' => 1, AEM::AEType.new('foob') => 2, AEM::AEType.new('barr') => 3} # note that four-char-code keys are always unpacked as AEType
|
158
164
|
d = @c.pack(val)
|
159
165
|
assert_equal(expected_val, @c.unpack(d))
|
data/test/test_findapp.rb
CHANGED
File without changes
|
data/test/test_mactypes.rb
CHANGED
File without changes
|
data/test/test_osax.rb
CHANGED
File without changes
|
data/test/testall.sh
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-appscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
5
10
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
|
11
|
+
authors: []
|
12
|
+
|
8
13
|
autorequire:
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2011-02-07 00:00:00 +00:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -23,19 +28,16 @@ extra_rdoc_files: []
|
|
23
28
|
|
24
29
|
files:
|
25
30
|
- CHANGES
|
26
|
-
- doc
|
27
|
-
- doc/aem-manual
|
28
31
|
- doc/aem-manual/01_introduction.html
|
29
32
|
- doc/aem-manual/02_apioverview.html
|
30
33
|
- doc/aem-manual/03_packingandunpackingdata.html
|
31
34
|
- doc/aem-manual/04_references.html
|
32
|
-
- doc/aem-manual/
|
35
|
+
- doc/aem-manual/05_targetingapplications.html
|
33
36
|
- doc/aem-manual/06_buildingandsendingevents.html
|
34
37
|
- doc/aem-manual/07_findapp.html
|
35
38
|
- doc/aem-manual/08_examples.html
|
36
39
|
- doc/aem-manual/aemreferenceinheritance.gif
|
37
40
|
- doc/aem-manual/index.html
|
38
|
-
- doc/appscript-manual
|
39
41
|
- doc/appscript-manual/01_introduction.html
|
40
42
|
- doc/appscript-manual/02_aboutappscripting.html
|
41
43
|
- doc/appscript-manual/03_quicktutorial.html
|
@@ -58,13 +60,11 @@ files:
|
|
58
60
|
- doc/appscript-manual/ruby_to_itunes_event.gif
|
59
61
|
- doc/full.css
|
60
62
|
- doc/index.html
|
61
|
-
- doc/mactypes-manual
|
62
63
|
- doc/mactypes-manual/01_introduction.html
|
63
64
|
- doc/mactypes-manual/02_aliasclass.html
|
64
65
|
- doc/mactypes-manual/03_fileurlclass.html
|
65
66
|
- doc/mactypes-manual/04_unitsclass.html
|
66
67
|
- doc/mactypes-manual/index.html
|
67
|
-
- doc/osax-manual
|
68
68
|
- doc/osax-manual/01_introduction.html
|
69
69
|
- doc/osax-manual/02_interface.html
|
70
70
|
- doc/osax-manual/03_examples.html
|
@@ -72,10 +72,8 @@ files:
|
|
72
72
|
- doc/osax-manual/index.html
|
73
73
|
- doc/rb-appscript-logo.png
|
74
74
|
- extconf.rb
|
75
|
-
- LICENSE
|
76
75
|
- rb-appscript.gemspec
|
77
76
|
- README
|
78
|
-
- sample
|
79
77
|
- sample/AB_export_vcard.rb
|
80
78
|
- sample/AB_list_people_with_emails.rb
|
81
79
|
- sample/Add_iCal_event.rb
|
@@ -93,17 +91,14 @@ files:
|
|
93
91
|
- sample/Simple_Finder_GUI_Scripting.rb
|
94
92
|
- sample/Stagger_Finder_windows.rb
|
95
93
|
- sample/TextEdit_demo.rb
|
96
|
-
- src
|
97
|
-
- src/lib
|
98
|
-
- src/lib/_aem
|
99
94
|
- src/lib/_aem/aemreference.rb
|
100
95
|
- src/lib/_aem/codecs.rb
|
101
96
|
- src/lib/_aem/connect.rb
|
97
|
+
- src/lib/_aem/encodingsupport.rb
|
102
98
|
- src/lib/_aem/findapp.rb
|
103
99
|
- src/lib/_aem/mactypes.rb
|
104
100
|
- src/lib/_aem/send.rb
|
105
101
|
- src/lib/_aem/typewrappers.rb
|
106
|
-
- src/lib/_appscript
|
107
102
|
- src/lib/_appscript/defaultterminology.rb
|
108
103
|
- src/lib/_appscript/referencerenderer.rb
|
109
104
|
- src/lib/_appscript/reservedkeywords.rb
|
@@ -116,7 +111,6 @@ files:
|
|
116
111
|
- src/rbae.c
|
117
112
|
- src/SendThreadSafe.c
|
118
113
|
- src/SendThreadSafe.h
|
119
|
-
- test
|
120
114
|
- test/README
|
121
115
|
- test/test_aemreference.rb
|
122
116
|
- test/test_appscriptcommands.rb
|
@@ -126,32 +120,38 @@ files:
|
|
126
120
|
- test/test_mactypes.rb
|
127
121
|
- test/test_osax.rb
|
128
122
|
- test/testall.sh
|
129
|
-
|
130
|
-
|
131
|
-
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: http://appscript.sourceforge.net/
|
125
|
+
licenses: []
|
126
|
+
|
132
127
|
post_install_message:
|
133
128
|
rdoc_options: []
|
134
129
|
|
135
130
|
require_paths:
|
136
131
|
- lib
|
137
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
138
134
|
requirements:
|
139
135
|
- - ">="
|
140
136
|
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 1
|
139
|
+
- 8
|
141
140
|
version: "1.8"
|
142
|
-
version:
|
143
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
144
143
|
requirements:
|
145
144
|
- - ">="
|
146
145
|
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 0
|
147
148
|
version: "0"
|
148
|
-
version:
|
149
149
|
requirements: []
|
150
150
|
|
151
151
|
rubyforge_project: rb-appscript
|
152
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.3.7
|
153
153
|
signing_key:
|
154
|
-
specification_version:
|
154
|
+
specification_version: 3
|
155
155
|
summary: Ruby appscript (rb-appscript) is a high-level, user-friendly Apple event bridge that allows you to control scriptable Mac OS X applications using ordinary Ruby scripts.
|
156
156
|
test_files:
|
157
157
|
- test/test_aemreference.rb
|