Permalink
Browse files

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

  • Loading branch information...
1 parent 34afd48 commit 7c89e0c2b593bc41089dfb3d8258f0edd8f65011 @Manfred Manfred committed Mar 11, 2011
Showing with 19 additions and 0 deletions.
  1. +1 −0 app/utils/CLI.h
  2. +11 −0 app/utils/CLI.m
  3. +5 −0 test/passenger_pane/cli_test.nu
  4. +2 −0 test/passenger_pane/fake_ppane/ppane
View
@@ -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
@@ -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;
@@ -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
@@ -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

0 comments on commit 7c89e0c

Please sign in to comment.