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
def initialize(*name_and_version_requirements, &block)
if name_and_version_requirements.empty? && block
@inline_podspec = true
@specification = Specification.new(&block)
super(@specification.name, @specification.version)
......@@ -35,17 +36,11 @@ module Pod
(@specification ? @specification == other.specification : @external_spec_source == other.external_spec_source)
end
def external_podspec?
!@external_spec_source.nil?
end
def inline_podspec?
!@specification.nil?
end
# In case this dependency was defined with either a repo url, :podspec, or block,
# this method will return the Specification instance.
def specification
@specification ||= begin
if external_podspec?
if @external_spec_source
pod_root = Config.instance.project_pods_root + @name
spec = nil
if @external_spec_source[:podspec]
......
......@@ -20,6 +20,7 @@ module Pod
executable :git
def download
@pod_root.dirname.mkpath
if @options[:tag]
download_tag
elsif @options[:commit]
......@@ -34,7 +35,7 @@ module Pod
end
def download_tag
@pod_root.mkdir
@pod_root.mkpath
Dir.chdir(@pod_root) do
git "init"
git "remote add origin '#{@url}'"
......
......@@ -23,8 +23,8 @@ module Pod
end
def find_dependency_set(dependency)
if dependency.external_podspec?
Specification::Set::External.new(dependency.specification)
if external_spec = dependency.specification
Specification::Set::External.new(external_spec)
else
Source.search(dependency)
end
......
......@@ -286,8 +286,8 @@ module Pod
# end
def install!
puts "==> Installing: #{self}" unless config.silent?
if defined_in_file && !(config.project_pods_root + defined_in_file.basename).exist?
config.project_pods_root.mkpath
unless (config.project_pods_root + defined_in_file.basename).exist?
FileUtils.cp(defined_in_file, config.project_pods_root)
end
......
......@@ -86,8 +86,32 @@ else
(config.project_pods_root + 'ASIHTTPRequest').should.exist
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
if false
before do
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
end
......@@ -262,3 +286,4 @@ else
end
end
end
......@@ -7,20 +7,6 @@ describe "Pod::Dependency" do
dep1.merge(dep2).should == Pod::Dependency.new('bananas', '>= 1.8', '1.9')
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
dep1 = Pod::Dependency.new('bananas', '>= 1')
dep1.only_part_of_other_pod = true
......
......@@ -23,7 +23,6 @@ describe "Pod::Podfile" do
dependency 'SomeExternalPod', :git => 'GIT-URL', :commit => '1234'
end
dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.external_podspec
dep.external_spec_source.should == { :git => 'GIT-URL', :commit => '1234' }
end
......@@ -32,7 +31,6 @@ describe "Pod::Podfile" do
dependency 'SomeExternalPod', :podspec => 'http://gist/SomeExternalPod.podspec'
end
dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.external_podspec
dep.external_spec_source.should == { :podspec => 'http://gist/SomeExternalPod.podspec' }
end
......@@ -43,7 +41,6 @@ describe "Pod::Podfile" do
end
end
dep = podfile.dependency_by_name('SomeExternalPod')
dep.should.be.inline_podspec
dep.specification.name.should == 'SomeExternalPod'
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