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
159ca279
Commit
159ca279
authored
Mar 07, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UI] Allow to disable wrapping
parent
e3390c0e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
user_interface.rb
lib/cocoapods/user_interface.rb
+10
-0
user_interface.rb
spec/spec_helper/user_interface.rb
+7
-8
No files found.
lib/cocoapods/user_interface.rb
View file @
159ca279
...
@@ -23,6 +23,12 @@ module Pod
...
@@ -23,6 +23,12 @@ module Pod
attr_accessor
:title_level
attr_accessor
:title_level
attr_accessor
:warnings
attr_accessor
:warnings
# @return [Bool] Whether the wrapping of the strings to the width of the
# terminal should be disabled.
#
attr_accessor
:disable_wrap
alias_method
:disable_wrap?
,
:disable_wrap
# Prints a title taking an optional verbose prefix and
# Prints a title taking an optional verbose prefix and
# a relative indentation valid for the UI action in the passed
# a relative indentation valid for the UI action in the passed
# block.
# block.
...
@@ -254,12 +260,16 @@ module Pod
...
@@ -254,12 +260,16 @@ module Pod
# terminal is too small a width of 80 is assumed.
# terminal is too small a width of 80 is assumed.
#
#
def
wrap_string
(
txt
,
indent
=
''
)
def
wrap_string
(
txt
,
indent
=
''
)
if
disable_wrap
txt
else
width
=
`stty size`
.
split
(
' '
)[
1
].
to_i
-
indent
.
length
width
=
`stty size`
.
split
(
' '
)[
1
].
to_i
-
indent
.
length
width
=
80
unless
width
>=
10
width
=
80
unless
width
>=
10
txt
.
strip
.
gsub
(
/(.{1,
#{
width
}
})( +|$)\n?|(.{
#{
width
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
txt
.
strip
.
gsub
(
/(.{1,
#{
width
}
})( +|$)\n?|(.{
#{
width
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
end
end
end
end
end
end
UI
=
UserInterface
UI
=
UserInterface
# Redirects cocoapods-core UI.
# Redirects cocoapods-core UI.
...
...
spec/spec_helper/user_interface.rb
View file @
159ca279
module
Pod
module
Pod
# @note as some outputs wraps strings
# Disable the wrapping so the output is deterministic in the tests.
#
UI
.
disable_wrap
=
true
# Redirects the messages to an internal store.
#
#
module
UI
module
UI
@output
=
''
@output
=
''
...
@@ -10,17 +14,12 @@ module Pod
...
@@ -10,17 +14,12 @@ module Pod
attr_accessor
:output
attr_accessor
:output
attr_accessor
:warnings
attr_accessor
:warnings
# @todo Allow to specify whether the text should be wrapped with an
# environment variable and remove the new feed replacement.
def
puts
(
message
=
''
)
def
puts
(
message
=
''
)
# Wrapping can bite in tests.
@output
<<
"
#{
message
}
"
@output
<<
"
#{
message
}
"
.
gsub
(
/\n/
,
''
)
end
end
def
warn
(
message
=
''
,
actions
=
[])
def
warn
(
message
=
''
,
actions
=
[])
# Wrapping can bite in tests.
@warnings
<<
"
#{
message
}
"
@warnings
<<
"
#{
message
}
"
.
gsub
(
/\n/
,
''
)
end
end
end
end
end
end
...
...
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