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
d3e2778e
Commit
d3e2778e
authored
Mar 07, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Command::IPC] Use ASCII CR+LF to signal the end of output
parent
e65c2ee5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
inter_process_communication.rb
lib/cocoapods/command/inter_process_communication.rb
+20
-17
inter_process_communication_spec.rb
spec/functional/command/inter_process_communication_spec.rb
+8
-1
No files found.
lib/cocoapods/command/inter_process_communication.rb
View file @
d3e2778e
...
@@ -5,6 +5,10 @@ module Pod
...
@@ -5,6 +5,10 @@ module Pod
self
.
abstract_command
=
true
self
.
abstract_command
=
true
self
.
summary
=
'Inter-process communication'
self
.
summary
=
'Inter-process communication'
def
output_pipe
STDOUT
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
class
Spec
<
IPC
class
Spec
<
IPC
...
@@ -25,7 +29,7 @@ module Pod
...
@@ -25,7 +29,7 @@ module Pod
def
run
def
run
spec
=
Specification
.
from_file
(
@path
)
spec
=
Specification
.
from_file
(
@path
)
UI
.
puts
spec
.
to_yaml
output_pipe
.
puts
spec
.
to_yaml
end
end
end
end
...
@@ -50,7 +54,7 @@ module Pod
...
@@ -50,7 +54,7 @@ module Pod
def
run
def
run
podfile
=
Pod
::
Podfile
.
from_file
(
@path
)
podfile
=
Pod
::
Podfile
.
from_file
(
@path
)
UI
.
puts
podfile
.
to_yaml
output_pipe
.
puts
podfile
.
to_yaml
end
end
end
end
...
@@ -89,7 +93,7 @@ module Pod
...
@@ -89,7 +93,7 @@ module Pod
next
next
end
end
end
end
UI
.
puts
result
.
to_yaml
output_pipe
.
puts
result
.
to_yaml
end
end
end
end
...
@@ -98,39 +102,38 @@ module Pod
...
@@ -98,39 +102,38 @@ module Pod
class
Repl
<
IPC
class
Repl
<
IPC
LISTENING_STRING
=
'>>> @LISTENING <<<'
END_OF_OUTPUT_SIGNAL
=
"
\n\r
"
self
.
summary
=
'The repl listens to commands on standard input.'
self
.
summary
=
'The repl listens to commands on standard input.'
self
.
description
=
<<-
DESC
self
.
description
=
<<-
DESC
The repl listens to commands on standard input and prints their
The repl listens to commands on standard input and prints their
result to standard output.
result to standard output.
It accepts all the other ipc subcommands. The repl will signal when
It accepts all the other ipc subcommands. The repl will signal the
it is ready to receive a new command with the `
#{
LISTENING_STRING
}
`
end of output with the the ASCII CR+LF `
\\
n
\\
r`.
string.
DESC
DESC
def
run
def
run
salute
print_version
signal_end_of_output
listen
listen
end
end
def
salute
def
print_version
UI
.
puts
"version: '
#{
Pod
::
VERSION
}
'"
output_pipe
.
puts
"version: '
#{
Pod
::
VERSION
}
'"
end
def
signal_end_of_output
output_pipe
.
puts
(
END_OF_OUTPUT_SIGNAL
)
STDOUT
.
flush
end
end
def
listen
def
listen
signal_ready
while
repl_command
=
STDIN
.
gets
while
repl_command
=
STDIN
.
gets
execute_repl_command
(
repl_command
)
execute_repl_command
(
repl_command
)
end
end
end
end
def
signal_ready
UI
.
puts
LISTENING_STRING
STDOUT
.
flush
end
def
execute_repl_command
(
repl_command
)
def
execute_repl_command
(
repl_command
)
if
(
repl_command
!=
"
\n
"
)
if
(
repl_command
!=
"
\n
"
)
repl_commands
=
repl_command
.
split
repl_commands
=
repl_command
.
split
...
@@ -138,7 +141,7 @@ module Pod
...
@@ -138,7 +141,7 @@ module Pod
arguments
=
repl_commands
arguments
=
repl_commands
subcommand_class
=
Pod
::
Command
::
IPC
.
const_get
(
subcommand
)
subcommand_class
=
Pod
::
Command
::
IPC
.
const_get
(
subcommand
)
subcommand_class
.
new
(
CLAide
::
ARGV
.
new
(
arguments
)).
run
subcommand_class
.
new
(
CLAide
::
ARGV
.
new
(
arguments
)).
run
signal_
ready
signal_
end_of_output
end
end
end
end
...
...
spec/functional/command/inter_process_communication_spec.rb
View file @
d3e2778e
...
@@ -3,6 +3,13 @@ require File.expand_path('../../../spec_helper', __FILE__)
...
@@ -3,6 +3,13 @@ require File.expand_path('../../../spec_helper', __FILE__)
module
Pod
module
Pod
describe
Command
::
IPC
do
describe
Command
::
IPC
do
before
do
Command
::
IPC
::
Spec
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
Podfile
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
List
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
Repl
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
describe
Command
::
IPC
::
Spec
do
describe
Command
::
IPC
::
Spec
do
it
"converts a podspec to yaml and prints it to STDOUT"
do
it
"converts a podspec to yaml and prints it to STDOUT"
do
...
@@ -69,7 +76,7 @@ module Pod
...
@@ -69,7 +76,7 @@ module Pod
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/- SSZipArchive:/
out
.
should
.
match
/- SSZipArchive:/
out
.
should
.
match
/>>> @LISTENING <<<$/
out
.
should
.
end_with?
(
"
\n\r
"
)
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