Module: Teapot::Commands

Defined in:
lib/teapot/commands.rb

Defined Under Namespace

Classes: CommandError, Pool

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.make(*args) ⇒ Object



65
66
67
# File 'lib/teapot/commands.rb', line 65

def self.make(*args)
	run("make", *args, "-j", processor_count)
end

.make_installObject



69
70
71
# File 'lib/teapot/commands.rb', line 69

def self.make_install
	make("install")
end

.pipeline(parallel = false) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/teapot/commands.rb', line 115

def self.pipeline(parallel = false)
	if parallel == false
		# Non-parallel execution pipeline
		Commands
	else
		# Pool based parallel execution pipeline
		Pool.new(parallel == true ? {} : parallel)
	end
end

.processor_countObject



28
29
30
31
32
33
34
# File 'lib/teapot/commands.rb', line 28

def self.processor_count
	# Get the number of virtual/physical processors
	count = Facter.processorcount.to_i rescue 1
	
	# Make sure we always return at least 1:
	count < 1 ? 1 : count
end

.run(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/teapot/commands.rb', line 43

def self.run(*args)
	args = args.flatten.collect &:to_s
	
	puts args.join(' ').color(:blue)
	
	if system(*args)
		true
	else
		raise CommandError.new("Non-zero exit status!")
	end
end

.run!(*args) ⇒ Object



55
56
57
58
59
# File 'lib/teapot/commands.rb', line 55

def self.run!(*args)
	run(*args)
rescue CommandError
	false
end

.split(arg) ⇒ Object



39
40
41
# File 'lib/teapot/commands.rb', line 39

def self.split(arg)
	Shellwords.split(arg || "")
end

Instance Method Details

#waitObject



61
62
63
# File 'lib/teapot/commands.rb', line 61

def wait
	# No parallel execution supported by default.
end