Commit 3da569f8 authored by Eric Amorde's avatar Eric Amorde

Add support for editing podspecs, docs, license, readme, module map, etc. for…

Add support for editing podspecs, docs, license, readme, module map, etc. for local development pods
parent 4ea4f5ae
...@@ -8,7 +8,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,7 +8,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* None. * Add support for editing the podspec, license, README, license, and docs of local development pods
[Eric Amorde](https://github.com/amorde)
[#7093](https://github.com/CocoaPods/CocoaPods/pull/7093)
##### Bug Fixes ##### Bug Fixes
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
end end
store_podspec(sandbox, podspec, podspec.extname == '.json') store_podspec(sandbox, podspec, podspec.extname == '.json')
is_absolute = absolute?(declared_path) is_absolute = absolute?(declared_path)
sandbox.store_local_path(name, podspec.dirname, is_absolute) sandbox.store_local_path(name, podspec, is_absolute)
sandbox.remove_checkout_source(name) sandbox.remove_checkout_source(name)
end end
end end
......
...@@ -40,6 +40,7 @@ module Pod ...@@ -40,6 +40,7 @@ module Pod
add_frameworks_bundles add_frameworks_bundles
add_vendored_libraries add_vendored_libraries
add_resources add_resources
add_developer_files unless sandbox.development_pods.empty?
link_headers link_headers
end end
...@@ -109,6 +110,21 @@ module Pod ...@@ -109,6 +110,21 @@ module Pod
end end
end end
def add_developer_files
UI.message '- Adding development pod helper files to Pods project' do
file_accessors.each do |file_accessor|
pod_name = file_accessor.spec.name
next unless sandbox.local?(pod_name)
root_name = Specification.root_name(pod_name)
paths = file_accessor.developer_files
paths.each do |path|
group = pods_project.group_for_spec(root_name, :developer)
pods_project.add_file_reference(path, group, false)
end
end
end
end
# Creates the link to the headers of the Pod in the sandbox. # Creates the link to the headers of the Pod in the sandbox.
# #
# @return [void] # @return [void]
...@@ -184,7 +200,7 @@ module Pod ...@@ -184,7 +200,7 @@ module Pod
paths = allowable_project_paths(paths) paths = allowable_project_paths(paths)
base_path = local ? common_path(paths) : nil base_path = local ? common_path(paths) : nil
paths.each do |path| paths.each do |path|
group = pods_project.group_for_spec(file_accessor.spec.name, group_key) group = pods_project.group_for_spec(pod_name, group_key)
pods_project.add_file_reference(path, group, local && reflect_file_system_structure_for_development, base_path) pods_project.add_file_reference(path, group, local && reflect_file_system_structure_for_development, base_path)
end end
end end
......
...@@ -113,6 +113,7 @@ module Pod ...@@ -113,6 +113,7 @@ module Pod
SPEC_SUBGROUPS = { SPEC_SUBGROUPS = {
:resources => 'Resources', :resources => 'Resources',
:frameworks => 'Frameworks', :frameworks => 'Frameworks',
:developer => 'Pod',
} }
# Returns the group for the specification with the give name creating it if # Returns the group for the specification with the give name creating it if
......
...@@ -152,7 +152,7 @@ module Pod ...@@ -152,7 +152,7 @@ module Pod
def pod_dir(name) def pod_dir(name)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
if local?(root_name) if local?(root_name)
Pathname.new(development_pods[root_name]) Pathname.new(development_pods[root_name].dirname)
else else
sources_root + root_name sources_root + root_name
end end
...@@ -211,7 +211,7 @@ module Pod ...@@ -211,7 +211,7 @@ module Pod
def specification(name) def specification(name)
if file = specification_path(name) if file = specification_path(name)
original_path = development_pods[name] original_path = development_pods[name]
Dir.chdir(original_path || Dir.pwd) { Specification.from_file(file) } Specification.from_file(original_path || file)
end end
end end
...@@ -239,8 +239,8 @@ module Pod ...@@ -239,8 +239,8 @@ module Pod
# Stores a specification in the `Local Podspecs` folder. # Stores a specification in the `Local Podspecs` folder.
# #
# @param [Sandbox] sandbox # @param [String] name
# the sandbox where the podspec should be stored. # the name of the pod
# #
# @param [String, Pathname] podspec # @param [String, Pathname] podspec
# The contents of the specification (String) or the path to a # The contents of the specification (String) or the path to a
...@@ -248,8 +248,6 @@ module Pod ...@@ -248,8 +248,6 @@ module Pod
# #
# @return [void] # @return [void]
# #
# @todo Store all the specifications (including those not originating
# from external sources) so users can check them.
# #
def store_podspec(name, podspec, _external_source = false, json = false) def store_podspec(name, podspec, _external_source = false, json = false)
file_name = json ? "#{name}.podspec.json" : "#{name}.podspec" file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
...@@ -351,8 +349,8 @@ module Pod ...@@ -351,8 +349,8 @@ module Pod
# @param [String] name # @param [String] name
# The name of the Pod. # The name of the Pod.
# #
# @param [#to_s] path # @param [Pathname, String] path
# The local path where the Pod is stored. # The path to the local Podspec
# #
# @param [Bool] was_absolute # @param [Bool] was_absolute
# True if the specified local path was absolute. # True if the specified local path was absolute.
...@@ -361,11 +359,12 @@ module Pod ...@@ -361,11 +359,12 @@ module Pod
# #
def store_local_path(name, path, was_absolute = false) def store_local_path(name, path, was_absolute = false)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
development_pods[root_name] = path.to_s path = Pathname.new(path) unless path.is_a?(Pathname)
development_pods[root_name] = path
@pods_with_absolute_path << root_name if was_absolute @pods_with_absolute_path << root_name if was_absolute
end end
# @return [Hash{String=>String}] The path of the Pods with a local source # @return [Hash{String=>Pathname}] The path of the Pods' podspecs with a local source
# grouped by their root name. # grouped by their root name.
# #
# @todo Rename (e.g. `pods_with_local_path`) # @todo Rename (e.g. `pods_with_local_path`)
...@@ -380,8 +379,19 @@ module Pod ...@@ -380,8 +379,19 @@ module Pod
# @return [Bool] Whether the Pod is locally sourced. # @return [Bool] Whether the Pod is locally sourced.
# #
def local?(name) def local?(name)
!local_podspec(name).nil?
end
# @param [String] name
# The name of a locally specified Pod
#
# @return [Pathname] Path to the local Podspec of the Pod
#
def local_podspec(name)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
!development_pods[root_name].nil? if path = development_pods[root_name]
Pathname.new(path)
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -17,6 +17,8 @@ module Pod ...@@ -17,6 +17,8 @@ module Pod
:license => 'licen{c,s}e{*,.*}'.freeze, :license => 'licen{c,s}e{*,.*}'.freeze,
:source_files => "*{#{SOURCE_FILE_EXTENSIONS.join(',')}}".freeze, :source_files => "*{#{SOURCE_FILE_EXTENSIONS.join(',')}}".freeze,
:public_header_files => "*{#{HEADER_EXTENSIONS.join(',')}}".freeze, :public_header_files => "*{#{HEADER_EXTENSIONS.join(',')}}".freeze,
:podspecs => '*.{podspec,podspec.json}'.freeze,
:docs => 'doc{s}{*,.*}/**/*'.freeze,
}.freeze }.freeze
# @return [Sandbox::PathList] the directory where the source of the Pod # @return [Sandbox::PathList] the directory where the source of the Pod
...@@ -291,6 +293,34 @@ module Pod ...@@ -291,6 +293,34 @@ module Pod
end end
end end
# @return [Array<Pathname>] The paths of auto-detected podspecs
#
def specs
path_list.glob([GLOB_PATTERNS[:podspecs]])
end
# @return [Array<Pathname>] The paths of auto-detected docs
#
def docs
path_list.glob([GLOB_PATTERNS[:docs]])
end
# @return [Array<Pathname>] Paths to include for local pods to assist in development
#
def developer_files
podspecs = specs
result = [module_map, prefix_header]
if podspecs.size <= 1
result += [license, readme, podspecs, docs]
else
result << podspec_file
if file = spec_consumer.license[:file]
result << root + file
end
end
result.compact.flatten.sort
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
...@@ -311,6 +341,12 @@ module Pod ...@@ -311,6 +341,12 @@ module Pod
paths_for_attribute(:private_header_files) paths_for_attribute(:private_header_files)
end end
# @return [Pathname] The path of the podspec matching @spec
#
def podspec_file
specs.lazy.select { |p| File.basename(p.to_s, '.*') == spec.name }.first
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private private
......
Subproject commit bff259482d80b63b286e54ae502a1b3136ec245f Subproject commit cd417b2a8a34c2c8630336b29b4b4405df9500b5
...@@ -8,7 +8,6 @@ Pod::Spec.new do |s| ...@@ -8,7 +8,6 @@ Pod::Spec.new do |s|
s.source = { :git => 'http://coconut-corp.local/coconut-lib.git', :tag => 'v1.0' } s.source = { :git => 'http://coconut-corp.local/coconut-lib.git', :tag => 'v1.0' }
s.license = { s.license = {
:type => 'MIT', :type => 'MIT',
:file => 'LICENSE',
:text => 'Permission is hereby granted ...' :text => 'Permission is hereby granted ...'
} }
s.source_files = 'Classes/*.{h,m}' s.source_files = 'Classes/*.{h,m}'
......
...@@ -22,7 +22,7 @@ module Pod ...@@ -22,7 +22,7 @@ module Pod
it 'marks the Pod as local in the sandbox' do it 'marks the Pod as local in the sandbox' do
@subject.fetch(config.sandbox) @subject.fetch(config.sandbox)
config.sandbox.development_pods.should == { config.sandbox.development_pods.should == {
'Reachability' => fixture('integration/Reachability').to_s, 'Reachability' => fixture('integration/Reachability/Reachability.podspec'),
} }
end end
......
...@@ -129,7 +129,7 @@ module Pod ...@@ -129,7 +129,7 @@ module Pod
it 'sets the PODS_TARGET_SRCROOT build variable for local pod' do it 'sets the PODS_TARGET_SRCROOT build variable for local pod' do
@pod_target.sandbox.store_local_path(@pod_target.pod_name, @spec.defined_in_file) @pod_target.sandbox.store_local_path(@pod_target.pod_name, @spec.defined_in_file)
@xcconfig = @generator.generate @xcconfig = @generator.generate
@xcconfig.to_hash['PODS_TARGET_SRCROOT'].should == '${PODS_ROOT}/../../spec/fixtures/banana-lib/BananaLib.podspec' @xcconfig.to_hash['PODS_TARGET_SRCROOT'].should == '${PODS_ROOT}/../../spec/fixtures/banana-lib'
end end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
......
...@@ -211,6 +211,46 @@ module Pod ...@@ -211,6 +211,46 @@ module Pod
@accessor.license.should == @root + 'LICENSE' @accessor.license.should == @root + 'LICENSE'
end end
it 'returns the docs of the specification' do
@accessor.docs.should == [
@root + 'docs/guide1.md',
@root + 'docs/subdir/guide2.md',
]
end
it 'returns the podspecs of the specification' do
@accessor.specs.should == [
@root + 'BananaLib.podspec',
]
end
it 'returns the matching podspec of the specification' do
@accessor.stubs(:specs).returns([@root + 'BananaLib.podspec', @root + 'OtherLib.podspec'])
@accessor.send(:podspec_file).should == @root + 'BananaLib.podspec'
end
it 'returns the developer files of the specification' do
@accessor.developer_files.should == [
@root + 'Banana.modulemap',
@root + 'BananaLib.podspec',
@root + 'Classes/BananaLib.pch',
@root + 'LICENSE',
@root + 'README',
@root + 'docs/guide1.md',
@root + 'docs/subdir/guide2.md',
]
end
it 'does not return auto-detected developer files when there are multiple podspecs' do
@accessor.stubs(:specs).returns([@root + 'BananaLib.podspec', @root + 'OtherLib.podspec'])
@accessor.developer_files.should == [
@root + 'Banana.modulemap',
@root + 'BananaLib.podspec',
@root + 'Classes/BananaLib.pch',
@root + 'LICENSE',
]
end
#--------------------------------------# #--------------------------------------#
it 'respects the exclude files' do it 'respects the exclude files' do
......
...@@ -22,6 +22,7 @@ module Pod ...@@ -22,6 +22,7 @@ module Pod
Classes/BananaLib.pch Classes/BananaLib.pch
Classes/BananaPrivate.h Classes/BananaPrivate.h
Classes/BananaTrace.d Classes/BananaTrace.d
LICENSE
README README
Resources/Base.lproj/Main.storyboard Resources/Base.lproj/Main.storyboard
Resources/Images.xcassets/Logo.imageset/Contents.json Resources/Images.xcassets/Logo.imageset/Contents.json
...@@ -36,6 +37,8 @@ module Pod ...@@ -36,6 +37,8 @@ module Pod
Resources/en.lproj/nested/logo-nested.png Resources/en.lproj/nested/logo-nested.png
Resources/logo-sidebar.png Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png Resources/sub_dir/logo-sidebar.png
docs/guide1.md
docs/subdir/guide2.md
framework/Source/MoreBanana.h framework/Source/MoreBanana.h
libBananalib.a libBananalib.a
preserve_me.txt preserve_me.txt
...@@ -71,6 +74,8 @@ module Pod ...@@ -71,6 +74,8 @@ module Pod
Resources/en.lproj Resources/en.lproj
Resources/en.lproj/nested Resources/en.lproj/nested
Resources/sub_dir Resources/sub_dir
docs
docs/subdir
framework framework
framework/Source framework/Source
sub-dir sub-dir
......
...@@ -22,6 +22,10 @@ module Pod ...@@ -22,6 +22,10 @@ module Pod
.git .git
.gitmodules .gitmodules
BananaLib.podspec BananaLib.podspec
docs
docs/guide1.md
docs/subdir
docs/subdir/guide2.md
libPusher libPusher
sub-dir sub-dir
sub-dir/sub-dir-2 sub-dir/sub-dir-2
......
...@@ -78,7 +78,7 @@ module Pod ...@@ -78,7 +78,7 @@ module Pod
end end
it 'returns the directory where a local Pod is stored' do it 'returns the directory where a local Pod is stored' do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib', Pathname.new('Some Path/BananaLib.podspec'))
@sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path') @sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path')
end end
...@@ -104,10 +104,14 @@ module Pod ...@@ -104,10 +104,14 @@ module Pod
spec = Specification.from_file(spec_file) spec = Specification.from_file(spec_file)
Specification.expects(:from_file).with do Specification.expects(:from_file).with do
Dir.pwd == fixture('banana-lib').to_s Dir.pwd == fixture('banana-lib').to_s
end.twice.returns(spec) end.once.returns(spec)
Specification.expects(:from_file).with do |path|
path == spec_file
end.once.returns(spec)
@sandbox.store_podspec('BananaLib', spec_file) @sandbox.store_podspec('BananaLib', spec_file)
@sandbox.store_local_path('BananaLib', fixture('banana-lib')) @sandbox.store_local_path('BananaLib', spec_file)
@sandbox.specification('BananaLib') @sandbox.specification('BananaLib')
end end
...@@ -176,17 +180,17 @@ module Pod ...@@ -176,17 +180,17 @@ module Pod
#--------------------------------------# #--------------------------------------#
it 'stores the local path of a Pod' do it 'stores the local path of a Pod' do
@sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path/BananaLib.podspec'))
@sandbox.development_pods['BananaLib'].should == 'Some Path' @sandbox.development_pods['BananaLib'].should == Pathname.new('Some Path/BananaLib.podspec')
end end
it 'returns the path of the local pods grouped by name' do it 'returns the path of the local pods grouped by name' do
@sandbox.store_local_path('BananaLib', 'Some Path') @sandbox.store_local_path('BananaLib', 'BananaLib/BananaLib.podspec')
@sandbox.development_pods.should == { 'BananaLib' => 'Some Path' } @sandbox.development_pods.should == { 'BananaLib' => Pathname.new('BananaLib/BananaLib.podspec') }
end end
it 'returns whether a Pod is local' do it 'returns whether a Pod is local' do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib', Pathname.new('BananaLib/BananaLib.podspec'))
@sandbox.local?('BananaLib').should.be.true @sandbox.local?('BananaLib').should.be.true
@sandbox.local?('BananaLib/Subspec').should.be.true @sandbox.local?('BananaLib/Subspec').should.be.true
@sandbox.local?('Monkey').should.be.false @sandbox.local?('Monkey').should.be.false
......
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