Commit ff706d09 authored by Eloy Duran's avatar Eloy Duran

+ specification specs

parent deb4712c
...@@ -4,8 +4,18 @@ require 'rubygems/dependency' ...@@ -4,8 +4,18 @@ require 'rubygems/dependency'
module Pod module Pod
class Dependency < Gem::Dependency class Dependency < Gem::Dependency
attr_accessor :part_of_other_pod attr_accessor :only_part_of_other_pod
def initialize(name, *version_requirements)
super
@only_part_of_other_pod = false
end
def ==(other)
super && @only_part_of_other_pod == other.only_part_of_other_pod
end
# Taken from a newer version of RubyGems
unless public_method_defined?(:merge) unless public_method_defined?(:merge)
def merge other def merge other
unless name == other.name then unless name == other.name then
......
...@@ -3,17 +3,17 @@ require 'cocoa_pods/specification/set' ...@@ -3,17 +3,17 @@ require 'cocoa_pods/specification/set'
module Pod module Pod
class Specification class Specification
def self.from_podfile(path) def self.from_podfile(path)
if File.exist?(path) if path.exist?
spec = new spec = new
spec.instance_eval(File.read(path)) spec.instance_eval(path.read)
spec.defined_in_file = path spec.defined_in_file = path
spec spec
end end
end end
def self.from_podspec(pathname) def self.from_podspec(path)
spec = eval(File.read(pathname), nil, pathname.to_s) spec = eval(path.read, nil, path.to_s)
spec.defined_in_file = pathname spec.defined_in_file = path
spec spec
end end
...@@ -63,17 +63,16 @@ module Pod ...@@ -63,17 +63,16 @@ module Pod
end end
def part_of(name, *version_requirements) def part_of(name, *version_requirements)
@part_of = dependency(name, *version_requirements) part_of_dependency(name, *version_requirements)
@part_of.part_of_other_pod = true @part_of.only_part_of_other_pod = true
end end
def part_of_dependency(name, *version_requirements) def part_of_dependency(name, *version_requirements)
part_of(name, *version_requirements) @part_of = dependency(name, *version_requirements)
dependency(name, *version_requirements)
end end
def source_files(*patterns) def source_files(*patterns)
@source_files = patterns @source_files = patterns.map { |p| Pathname.new(p) }
end end
def source(remote) def source(remote)
...@@ -103,6 +102,7 @@ module Pod ...@@ -103,6 +102,7 @@ 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
......
...@@ -37,7 +37,7 @@ module Pod ...@@ -37,7 +37,7 @@ module Pod
end end
def only_part_of_other_pod? def only_part_of_other_pod?
@required_by.all? { |_, dep| dep.part_of_other_pod } @required_by.all? { |_, dep| dep.only_part_of_other_pod }
end end
def name def name
......
dependency 'SSZipArchive', '>= 1'
dependency 'ASIHTTPRequest', '~> 1.8.0'
dependency 'Reachability' # part of ASIHTTPRequest
dependency 'ASIWebPageRequest', '< 1.8.2' # part of ASIHTTPRequest
banana-lib @ 0d06750e
Subproject commit f046c1a0fc673a01cf1ce4607c5d1857ce08b44a Subproject commit 0d06750e78e5a6653dc0f66776a257052328c146
...@@ -6,4 +6,13 @@ describe "Pod::Dependency" do ...@@ -6,4 +6,13 @@ describe "Pod::Dependency" do
dep2 = Pod::Dependency.new('bananas', '1.9') dep2 = Pod::Dependency.new('bananas', '1.9')
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 "is equal to another dependency if the `part_of_other_pod' flag is the same" do
dep1 = Pod::Dependency.new('bananas', '>= 1')
dep1.only_part_of_other_pod = true
dep2 = Pod::Dependency.new('bananas', '>= 1')
dep1.should.not == dep2
dep2.only_part_of_other_pod = true
dep1.should == dep2
end
end end
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'))
end
it "lists the project's dependencies" do
@spec.dependencies.should == [
Pod::Dependency.new('SSZipArchive', '>= 1'),
Pod::Dependency.new('ASIHTTPRequest', '~> 1.8.0'),
Pod::Dependency.new('Reachability', '>= 0'),
Pod::Dependency.new('ASIWebPageRequest', ' < 1.8.2')
]
end
it "returns the path to the Podfile" do
@spec.defined_in_file.should == fixture('Podfile')
end
it "returns that it's loaded from a Podfile" do
@spec.should.be.from_podfile
end
it "does not have a destroot" do
@spec.pod_destroot.should == nil
end
end
describe "A Pod::Specification loaded from a podspec" do
before do
@spec = Pod::Specification.from_podspec(fixture('banana-lib/BananaLib.podspec'))
end
it "returns that it's not loaded from a podfile" do
@spec.should.not.be.from_podfile
end
it "returns the path to the podspec" do
@spec.defined_in_file.should == fixture('banana-lib/BananaLib.podspec')
end
it "returns the directory where the pod should be checked out to" do
@spec.pod_destroot.should == config.project_pods_root + 'BananaLib-1.0'
end
it "returns the pod's name" do
@spec.read(:name).should == 'BananaLib'
end
it "returns the pod's version" do
@spec.read(:version).should == Pod::Version.new('1.0')
end
it "returns a list of authors and their email addresses" do
@spec.read(:authors).should == {
'Banana Corp' => nil,
'Monkey Boy' => 'monkey@banana-corp.local'
}
end
it "returns the pod's homepage" do
@spec.read(:homepage).should == 'http://banana-corp.local/banana-lib.html'
end
it "returns the pod's summary" do
@spec.read(:summary).should == 'Chunky bananas!'
end
it "returns the pod's description" do
@spec.read(:description).should == 'Full of chunky bananas.'
end
it "returns the pod's source" do
@spec.read(:source).should == {
:git => 'http://banana-corp.local/banana-lib.git',
:tag => 'v1.0'
}
end
it "returns the pod's source files" do
@spec.read(:source_files).should == [
Pathname.new('Classes/*.{h,m}'),
Pathname.new('Vendor')
]
end
it "returns the pod's dependencies" do
@spec.read(:dependencies).should == [
Pod::Dependency.new('monkey', '~> 1.0.1', '< 1.0.9')
]
end
it "returns the pod's xcconfig settings" do
@spec.read(:xcconfig).should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration'
}
end
end
describe "A Pod::Specification that's part of another pod's source" do
before do
@spec = Pod::Specification.new
end
it "adds a dependency on the other pod's source, but not the library" do
@spec.part_of 'monkey', '>= 1'
@spec.should.be.part_of_other_pod
dep = Pod::Dependency.new('monkey', '>= 1')
@spec.read(:dependencies).should.not == [dep]
dep.only_part_of_other_pod = true
@spec.read(:dependencies).should == [dep]
end
it "adds a dependency on the other pod's source *and* the library" do
@spec.part_of_dependency 'monkey', '>= 1'
@spec.should.be.part_of_other_pod
@spec.read(:dependencies).should == [Pod::Dependency.new('monkey', '>= 1')]
end
# TODO
#it "returns the specification of the pod that it's part of" do
# @spec.part_of_specification
#end
#
#it "returns the destroot of the pod that it's part of" do
# @spec.pod_destroot
#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