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
925e086a
Commit
925e086a
authored
Dec 18, 2013
by
Eloy Durán
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1680 from carsonmcdonald/stdingetstouigets
Replace use of $stdin.gets with UI.gets
parents
5699bf84
e0d9e753
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
8 deletions
+17
-8
spec.rb
lib/cocoapods/command/spec.rb
+1
-1
user_interface.rb
lib/cocoapods/user_interface.rb
+6
-0
spec_spec.rb
spec/functional/command/spec_spec.rb
+4
-7
user_interface.rb
spec/spec_helper/user_interface.rb
+6
-0
No files found.
lib/cocoapods/command/spec.rb
View file @
925e086a
...
@@ -302,7 +302,7 @@ module Pod
...
@@ -302,7 +302,7 @@ module Pod
UI
.
puts
message
UI
.
puts
message
index
=
$stdin
.
gets
.
chomp
.
to_i
-
1
index
=
UI
.
gets
.
chomp
.
to_i
-
1
if
index
<
0
||
index
>
array
.
count
-
1
if
index
<
0
||
index
>
array
.
count
-
1
raise
Informative
,
"
#{
index
+
1
}
is invalid [1-
#{
array
.
count
}
]"
raise
Informative
,
"
#{
index
+
1
}
is invalid [1-
#{
array
.
count
}
]"
else
else
...
...
lib/cocoapods/user_interface.rb
View file @
925e086a
...
@@ -240,6 +240,12 @@ module Pod
...
@@ -240,6 +240,12 @@ module Pod
STDOUT
.
print
(
message
)
unless
config
.
silent?
STDOUT
.
print
(
message
)
unless
config
.
silent?
end
end
# gets input from $stdin
#
def
gets
$stdin
.
gets
end
# Stores important warning to the user optionally followed by actions
# Stores important warning to the user optionally followed by actions
# that the user should take. To print them use {#print_warnings}.
# that the user should take. To print them use {#print_warnings}.
#
#
...
...
spec/functional/command/spec_spec.rb
View file @
925e086a
...
@@ -212,10 +212,9 @@ module Pod
...
@@ -212,10 +212,9 @@ module Pod
end
end
it
"cats the first podspec from all podspecs"
do
it
"cats the first podspec from all podspecs"
do
$stdin
=
StringIO
.
new
(
"1
\n
"
,
'r'
)
UI
.
next_input
=
"1
\n
"
run_command
(
'spec'
,
'cat'
,
'--show-all'
,
'AFNetworking'
)
run_command
(
'spec'
,
'cat'
,
'--show-all'
,
'AFNetworking'
)
UI
.
output
.
should
.
include
fixture
(
'spec-repos/master/AFNetworking/1.2.0/AFNetworking.podspec'
).
read
UI
.
output
.
should
.
include
fixture
(
'spec-repos/master/AFNetworking/1.2.0/AFNetworking.podspec'
).
read
$stdin
=
STDIN
end
end
end
end
...
@@ -248,19 +247,17 @@ module Pod
...
@@ -248,19 +247,17 @@ module Pod
describe
"#choose_from_array"
do
describe
"#choose_from_array"
do
it
"should return a valid index for the given array"
do
it
"should return a valid index for the given array"
do
$stdin
=
StringIO
.
new
(
"1
\n
"
,
'r'
)
UI
.
next_input
=
"1
\n
"
index
=
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
index
=
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
UI
.
output
.
should
.
include
"1: item1
\n
2: item2
\n
3: item3
\n
A message
\n
"
UI
.
output
.
should
.
include
"1: item1
\n
2: item2
\n
3: item3
\n
A message
\n
"
index
.
should
==
0
index
.
should
==
0
$stdin
=
STDIN
end
end
it
"should raise when the index is out of bounds"
do
it
"should raise when the index is out of bounds"
do
$stdin
=
StringIO
.
new
(
"4
\n
"
,
'r'
)
UI
.
next_input
=
"4
\n
"
lambda
{
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
}.
should
.
raise
Pod
::
Informative
lambda
{
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
}.
should
.
raise
Pod
::
Informative
$stdin
=
StringIO
.
new
(
"0
\n
"
,
'r'
)
UI
.
next_input
=
"0
\n
"
lambda
{
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
}.
should
.
raise
Pod
::
Informative
lambda
{
@sut
.
send
(
:choose_from_array
,
[
'item1'
,
'item2'
,
'item3'
],
'A message'
)
}.
should
.
raise
Pod
::
Informative
$stdin
=
STDIN
end
end
end
end
...
...
spec/spec_helper/user_interface.rb
View file @
925e086a
...
@@ -9,10 +9,12 @@ module Pod
...
@@ -9,10 +9,12 @@ module Pod
module
UI
module
UI
@output
=
''
@output
=
''
@warnings
=
''
@warnings
=
''
@next_input
=
''
class
<<
self
class
<<
self
attr_accessor
:output
attr_accessor
:output
attr_accessor
:warnings
attr_accessor
:warnings
attr_accessor
:next_input
def
puts
(
message
=
''
)
def
puts
(
message
=
''
)
@output
<<
"
#{
message
}
\n
"
@output
<<
"
#{
message
}
\n
"
...
@@ -25,6 +27,10 @@ module Pod
...
@@ -25,6 +27,10 @@ module Pod
def
print
(
message
)
def
print
(
message
)
@output
<<
message
@output
<<
message
end
end
def
gets
@next_input
end
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