Module: PgVerify::Shell

Defined in:
lib/pg-verify/shell/shell.rb,
lib/pg-verify/shell/loading/no_animation.rb,
lib/pg-verify/shell/loading/line_animation.rb,
lib/pg-verify/shell/loading/loading_prompt.rb,
lib/pg-verify/shell/loading/loading_animation.rb

Defined Under Namespace

Modules: LoadingPrompt Classes: LineAnimation, LoadingAnimation, NoAnimation

Class Method Summary collapse

Class Method Details

.expand_to_console(left, right) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/pg-verify/shell/shell.rb', line 21

def self.expand_to_console(left, right)
    return "#{left}    (#{right})" unless Settings.allow_right_print
    return "#{left}    (#{right})" unless Shell.in_tty?
    width = IO.console.nil? ? 4 : IO.console.winsize[1]
    space = " " * [(width -(Colorizer.uncolorize(left).length + Colorizer.uncolorize(right).length)), 1].max
    return left + space.c_sidenote + right
end

.gen_prompt(level) ⇒ Object



16
17
18
19
# File 'lib/pg-verify/shell/shell.rb', line 16

def self.gen_prompt(level)
    prompt = Settings.prompt.prompt_format % Settings.prompt[level]
    prompt.color(level)
end

.in_pipe?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/pg-verify/shell/shell.rb', line 8

def self.in_pipe?()
    !in_tty?()
end

.in_tty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/pg-verify/shell/shell.rb', line 12

def self.in_tty?()
    $stdout.isatty
end