Commit 6f2f1499 authored by Eloy Duran's avatar Eloy Duran

Add Pod::File which is a subclass of Pod::Specification, but meant for a Podfile.

parent 26641970
...@@ -30,13 +30,13 @@ module Pod ...@@ -30,13 +30,13 @@ module Pod
spec = nil spec = nil
if @podspec if @podspec
if @podspec.exist? if @podspec.exist?
spec = Specification.from_podspec(@podspec) spec = Specification.from_file(@podspec)
else else
raise Informative, "The specified podspec `#{@podspec}' doesn't exist." raise Informative, "The specified podspec `#{@podspec}' doesn't exist."
end end
else else
if config.project_podfile if config.project_podfile
spec = Specification.from_podfile(config.project_podfile) spec = Specification.from_file(config.project_podfile)
else else
raise Informative, "No `Podfile' or `.podspec' file found in the current working directory." raise Informative, "No `Podfile' or `.podspec' file found in the current working directory."
end end
......
...@@ -55,7 +55,7 @@ module Pod ...@@ -55,7 +55,7 @@ module Pod
def lint def lint
file = @name ? Pathname.new(@name) : Pathname.pwd.glob('*.podspec').first file = @name ? Pathname.new(@name) : Pathname.pwd.glob('*.podspec').first
spec = Specification.from_podspec(file) spec = Specification.from_file(file)
spec.validate! spec.validate!
end end
end end
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
alias_method :silent?, :silent alias_method :silent?, :silent
def initialize def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods")) @repos_dir = Pathname.new(::File.expand_path("~/.cocoapods"))
@clean = true @clean = true
@verbose = false @verbose = false
@silent = false @silent = false
......
...@@ -6,16 +6,8 @@ module Pod ...@@ -6,16 +6,8 @@ module Pod
class Specification class Specification
autoload :Set, 'cocoapods/specification/set' autoload :Set, 'cocoapods/specification/set'
def self.from_podfile(path) # The file is expected to define and return either a Pods::Specification or a Pod::File.
if path.exist? def self.from_file(path)
spec = new
spec.instance_eval(path.read)
spec.defined_in_file = path
spec
end
end
def self.from_podspec(path)
spec = Pod._eval_podspec(path) spec = Pod._eval_podspec(path)
spec.defined_in_file = path spec.defined_in_file = path
spec spec
...@@ -143,7 +135,6 @@ module Pod ...@@ -143,7 +135,6 @@ module Pod
end end
def pod_destroot def pod_destroot
return if from_podfile?
if part_of_other_pod? if part_of_other_pod?
part_of_specification.pod_destroot part_of_specification.pod_destroot
else else
...@@ -161,8 +152,8 @@ module Pod ...@@ -161,8 +152,8 @@ module Pod
!@part_of.nil? !@part_of.nil?
end end
def from_podfile? def podfile?
@name.nil? && @version.nil? false
end end
def any_platform? def any_platform?
...@@ -221,11 +212,7 @@ module Pod ...@@ -221,11 +212,7 @@ module Pod
end end
def to_s def to_s
if from_podfile? "`#{@name}' version `#{@version}'"
"podfile at `#{@defined_in_file}'"
else
"`#{@name}' version `#{@version}'"
end
end end
def inspect def inspect
...@@ -310,4 +297,18 @@ module Pod ...@@ -310,4 +297,18 @@ module Pod
end end
Spec = Specification Spec = Specification
class File < Specification
def podfile?
true
end
def to_s
"podfile at `#{@defined_in_file}'"
end
def pod_destroot
# A Podfile has none
end
end
end end
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
end end
def specification def specification
Specification.from_podspec(specification_path) Specification.from_file(specification_path)
end end
# Return the first version that matches the current dependency. # Return the first version that matches the current dependency.
......
...@@ -219,9 +219,9 @@ module Pod ...@@ -219,9 +219,9 @@ module Pod
# TODO this is a workaround for an issue with MacRuby with compiled files # TODO this is a workaround for an issue with MacRuby with compiled files
# that makes the use of __FILE__ impossible. # that makes the use of __FILE__ impossible.
# #
#TEMPLATES_DIR = Pathname.new(File.expand_path('../../../../xcode-project-templates', __FILE__)) #TEMPLATES_DIR = Pathname.new(::File.expand_path('../../../../xcode-project-templates', __FILE__))
file = $LOADED_FEATURES.find { |file| file =~ %r{cocoapods/xcode/project\.rbo?$} } file = $LOADED_FEATURES.find { |file| file =~ %r{cocoapods/xcode/project\.rbo?$} }
TEMPLATES_DIR = Pathname.new(File.expand_path('../../../../xcode-project-templates', file)) TEMPLATES_DIR = Pathname.new(::File.expand_path('../../../../xcode-project-templates', file))
# TODO see if we really need different templates for iOS and OS X # TODO see if we really need different templates for iOS and OS X
def self.ios_static_library def self.ios_static_library
......
dependency 'SSZipArchive', '>= 1' Pod::File.new do |f|
dependency 'ASIHTTPRequest', '~> 1.8.0' f.platform = :ios
dependency 'Reachability' # part of ASIHTTPRequest f.dependency 'SSZipArchive', '>= 1'
dependency 'ASIWebPageRequest', '< 1.8.2' # part of ASIHTTPRequest f.dependency 'ASIHTTPRequest', '~> 1.8.0'
f.dependency 'Reachability' # part of ASIHTTPRequest
f.dependency 'ASIWebPageRequest', '< 1.8.2' # part of ASIHTTPRequest
end
...@@ -43,7 +43,7 @@ describe "Pod::Command" do ...@@ -43,7 +43,7 @@ describe "Pod::Command" do
command('spec', 'create', 'Bananas') command('spec', 'create', 'Bananas')
end end
path = temporary_directory + 'Bananas.podspec' path = temporary_directory + 'Bananas.podspec'
spec = Pod::Specification.from_podspec(path) spec = Pod::Specification.from_file(path)
spec.name.should == 'Bananas' spec.name.should == 'Bananas'
spec.version.should == Pod::Version.new('1.0.0') spec.version.should == Pod::Version.new('1.0.0')
spec.summary.should == 'A short description of Bananas.' spec.summary.should == 'A short description of Bananas.'
......
...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "A Pod::Specification loaded from a Podfile" do describe "A Pod::Specification loaded from a Podfile" do
before do before do
@spec = Pod::Specification.from_podfile(fixture('Podfile')) @spec = Pod::Specification.from_file(fixture('Podfile'))
end end
it "lists the project's dependencies" do it "lists the project's dependencies" do
...@@ -19,7 +19,7 @@ describe "A Pod::Specification loaded from a Podfile" do ...@@ -19,7 +19,7 @@ describe "A Pod::Specification loaded from a Podfile" do
end end
it "returns that it's loaded from a Podfile" do it "returns that it's loaded from a Podfile" do
@spec.should.be.from_podfile @spec.should.be.podfile
end end
it "does not have a destroot" do it "does not have a destroot" do
...@@ -29,11 +29,11 @@ end ...@@ -29,11 +29,11 @@ end
describe "A Pod::Specification loaded from a podspec" do describe "A Pod::Specification loaded from a podspec" do
before do before do
@spec = Pod::Specification.from_podspec(fixture('banana-lib/BananaLib.podspec')) @spec = Pod::Specification.from_file(fixture('banana-lib/BananaLib.podspec'))
end end
it "returns that it's not loaded from a podfile" do it "returns that it's not loaded from a podfile" do
@spec.should.not.be.from_podfile @spec.should.not.be.podfile
end end
it "returns the path to the podspec" do it "returns the path to the podspec" do
...@@ -169,7 +169,7 @@ describe "A Pod::Specification, with installed source," do ...@@ -169,7 +169,7 @@ describe "A Pod::Specification, with installed source," do
before do before do
config.project_pods_root = fixture('integration') config.project_pods_root = fixture('integration')
podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec') podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec')
@spec = Pod::Specification.from_podspec(podspec) @spec = Pod::Specification.from_file(podspec)
@destroot = fixture('integration/SSZipArchive') @destroot = fixture('integration/SSZipArchive')
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