Class: Shell
- Inherits:
-
Object
- Object
- Shell
- Defined in:
- lib/core/shell.rb
Class Attribute Summary collapse
-
.tmp_stderr ⇒ Object
readonly
Returns the value of attribute tmp_stderr.
Class Method Summary collapse
- .abort(message) ⇒ Object
- .color(message, color_key) ⇒ Object
- .confirm(message) ⇒ Object
- .read_from_tmp_stderr ⇒ Object
- .shell ⇒ Object
- .stderr ⇒ Object
- .use_tmp_stderr ⇒ Object
- .warn(message) ⇒ Object
- .warn_deprecated(message) ⇒ Object
- .write_to_tmp_stderr(message) ⇒ Object
Class Attribute Details
.tmp_stderr ⇒ Object (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() 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(, color_key) shell.set_color(, color_key) end |
.confirm(message) ⇒ Object
38 39 40 |
# File 'lib/core/shell.rb', line 38 def self.confirm() shell.yes?("#{message} (y/n)") end |
.read_from_tmp_stderr ⇒ Object
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 |
.shell ⇒ Object
8 9 10 |
# File 'lib/core/shell.rb', line 8 def self.shell @shell ||= Thor::Shell::Color.new end |
.stderr ⇒ Object
12 13 14 |
# File 'lib/core/shell.rb', line 12 def self.stderr @stderr ||= $stderr end |
.use_tmp_stderr ⇒ Object
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() 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() 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() tmp_stderr.write() end |