Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
6c64eeb6
Commit
6c64eeb6
authored
Nov 19, 2015
by
Muhammed Yavuz Nuzumlali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4560 from CocoaPods/yavuz/imp/UIWithPager
[User Interface] add method to pipe outputs to a pager
parents
2128c44a
abce6b74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
user_interface.rb
lib/cocoapods/user_interface.rb
+15
-0
user_interface_spec.rb
spec/unit/user_interface_spec.rb
+12
-0
No files found.
lib/cocoapods/user_interface.rb
View file @
6c64eeb6
...
@@ -368,6 +368,21 @@ module Pod
...
@@ -368,6 +368,21 @@ module Pod
warnings
<<
{
:message
=>
message
,
:actions
=>
actions
,
:verbose_only
=>
verbose_only
}
warnings
<<
{
:message
=>
message
,
:actions
=>
actions
,
:verbose_only
=>
verbose_only
}
end
end
# Pipes all output inside given block to a pager.
#
# @yield Code block in which inputs to {#puts} and {#print} methods will be printed to the piper.
#
def
with_pager
prev_handler
=
Signal
.
trap
(
'INT'
,
'IGNORE'
)
IO
.
popen
((
ENV
[
'PAGER'
]
||
'less -R'
),
'w'
)
do
|
io
|
UI
.
output_io
=
io
yield
end
ensure
Signal
.
trap
(
'INT'
,
prev_handler
)
UI
.
output_io
=
nil
end
private
private
# @!group Helpers
# @!group Helpers
...
...
spec/unit/user_interface_spec.rb
View file @
6c64eeb6
...
@@ -26,6 +26,18 @@ module Pod
...
@@ -26,6 +26,18 @@ module Pod
# TODO
# TODO
end
end
describe
'#with_pager'
do
it
'sets output_io'
do
fd
=
IO
.
sysopen
(
'/dev/null'
,
'w'
)
io
=
IO
.
new
(
fd
)
IO
.
stubs
(
:popen
).
yields
(
io
)
UI
.
with_pager
do
UI
.
output_io
.
should
==
io
end
UI
.
output_io
.
should
.
be
.
nil
end
end
describe
'#labeled'
do
describe
'#labeled'
do
it
'prints nothing if value is nil'
do
it
'prints nothing if value is nil'
do
UI
.
labeled
(
'label'
,
nil
)
UI
.
labeled
(
'label'
,
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment