Commit e91db0ae authored by Eloy Duran's avatar Eloy Duran

Add shortcuts to the spec for frameworks and libraries. Closes #5.

parent 08c29794
......@@ -21,7 +21,7 @@ module Pod
def initialize(&block)
@dependencies = []
@xcconfig = {}
@xcconfig = Xcode::Config.new
instance_eval(&block) if block_given?
end
......@@ -87,9 +87,21 @@ module Pod
end
def xcconfig(hash)
@xcconfig = hash
@xcconfig.merge!(hash)
end
def frameworks(*frameworks)
frameworks.unshift('')
xcconfig 'OTHER_LDFLAGS' => frameworks.join(' -framework ').strip
end
alias_method :framework, :frameworks
def libraries(*libraries)
libraries.unshift('')
xcconfig 'OTHER_LDFLAGS' => libraries.join(' -l ').strip
end
alias_method :library, :libraries
# Not attributes
include Config::Mixin
......
module Pod
module Xcode
class Config
def initialize(xcconfig_hash = {})
def initialize(xcconfig = {})
@attributes = {}
merge!(xcconfig_hash)
merge!(xcconfig)
end
def to_hash
@attributes
end
def merge!(xcconfig_hash)
xcconfig_hash.each do |key, value|
def merge!(xcconfig)
xcconfig.to_hash.each do |key, value|
if existing_value = @attributes[key]
@attributes[key] = "#{existing_value} #{value}"
else
......
......@@ -52,7 +52,7 @@ describe "Pod::Command" do
spec.read(:source).should == { :git => 'http://example.com/Bananas.git', :tag => '1.0.0' }
spec.read(:description).should == 'An optional longer description of Bananas.'
spec.read(:source_files).should == [Pathname.new('Classes'), Pathname.new('Classes/**/*.{h,m}')]
spec.read(:xcconfig).should == { 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework' }
spec.read(:xcconfig).to_hash.should == { 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework' }
spec.read(:dependencies).should == [Pod::Dependency.new('SomeLibraryThatBananasDependsOn', '>= 1.0.0')]
end
......
......@@ -92,11 +92,27 @@ describe "A Pod::Specification loaded from a podspec" do
end
it "returns the pod's xcconfig settings" do
@spec.read(:xcconfig).should == {
@spec.read(:xcconfig).to_hash.should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration'
}
end
it "has a shortcut to add frameworks to the xcconfig" do
@spec.frameworks('CFNetwork', 'CoreText')
@spec.read(:xcconfig).to_hash.should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration ' \
'-framework CFNetwork ' \
'-framework CoreText'
}
end
it "has a shortcut to add libraries to the xcconfig" do
@spec.libraries('z', 'xml2')
@spec.read(:xcconfig).to_hash.should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration -l z -l xml2'
}
end
it "returns that it's equal to another specification if the name and version are equal" do
@spec.should == Pod::Spec.new { name 'BananaLib'; version '1.0' }
@spec.should.not == Pod::Spec.new { name 'OrangeLib'; version '1.0' }
......
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