Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions ObjectGraph/ObjectGraph.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ @interface ObjectGraph()
@property (nonatomic, strong) NSMenuItem *pathItem;
@property (nonatomic, copy) NSString *sourceCodePath;
@property (nonatomic, copy) TaskBlock getGraphvizExecutablePathBlock;
@property (nonatomic, copy) TaskBlock convertToPNGBlock;
@property (nonatomic, copy) TaskBlock movePNGFileBlock;
@property (nonatomic, copy) TaskBlock convertToPDFBlock;
@property (nonatomic, copy) TaskBlock movePDFFileBlock;
@property (nonatomic, copy) TaskBlock moveDOTFileBlock;
@property (nonatomic, copy) TaskBlock openBlock;

Expand Down Expand Up @@ -86,8 +86,8 @@ - (id)initWithBundle:(NSBundle *)plugin
[self setDefaultSourceCodePathPath];

[self setupGetGraphvizExecutablePathBlock];
[self setupConvertToPNGBlock];
[self setupMovePNGFileBlock];
[self setupConvertToPDFBlock];
[self setupMovePDFFileBlock];
[self setupMoveDOTFileBlock];
[self setupOpenBlock];

Expand Down Expand Up @@ -164,15 +164,15 @@ - (void)selectPath
- (NSString *)dotFileName
{
VWKProject *project = [VWKProject projectForKeyWindow];
NSString *dotFileName = [project.projectName stringByAppendingString:@".dot"];
NSString *dotFileName = [project.projectName stringByAppendingPathExtension:@"dot"];
return dotFileName;
}

- (NSString *)pngFileName
- (NSString *)pdfFileName
{
VWKProject *project = [VWKProject projectForKeyWindow];
NSString *pngFileName = [project.projectName stringByAppendingString:@".png"];
return pngFileName;
NSString *pdfFileName = [project.projectName stringByAppendingPathExtension:@"pdf"];
return pdfFileName;
}

- (NSString *)projectPath
Expand Down Expand Up @@ -206,36 +206,36 @@ - (void)setupGetGraphvizExecutablePathBlock
[VWKShellHandler runShellCommand:shellString
withArgs:args
directory:strongSelf.sourceCodePath
completion:strongSelf.convertToPNGBlock];
completion:strongSelf.convertToPDFBlock];
};
}

- (void)setupConvertToPNGBlock
- (void)setupConvertToPDFBlock
{
__weak __typeof(&*self)weakSelf = self;
self.convertToPNGBlock = ^(NSTask *t,
self.convertToPDFBlock = ^(NSTask *t,
NSString *standardOutputString,
NSString *standardErrorString){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
if (standardOutputString.length > 0) {
NSString *GRAPHVIZ_EXECUTABLE_PATH = [standardOutputString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[VWKShellHandler runShellCommand:GRAPHVIZ_EXECUTABLE_PATH
withArgs:@[@"-Tpng", strongSelf.dotFileName, @"-o", strongSelf.pngFileName]
withArgs:@[@"-Tpdf", strongSelf.dotFileName, @"-o", strongSelf.pdfFileName]
directory:strongSelf.sourceCodePath
completion:strongSelf.movePNGFileBlock];
completion:strongSelf.movePDFFileBlock];
}
};
}

- (void)setupMovePNGFileBlock
- (void)setupMovePDFFileBlock
{
__weak __typeof(&*self)weakSelf = self;
self.movePNGFileBlock = ^(NSTask *t,
self.movePDFFileBlock = ^(NSTask *t,
NSString *standardOutputString,
NSString *standardErrorString){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[VWKShellHandler runShellCommand:[BIN_PATH stringByAppendingPathComponent:MOVE_EXECUTABLE]
withArgs:@[strongSelf.pngFileName, strongSelf.projectPath]
withArgs:@[strongSelf.pdfFileName, strongSelf.projectPath]
directory:strongSelf.sourceCodePath
completion:strongSelf.moveDOTFileBlock];
};
Expand Down Expand Up @@ -263,7 +263,7 @@ - (void)setupOpenBlock
NSString *standardErrorString){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[VWKShellHandler runShellCommand:[USER_BIN_PATH stringByAppendingPathComponent:OPEN_EXECUTABLE]
withArgs:@[strongSelf.pngFileName]
withArgs:@[strongSelf.pdfFileName]
directory:strongSelf.projectPath
completion:nil];
};
Expand Down