Commit aef7ea0f authored by Eloy Duran's avatar Eloy Duran

Install a library from a podspec defined on a dependency in a Podfile.

parent ddc5ac50
...@@ -13,6 +13,7 @@ module Pod ...@@ -13,6 +13,7 @@ module Pod
def initialize(*name_and_version_requirements, &block) def initialize(*name_and_version_requirements, &block)
if name_and_version_requirements.empty? && block if name_and_version_requirements.empty? && block
@inline_podspec = true
@specification = Specification.new(&block) @specification = Specification.new(&block)
super(@specification.name, @specification.version) super(@specification.name, @specification.version)
...@@ -35,17 +36,11 @@ module Pod ...@@ -35,17 +36,11 @@ module Pod
(@specification ? @specification == other.specification : @external_spec_source == other.external_spec_source) (@specification ? @specification == other.specification : @external_spec_source == other.external_spec_source)
end end
def external_podspec? # In case this dependency was defined with either a repo url, :podspec, or block,
!@external_spec_source.nil? # this method will return the Specification instance.
end
def inline_podspec?
!@specification.nil?
end
def specification def specification
@specification ||= begin @specification ||= begin
if external_podspec? if @external_spec_source
pod_root = Config.instance.project_pods_root + @name pod_root = Config.instance.project_pods_root + @name
spec = nil spec = nil
if @external_spec_source[:podspec] if @external_spec_source[:podspec]
......
...@@ -20,6 +20,7 @@ module Pod ...@@ -20,6 +20,7 @@ module Pod
executable :git executable :git
def download def download
@pod_root.dirname.mkpath
if @options[:tag] if @options[:tag]
download_tag download_tag
elsif @options[:commit] elsif @options[:commit]
...@@ -34,7 +35,7 @@ module Pod ...@@ -34,7 +35,7 @@ module Pod
end end
def download_tag def download_tag
@pod_root.mkdir @pod_root.mkpath
Dir.chdir(@pod_root) do Dir.chdir(@pod_root) do
git "init" git "init"
git "remote add origin '#{@url}'" git "remote add origin '#{@url}'"
......
...@@ -23,8 +23,8 @@ module Pod ...@@ -23,8 +23,8 @@ module Pod
end end
def find_dependency_set(dependency) def find_dependency_set(dependency)
if dependency.external_podspec? if external_spec = dependency.specification
Specification::Set::External.new(dependency.specification) Specification::Set::External.new(external_spec)
else else
Source.search(dependency) Source.search(dependency)
end end
......
...@@ -286,8 +286,8 @@ module Pod ...@@ -286,8 +286,8 @@ module Pod
# end # end
def install! def install!
puts "==> Installing: #{self}" unless config.silent? puts "==> Installing: #{self}" unless config.silent?
if defined_in_file && !(config.project_pods_root + defined_in_file.basename).exist?
config.project_pods_root.mkpath config.project_pods_root.mkpath
unless (config.project_pods_root + defined_in_file.basename).exist?
FileUtils.cp(defined_in_file, config.project_pods_root) FileUtils.cp(defined_in_file, config.project_pods_root)
end end
......
...@@ -86,8 +86,32 @@ else ...@@ -86,8 +86,32 @@ else
(config.project_pods_root + 'ASIHTTPRequest').should.exist (config.project_pods_root + 'ASIHTTPRequest').should.exist
end end
it "installs a library with a podspec defined inline" do
podfile = Pod::Podfile.new do
self.platform :ios
dependency do |s|
s.name = 'JSONKit'
s.version = '1.2'
s.source = { :git => 'https://github.com/johnezang/JSONKit.git', :tag => 'v1.2' }
s.source_files = 'JSONKit.*'
end
end
installer = SpecHelper::Installer.new(podfile)
installer.install!
# TODO do we need the write out the podspec?
#spec = Pod::Spec.from_file(config.project_pods_root + 'JSONKit.podspec')
#spec.version.to_s.should == '1.2'
change_log = (config.project_pods_root + 'JSONKit/CHANGELOG.md').read
change_log.should.include '1.2'
change_log.should.not.include '1.3'
end
end end
if false
before do before do
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root) FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
end end
...@@ -262,3 +286,4 @@ else ...@@ -262,3 +286,4 @@ else
end end
end end
end
...@@ -7,20 +7,6 @@ describe "Pod::Dependency" do ...@@ -7,20 +7,6 @@ describe "Pod::Dependency" do
dep1.merge(dep2).should == Pod::Dependency.new('bananas', '>= 1.8', '1.9') dep1.merge(dep2).should == Pod::Dependency.new('bananas', '>= 1.8', '1.9')
end end
it "returns wether or not the spec for this pod is in a spec repo" do
dep = Pod::Dependency.new('bananas')
dep.should.not.be.external_podspec
dep.external_spec_source = { :git => 'GIT-URL' }
dep.should.be.external_podspec
end
it "returns wether or not the spec for this pod is defined inline" do
dep = Pod::Dependency.new { |s| s.name = 'bananas' }
dep.should.be.inline_podspec
dep.specification.should.be.instance_of Pod::Specification
dep.specification.name.should == 'bananas'
end
it "is equal to another dependency if `part_of_other_pod' is the same" do it "is equal to another dependency if `part_of_other_pod' is the same" do
dep1 = Pod::Dependency.new('bananas', '>= 1') dep1 = Pod::Dependency.new('bananas', '>= 1')
dep1.only_part_of_other_pod = true dep1.only_part_of_other_pod = true
......
...@@ -23,7 +23,6 @@ describe "Pod::Podfile" do ...@@ -23,7 +23,6 @@ describe "Pod::Podfile" do
dependency 'SomeExternalPod', :git => 'GIT-URL', :commit => '1234' dependency 'SomeExternalPod', :git => 'GIT-URL', :commit => '1234'
end end
dep = podfile.dependency_by_name('SomeExternalPod') dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.external_podspec
dep.external_spec_source.should == { :git => 'GIT-URL', :commit => '1234' } dep.external_spec_source.should == { :git => 'GIT-URL', :commit => '1234' }
end end
...@@ -32,7 +31,6 @@ describe "Pod::Podfile" do ...@@ -32,7 +31,6 @@ describe "Pod::Podfile" do
dependency 'SomeExternalPod', :podspec => 'http://gist/SomeExternalPod.podspec' dependency 'SomeExternalPod', :podspec => 'http://gist/SomeExternalPod.podspec'
end end
dep = podfile.dependency_by_name('SomeExternalPod') dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.external_podspec
dep.external_spec_source.should == { :podspec => 'http://gist/SomeExternalPod.podspec' } dep.external_spec_source.should == { :podspec => 'http://gist/SomeExternalPod.podspec' }
end end
...@@ -43,7 +41,6 @@ describe "Pod::Podfile" do ...@@ -43,7 +41,6 @@ describe "Pod::Podfile" do
end end
end end
dep = podfile.dependency_by_name('SomeExternalPod') dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.inline_podspec
dep.specification.name.should == 'SomeExternalPod' dep.specification.name.should == 'SomeExternalPod'
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