Class: Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/core/shell.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.tmp_stderrObject (readonly)

Returns the value of attribute tmp_stderr.



5
6
7
# File 'lib/core/shell.rb', line 5

def tmp_stderr
  @tmp_stderr
end

Class Method Details

.abort(message) ⇒ Object



50
51
52
# File 'lib/core/shell.rb', line 50

def self.abort(message)
  Kernel.abort(color("ERROR: #{message}", :red))
end

.color(message, color_key) ⇒ Object



34
35
36
# File 'lib/core/shell.rb', line 34

def self.color(message, color_key)
  shell.set_color(message, color_key)
end

.confirm(message) ⇒ Object



38
39
40
# File 'lib/core/shell.rb', line 38

def self.confirm(message)
  shell.yes?("#{message} (y/n)")
end

.read_from_tmp_stderrObject



29
30
31
32
# File 'lib/core/shell.rb', line 29

def self.read_from_tmp_stderr
  tmp_stderr.rewind
  tmp_stderr.read.strip
end

.shellObject



8
9
10
# File 'lib/core/shell.rb', line 8

def self.shell
  @shell ||= Thor::Shell::Color.new
end

.stderrObject



12
13
14
# File 'lib/core/shell.rb', line 12

def self.stderr
  @stderr ||= $stderr
end

.use_tmp_stderrObject



16
17
18
19
20
21
22
23
# File 'lib/core/shell.rb', line 16

def self.use_tmp_stderr
  @tmp_stderr = Tempfile.create

  yield

  @tmp_stderr.close
  @tmp_stderr = nil
end

.warn(message) ⇒ Object



42
43
44
# File 'lib/core/shell.rb', line 42

def self.warn(message)
  stderr.puts(color("WARNING: #{message}", :yellow))
end

.warn_deprecated(message) ⇒ Object



46
47
48
# File 'lib/core/shell.rb', line 46

def self.warn_deprecated(message)
  stderr.puts(color("DEPRECATED: #{message}", :yellow))
end

.write_to_tmp_stderr(message) ⇒ Object



25
26
27
# File 'lib/core/shell.rb', line 25

def self.write_to_tmp_stderr(message)
  tmp_stderr.write(message)
end