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