/
RunRubyScriptAction.m
47 lines (33 loc) · 1.01 KB
/
RunRubyScriptAction.m
1
2
3
4
5
6
7
8
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
//
// RubyScriptAction.m
// RubyScriptAction
//
// Created by Jason Foreman on 12/16/07.
// Copyright 2007 Jason Foreman. All rights reserved.
//
#import "RunRubyScriptAction.h"
void __attribute__((constructor)) loadRubyScriptAction(void)
{
NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init];
[[[RubyScriptActionLoader alloc] init] autorelease];
[thePool release];
}
@implementation RubyScriptActionLoader
+ (void) load;
{
RBBundleInit("RunRubyScriptAction.rb", self, nil);
}
@end
@implementation LSWrapper
+ (NSString*)bundleIdentifierForApplicationWithName:(NSString*)name;
{
NSString *fullname = [name stringByAppendingPathExtension:@"app"];
CFURLRef appURL;
OSErr err = LSFindApplicationForInfo(kLSUnknownCreator, nil, (CFStringRef)fullname, NULL, &appURL);
NSString *path = (NSString*)CFURLCopyFileSystemPath(appURL, kCFURLPOSIXPathStyle);
[(NSURL*)appURL release];
[path autorelease];
NSBundle *bundle = [NSBundle bundleWithPath:path];
return [bundle bundleIdentifier];
}
@end