Class: Machinery::Ui
- Inherits:
-
Object
show all
- Defined in:
- lib/ui.rb,
lib/hint.rb,
lib/renderer.rb,
lib/diff_widget.rb
Defined Under Namespace
Classes: DiffWidget, Hint, Renderer
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
Returns the value of attribute use_pager.
21
22
23
|
# File 'lib/ui.rb', line 21
def
@use_pager
end
|
Class Method Details
43
44
45
|
# File 'lib/ui.rb', line 43
def
@pager.close if @pager
end
|
101
102
103
|
# File 'lib/ui.rb', line 101
def error(s)
STDERR.puts s
end
|
.internal_scope_list_to_string(scopes) ⇒ Object
23
24
25
26
|
# File 'lib/ui.rb', line 23
def internal_scope_list_to_string(scopes)
list = Array(scopes)
list.map { |e| e.tr("_", "-") }.join(", ")
end
|
47
48
49
|
# File 'lib/ui.rb', line 47
def
Process.kill("TERM", @pager_pid) if @pager_pid
end
|
.print(output) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/ui.rb', line 51
def print(output)
reset_line if progress_visible?
if ! || !$stdout.tty?
begin
STDOUT.print output
rescue Errno::EPIPE
end
else
if !ENV['PAGER'] || ENV['PAGER'] == ''
ENV['PAGER'] = 'less'
ENV['LESS'] = 'FSRX'
begin
LocalSystem.validate_existence_of_package("less")
(output)
rescue Machinery::Errors::MissingRequirement
STDOUT.print output
end
else
IO.popen("$PAGER &>/dev/null", "w") { |f| f.close }
if $?.success?
(output)
else
raise(Machinery::Errors::InvalidPager.new("'#{ENV['PAGER']}' could not " \
"be executed. Use the --no-pager option or modify your $PAGER " \
"bash environment variable to display output.")
)
end
end
end
end
|
.progress(output) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/ui.rb', line 84
def progress(output)
return unless progress_enabled?
reset_line if progress_visible?
print output
@progress_visible = true
end
|
.puts(output) ⇒ Object
93
94
95
|
# File 'lib/ui.rb', line 93
def puts(output)
print output + "\n"
end
|
97
98
99
|
# File 'lib/ui.rb', line 97
def warn(s)
STDERR.puts s
end
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/ui.rb', line 28
def (output)
@pager ||= IO.popen("$PAGER", "w")
@pager_pid = @pager.pid
begin
@pager.puts output
rescue Errno::EPIPE
end
end
|