Class: ShellContext

Inherits:
Object
  • Object
show all
Defined in:
lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb

Direct Known Subclasses

ShellBuffer, ShellDebugger, ShellExec

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.currentObject



5
6
7
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 5

def self.current()
	@current
end

.during_shell_context(new_shell_context, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 13

def self.during_shell_context(new_shell_context, &block)
	current_shell_context = @current

	@current = new_shell_context

	block.call

	@current = current_shell_context
end

.remindersObject



23
24
25
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 23

def self.reminders()
	@reminders
end

.set_current(shell_context) ⇒ Object



9
10
11
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 9

def self.set_current(shell_context)
	@current = shell_context
end

.show_info(text) ⇒ Object



27
28
29
30
31
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 27

def self.show_info(text)
	puts '-----------------------------------------------'.red
	puts text.green
	puts '-----------------------------------------------'.red
end

Instance Method Details

#execute(task_name, *args) ⇒ Object



47
48
49
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 47

def execute(task_name, *args)
	raise 'Subclass responsibility'
end

#invoke(task_name, *args) ⇒ Object



43
44
45
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 43

def invoke(task_name, *args)
	raise 'Subclass responsibility'
end

#raise_validation_error(message) ⇒ Object



55
56
57
58
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 55

def raise_validation_error(message)
	show_info(message)
	exit
end

#remind_to(text) ⇒ Object



51
52
53
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 51

def remind_to(text)
	ShellContext.reminders << text
end

#shell(command) ⇒ Object

Instance methods



35
36
37
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 35

def shell(command)
	raise 'Subclass responsibility'
end

#shell!(command) ⇒ Object



39
40
41
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 39

def shell!(command)
	raise 'Subclass responsibility'
end

#show_info(text) ⇒ Object



60
61
62
# File 'lib/cabeza-de-termo/cachivache-helpers/utilities/shell-contexts/shell-context.rb', line 60

def show_info(text)
	ShellContext.show_info(text)
end