Unverified Commit fcb6a0be authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7093 from amorde/dev-podspec

Add podspec, readme, license, docs, etc. to development pods
parents 4ea4f5ae 3da569f8
......@@ -8,7 +8,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### 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
......
......@@ -16,7 +16,7 @@ module Pod
end
store_podspec(sandbox, podspec, podspec.extname == '.json')
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)
end
end
......
......@@ -40,6 +40,7 @@ module Pod
add_frameworks_bundles
add_vendored_libraries
add_resources
add_developer_files unless sandbox.development_pods.empty?
link_headers
end
......@@ -109,6 +110,21 @@ module Pod
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.
#
# @return [void]
......@@ -184,7 +200,7 @@ module Pod
paths = allowable_project_paths(paths)
base_path = local ? common_path(paths) : nil
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)
end
end
......
......@@ -113,6 +113,7 @@ module Pod
SPEC_SUBGROUPS = {
:resources => 'Resources',
:frameworks => 'Frameworks',
:developer => 'Pod',
}
# Returns the group for the specification with the give name creating it if
......
......@@ -152,7 +152,7 @@ module Pod
def pod_dir(name)
root_name = Specification.root_name(name)
if local?(root_name)
Pathname.new(development_pods[root_name])
Pathname.new(development_pods[root_name].dirname)
else
sources_root + root_name
end
......@@ -211,7 +211,7 @@ module Pod
def specification(name)
if file = specification_path(name)
original_path = development_pods[name]
Dir.chdir(original_path || Dir.pwd) { Specification.from_file(file) }
Specification.from_file(original_path || file)
end
end
......@@ -239,8 +239,8 @@ module Pod
# Stores a specification in the `Local Podspecs` folder.
#
# @param [Sandbox] sandbox
# the sandbox where the podspec should be stored.
# @param [String] name
# the name of the pod
#
# @param [String, Pathname] podspec
# The contents of the specification (String) or the path to a
......@@ -248,8 +248,6 @@ module Pod
#
# @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)
file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
......@@ -351,8 +349,8 @@ module Pod
# @param [String] name
# The name of the Pod.
#
# @param [#to_s] path
# The local path where the Pod is stored.
# @param [Pathname, String] path
# The path to the local Podspec
#
# @param [Bool] was_absolute
# True if the specified local path was absolute.
......@@ -361,11 +359,12 @@ module Pod
#
def store_local_path(name, path, was_absolute = false)
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
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.
#
# @todo Rename (e.g. `pods_with_local_path`)
......@@ -380,8 +379,19 @@ module Pod
# @return [Bool] Whether the Pod is locally sourced.
#
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)
!development_pods[root_name].nil?
if path = development_pods[root_name]
Pathname.new(path)
end
end
#-------------------------------------------------------------------------#
......
......@@ -17,6 +17,8 @@ module Pod
:license => 'licen{c,s}e{*,.*}'.freeze,
:source_files => "*{#{SOURCE_FILE_EXTENSIONS.join(',')}}".freeze,
:public_header_files => "*{#{HEADER_EXTENSIONS.join(',')}}".freeze,
:podspecs => '*.{podspec,podspec.json}'.freeze,
:docs => 'doc{s}{*,.*}/**/*'.freeze,
}.freeze
# @return [Sandbox::PathList] the directory where the source of the Pod
......@@ -291,6 +293,34 @@ module Pod
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
......@@ -311,6 +341,12 @@ module Pod
paths_for_attribute(:private_header_files)
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
......
Subproject commit bff259482d80b63b286e54ae502a1b3136ec245f
Subproject commit cd417b2a8a34c2c8630336b29b4b4405df9500b5
......@@ -8,7 +8,6 @@ Pod::Spec.new do |s|
s.source = { :git => 'http://coconut-corp.local/coconut-lib.git', :tag => 'v1.0' }
s.license = {
:type => 'MIT',
:file => 'LICENSE',
:text => 'Permission is hereby granted ...'
}
s.source_files = 'Classes/*.{h,m}'
......
......@@ -22,7 +22,7 @@ module Pod
it 'marks the Pod as local in the sandbox' do
@subject.fetch(config.sandbox)
config.sandbox.development_pods.should == {
'Reachability' => fixture('integration/Reachability').to_s,
'Reachability' => fixture('integration/Reachability/Reachability.podspec'),
}
end
......
......@@ -129,7 +129,7 @@ module Pod
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)
@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
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
......
......@@ -211,6 +211,46 @@ module Pod
@accessor.license.should == @root + 'LICENSE'
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
......
......@@ -22,6 +22,7 @@ module Pod
Classes/BananaLib.pch
Classes/BananaPrivate.h
Classes/BananaTrace.d
LICENSE
README
Resources/Base.lproj/Main.storyboard
Resources/Images.xcassets/Logo.imageset/Contents.json
......@@ -36,6 +37,8 @@ module Pod
Resources/en.lproj/nested/logo-nested.png
Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png
docs/guide1.md
docs/subdir/guide2.md
framework/Source/MoreBanana.h
libBananalib.a
preserve_me.txt
......@@ -71,6 +74,8 @@ module Pod
Resources/en.lproj
Resources/en.lproj/nested
Resources/sub_dir
docs
docs/subdir
framework
framework/Source
sub-dir
......
......@@ -22,6 +22,10 @@ module Pod
.git
.gitmodules
BananaLib.podspec
docs
docs/guide1.md
docs/subdir
docs/subdir/guide2.md
libPusher
sub-dir
sub-dir/sub-dir-2
......
......@@ -78,7 +78,7 @@ module Pod
end
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')
end
......@@ -104,10 +104,14 @@ module Pod
spec = Specification.from_file(spec_file)
Specification.expects(:from_file).with do
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_local_path('BananaLib', fixture('banana-lib'))
@sandbox.store_local_path('BananaLib', spec_file)
@sandbox.specification('BananaLib')
end
......@@ -176,17 +180,17 @@ module Pod
#--------------------------------------#
it 'stores the local path of a Pod' do
@sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path'))
@sandbox.development_pods['BananaLib'].should == 'Some Path'
@sandbox.store_local_path('BananaLib/Subspec', Pathname.new('Some Path/BananaLib.podspec'))
@sandbox.development_pods['BananaLib'].should == Pathname.new('Some Path/BananaLib.podspec')
end
it 'returns the path of the local pods grouped by name' do
@sandbox.store_local_path('BananaLib', 'Some Path')
@sandbox.development_pods.should == { 'BananaLib' => 'Some Path' }
@sandbox.store_local_path('BananaLib', 'BananaLib/BananaLib.podspec')
@sandbox.development_pods.should == { 'BananaLib' => Pathname.new('BananaLib/BananaLib.podspec') }
end
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/Subspec').should.be.true
@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