Module: Peony::Shell

Defined in:
lib/peony/shell.rb,
lib/peony/shell/html.rb,
lib/peony/shell/basic.rb,
lib/peony/shell/color.rb

Defined Under Namespace

Classes: Basic, Color, HTML, Padding

Constant Summary collapse

SHELL_DELEGATED_METHODS =
[:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns,
:print_table, :print_wrapped, :file_collision, :terminal_width, :padding]

Instance Method Summary collapse

Instance Method Details

#shellObject

Holds the shell for the given Thor instance. If no shell is given, it gets a default shell from Thor::Base.shell.



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

def shell
  @shell ||= if ENV['PEONY_SHELL'] && ENV['PEONY_SHELL'].size > 0
    Peony::Shell.const_get(ENV['PEONY_SHELL']).new
  elsif (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) && !(ENV['ANSICON'])
    Peony::Shell::Basic.new
  else
    Peony::Shell::Color.new
  end
end

#with_paddingObject

Yields the given block with padding.



35
36
37
38
39
40
# File 'lib/peony/shell.rb', line 35

def with_padding
  self.padding.up
  yield
ensure
  self.padding.down
end