Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a method to CLI that checks if the Passenger module is installed.

  • Loading branch information...
commit 7c89e0c2b593bc41089dfb3d8258f0edd8f65011 1 parent 34afd48
@Manfred Manfred authored
View
1  app/utils/CLI.h
@@ -23,6 +23,7 @@ enum {
- (void) update:(Application *)application;
- (void) restart:(Application *)application;
- (void) restart;
+- (BOOL) isPassengerModuleInstalled;
- (id) execute:(NSArray *)arguments elevated:(BOOL)elevated;
- (id) execute:(NSArray *)arguments;
View
11 app/utils/CLI.m
@@ -74,6 +74,17 @@ - (void) restart {
[self execute:[NSArray arrayWithObject:@"restart"] elevated:YES];
}
+- (BOOL) isPassengerModuleInstalled {
+ NSDictionary *info = [self execute:[NSArray arrayWithObject:@"info"]];
+ if (info) {
+ NSNumber *isInstalled = [info objectForKey:@"passenger_module_installed"];
+ return [isInstalled boolValue];
+ } else {
+ NSLog(@"Failed to read info, assuming Passenger module isn't installed.");
+ return NO;
+ }
+}
+
// Inspired by: http://svn.kismac-ng.org/kmng/trunk/Subprojects/BIGeneric/BLAuthentication.m
- (id) execute:(NSArray *)arguments elevated:(BOOL)elevated {
OSStatus status;
View
5 test/passenger_pane/cli_test.nu
@@ -34,6 +34,11 @@
(set arguments (NSString stringWithContentsOfFile:pathToCLIArguments encoding:NSUTF8StringEncoding error:nil))
(~ arguments should equal:"[\"restart\", \"manager.boom.local\"]")
))
+
+ (it "knows whether the Passenger module is installed" (do ()
+ (set installed (@cli isPassengerModuleInstalled))
+ (~ installed should equal:false)
+ ))
))
(describe "CLI, when authorized" `(do
View
2  test/passenger_pane/fake_ppane/ppane
@@ -16,4 +16,6 @@ elsif %w(add update delete restart).include?(command)
file.write(ARGV.inspect)
end
FileUtils.chown_R(trust(ENV['USER']), nil, trust(tmpdir))
+elsif command == 'info'
+ puts '{"passenger_module_installed":false,"passenger_pane_configured":true}'
end
Please sign in to comment.
Something went wrong with that request. Please try again.