Commit b95bb22c authored by dacaiguoguogmail's avatar dacaiguoguogmail

Add ipc command `podfile_json` converts a Podfile to JSON

parent 0ad9a6ca
...@@ -32,6 +32,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -32,6 +32,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Austin Emmons](https://github.com/atreat) [Austin Emmons](https://github.com/atreat)
[#6742](https://github.com/CocoaPods/CocoaPods/issues/6742) [#6742](https://github.com/CocoaPods/CocoaPods/issues/6742)
* Add ipc command `podfile_json` converts a Podfile to JSON
[Dacaiguoguo](https://github.com/dacaiguoguogmail)
[#6779](https://github.com/CocoaPods/CocoaPods/pull/6779)
##### Bug Fixes ##### Bug Fixes
* Do not double add search paths to test xcconfig from parent * Do not double add search paths to test xcconfig from parent
......
require 'cocoapods/command/ipc/list' require 'cocoapods/command/ipc/list'
require 'cocoapods/command/ipc/podfile' require 'cocoapods/command/ipc/podfile'
require 'cocoapods/command/ipc/podfile_json'
require 'cocoapods/command/ipc/repl' require 'cocoapods/command/ipc/repl'
require 'cocoapods/command/ipc/spec' require 'cocoapods/command/ipc/spec'
require 'cocoapods/command/ipc/update_search_index' require 'cocoapods/command/ipc/update_search_index'
......
module Pod
class Command
class IPC < Command
class PodfileJSON < IPC
include ProjectDirectory
self.summary = 'Converts a Podfile to JSON'
self.description = 'Converts a Podfile to JSON and prints it to STDOUT.'
self.arguments = [
CLAide::Argument.new('PATH', true),
]
def initialize(argv)
@path = argv.shift_argument
super
end
def validate!
super
help! 'A Podfile path is required.' unless @path
end
def run
podfile = Pod::Podfile.from_file(@path)
output_pipe.puts podfile.to_hash.to_json
end
end
end
end
end
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Command::IPC::PodfileJSON do
before do
Command::IPC::PodfileJSON.any_instance.stubs(:output_pipe).returns(UI)
end
it 'converts a Podfile to JSON and prints it to STDOUT' do
out = run_command('ipc', 'podfile-json', fixture('Podfile'))
parsed_hash = JSON.parse(out)
parsed_hash.should == { 'target_definitions' => [{ 'name' => 'Pods', 'abstract' => true, 'platform' => 'ios', 'dependencies' => [{ 'SSZipArchive' => ['>= 1'] }, { 'ASIHTTPRequest' => ['~> 1.8.0'] }, 'Reachability', { 'ASIWebPageRequest' => ['< 1.8.2'] }] }] }
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