Class: PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/phusion_passenger/platform_info/depcheck.rb

Overview

class Dependency

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConsoleRunner

Returns a new instance of ConsoleRunner.



299
300
301
302
# File 'lib/phusion_passenger/platform_info/depcheck.rb', line 299

def initialize
	@stdout = STDOUT
	@dep_identifiers = []
end

Instance Attribute Details

#missing_dependenciesObject (readonly)

Returns the value of attribute missing_dependencies.



297
298
299
# File 'lib/phusion_passenger/platform_info/depcheck.rb', line 297

def missing_dependencies
  @missing_dependencies
end

Instance Method Details

#add(identifier) ⇒ Object



304
305
306
# File 'lib/phusion_passenger/platform_info/depcheck.rb', line 304

def add(identifier)
	@dep_identifiers << identifier
end

#check_allObject



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/phusion_passenger/platform_info/depcheck.rb', line 308

def check_all
	old_log_impl = PlatformInfo.log_implementation
	begin
		PlatformInfo.log_implementation = lambda do |message|
			message = PlatformInfo.send(:reindent, message, 10)
			message.sub!(/^          /, '')
			STDOUT.puts "       -> #{message}"
		end
		@missing_dependencies = []
		@dep_identifiers.each do |identifier|
			dep = Depcheck.find(identifier)
			raise "Cannot find depcheck spec #{identifier.inspect}" if !dep
			puts_header "Checking for #{dep.name}..."
			result = dep.check
			result = { :found => false } if !result

			if result[:found] && !result[:error]
				puts_detail "Found: <green>yes</green>"
			else
				if result[:error]
					puts_detail "Found: #{result[:found] ? "<yellow>yes, but there was an error</yellow>" : "<red>no</red>"}"
					puts_detail "Error: <red>#{result[:error]}</red>"
				else
					puts_detail "Found: #{result[:found] ? "<green>yes</green>" : "<red>no</red>"}"
				end
				@missing_dependencies << dep
			end

			result.each_pair do |key, value|
				if key.is_a?(String)
					puts_detail "#{key}: #{value}"
				end
			end
		end

		return @missing_dependencies.empty?
	ensure
		PlatformInfo.log_implementation = old_log_impl
	end
end


349
350
351
352
353
354
355
356
357
358
# File 'lib/phusion_passenger/platform_info/depcheck.rb', line 349

def print_installation_instructions_for_missing_dependencies
	@missing_dependencies.each do |dep|
		puts " * To install <yellow>#{dep.name}</yellow>:"
		puts "   #{dep.install_instructions}"
		if dep.install_comments
			puts "   #{dep.install_comments}"
		end
		puts
	end
end