Commit 478ef3a6 authored by Fabio Pelosin's avatar Fabio Pelosin

[Command::IPC] Add repl subcommand

parent 93c28fca
......@@ -11,6 +11,10 @@
OTHER_CPLUSPLUSFLAGS in the release builds of the Pods project.
- Fixed `pod lint --local`
###### Ancillary enhancements
- Added `pod ipc repl` subcommand.
## 0.17.0.rc2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.17.0.rc1...0.17.0.rc2)
[cocoapods-core](https://github.com/CocoaPods/Core/compare/0.17.0.rc1...0.17.0.rc2)
......
......@@ -80,9 +80,7 @@ module Pod
begin
spec = set.specification
result[spec.name] = {
'defined_in_file' => spec.defined_in_file.to_s,
'version' => spec.version,
'authors' => spec.authors,
'authors' => spec.authors.keys,
'summary' => spec.summary,
'description' => spec.description,
'platforms' => spec.available_platforms.map { |p| p.name.to_s },
......@@ -98,6 +96,56 @@ module Pod
#-----------------------------------------------------------------------#
class Repl < IPC
LISTENING_STRING = '>>> @LISTENING <<<'
self.summary = 'The repl listens to commands on standard input.'
self.description = <<-DESC
The repl listens to commands on standard input and prints their
result to standard output.
It accepts all the other ipc subcommands. The repl will signal when
it is ready to receive a new command with the `#{LISTENING_STRING}`
string.
DESC
def run
salute
listen
end
def salute
UI.puts "version: #{Pod::VERSION}"
end
def listen
signal_ready
while repl_command = STDIN.gets
execute_repl_command(repl_command)
end
end
def signal_ready
UI.puts LISTENING_STRING
end
def execute_repl_command(repl_command)
if (repl_command != "\n")
repl_commands = repl_command.split
subcommand = repl_commands.shift.capitalize
arguments = repl_commands
subcommand_class = Kernel.const_get("Pod::Command::IPC::#{subcommand}")
subcommand_class.new(CLAide::ARGV.new(arguments)).run
signal_ready
STDOUT.flush
end
end
end
#-----------------------------------------------------------------------#
end
end
end
......@@ -42,7 +42,6 @@ module Pod
out = run_command('ipc', 'list')
out.should.include('---')
out.should.match /BananaLib:/
out.should.match /version: .1\.0./
out.should.match /description: Full of chunky bananas./
end
......@@ -50,5 +49,32 @@ module Pod
#-------------------------------------------------------------------------#
describe Command::IPC::Repl do
it "prints the version of CocoaPods as its first message" do
command = Command::IPC::Repl.new(CLAide::ARGV.new([]))
command.stubs(:listen)
command.run
out = UI.output
out.should.match /version: #{Pod::VERSION}/
end
it "converts forwards the commands to the other ipc subcommands prints the result to STDOUT" do
command = Command::IPC::Repl.new(CLAide::ARGV.new([]))
command.execute_repl_command("podfile #{fixture('Podfile')}")
out = UI.output
out.should.include('---')
out.should.match /target_definitions:/
out.should.match /platform: ios/
out.should.match /- SSZipArchive:/
out.should.match />>> @LISTENING <<<$/
end
end
#-------------------------------------------------------------------------#
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment