Sha256: fa0e1f31567788eecc6022542df22f78a4c475e5224fb4a3bfb6e0f98a272fe6

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

require 'rush/shell'

module Rush
	# This is a class that can be embedded in other applications 
	# rake tasks, utility scripts, etc
	# 
	# Delegates unknown method calls to a Rush::Shell instance
	class EmbeddableShell
		attr_accessor :shell
		def initialize(suppress_output = true)
			self.shell = Rush::Shell.new
			shell.suppress_output = suppress_output
		end
		
		# evalutes any unkown method call against the rush shell
		def method_missing(sym, *args, &block)
			shell.execute sym.to_s
			$last_res
		end
		
		# take a whole block and execute it as if it were inside a shell
		def execute_in_shell(&block)
			self.instance_eval(&block)
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aleksi-rush-0.6.7 lib/rush/embeddable_shell.rb
aleksi-rush-0.6.6 lib/rush/embeddable_shell.rb