Commit bb774bd4 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' into git-cache

* master:
  [Command::Spec::Linter] fix for #podspec_warnings.
  [Command::Spec] Template layout fix.
  [Platform] Removed options accessor.
  [Executable] Made executed command more prominent.
  Spelling correctioSpelling correctionn
  [Resolver] Support for deployment target check.
  [Specification#deployment_target=] Switch to Pod::Version
  [Platform#==] Check for deployment target.
  [Platform] Simplify deployment target specification.
  [#212] Check for deployment target
parents d1788235 43d8dc6f
...@@ -316,9 +316,9 @@ module Pod ...@@ -316,9 +316,9 @@ module Pod
messages << "Missing license[:file] or [:text]" unless license[:file] || license[:text] messages << "Missing license[:file] or [:text]" unless license[:file] || license[:text]
messages << "The summary should end with a dot" if @spec.summary !~ /.*\./ messages << "The summary should end with a dot" if @spec.summary !~ /.*\./
messages << "The description should end with a dot" if @spec.description !~ /.*\./ && @spec.description != @spec.summary messages << "The description should end with a dot" if @spec.description !~ /.*\./ && @spec.description != @spec.summary
messages << "Git sources should specify either a tag or a commit" if source[:git] && ( !source[:commit] || !source[:tag] ) messages << "Git sources should specify either a tag or a commit" if source[:git] && !source[:commit] && !source[:tag]
messages << "Github repositories should end in `.git'" if github_source? && source[:git] !~ /.*\.git/ messages << "Github repositories should end in `.git'" if github_source? && source[:git] !~ /.*\.git/
messages << "Github repositories should start with `https'" if github_source? && source[:git] !~ /https:\/\/github.com/ messages << "Github repositories should use `https' link" if github_source? && source[:git] !~ /https:\/\/github.com/
messages << "Comments must be deleted" if text =~ /^\w*#\n\w*#/ # allow a single line comment as it is generally used in subspecs messages << "Comments must be deleted" if text =~ /^\w*#\n\w*#/ # allow a single line comment as it is generally used in subspecs
messages messages
end end
...@@ -532,16 +532,17 @@ Pod::Spec.new do |s| ...@@ -532,16 +532,17 @@ Pod::Spec.new do |s|
s.description = 'An optional longer description of #{data[:name]}.' s.description = 'An optional longer description of #{data[:name]}.'
# If this Pod runs only on iOS or OS X, then specify that with one of # If this Pod runs only on iOS or OS X, then specify the platform and
# these, or none if it runs on both platforms. # the deployment target.
# If the pod runs on both plafroms but presents different deployment
# targets, source files, etc. create two different pods: `#{data[:name]}-iOS'
# and `#{data[:name]}-OSX'.
# #
# s.platform = :ios, '5.0'
# s.platform = :ios # s.platform = :ios
# s.platform = :ios, { :deployment_target => "5.0" }
# s.platform = :osx # If this Pod runs on boths platforms, then specify the deployment
# s.platform = :osx, { :deployment_target => "10.7" } # targets.
#
# s.ios.deployment_target = '5.0'
# s.osx.deployment_target = '10.7'
# A list of resources included with the Pod. These are copied into the # A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. # target bundle with a build phase script.
...@@ -589,6 +590,7 @@ Pod::Spec.new do |s| ...@@ -589,6 +590,7 @@ Pod::Spec.new do |s|
# #
# s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' } # s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
# ――― INFO ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
end end
SPEC SPEC
end end
...@@ -596,7 +598,7 @@ Pod::Spec.new do |s| ...@@ -596,7 +598,7 @@ Pod::Spec.new do |s|
def semantic_versioning_notice(repo_id, repo) def semantic_versioning_notice(repo_id, repo)
return <<-EOS return <<-EOS
#{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed} #{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
I’ve recently added [#{repo}](https://github.com/CocoaPods/Specs/tree/master/#{repo}) to the [CocoaPods](https://github.com/CocoaPods/CocoaPods) package manager repo. I’ve recently added [#{repo}](https://github.com/CocoaPods/Specs/tree/master/#{repo}) to the [CocoaPods](https://github.com/CocoaPods/CocoaPods) package manager repo.
...@@ -613,9 +615,9 @@ $ git tag -a 1.0.0 -m "Tag release 1.0.0" ...@@ -613,9 +615,9 @@ $ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags $ git push --tags
``` ```
#{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed} #{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
#{'[!] This repo does not appear to have semantic version tags.'.yellow} #{'[!] This repo does not appear to have semantic version tags.'.yellow}
After commiting the specification, consider opening a ticket with the template displayed above: After commiting the specification, consider opening a ticket with the template displayed above:
- link: https://github.com/#{repo_id}/issues/new - link: https://github.com/#{repo_id}/issues/new
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
raise Informative, "Unable to locate the executable `#{name}'" raise Informative, "Unable to locate the executable `#{name}'"
end end
if Config.instance.verbose? if Config.instance.verbose?
puts "#{bin} #{command}" puts "-> #{bin} #{command}"
`#{bin} #{command} 1>&2` `#{bin} #{command} 1>&2`
else else
`#{bin} #{command} 2> /dev/null` `#{bin} #{command} 2> /dev/null`
......
...@@ -8,22 +8,29 @@ module Pod ...@@ -8,22 +8,29 @@ module Pod
new :osx new :osx
end end
attr_reader :options attr_reader :deployment_target
def initialize(symbolic_name, options = {}) def initialize(symbolic_name, deployment_target = nil)
@symbolic_name = symbolic_name @symbolic_name = symbolic_name
@options = options if deployment_target
version = deployment_target.is_a?(Hash) ? deployment_target[:deployment_target] : deployment_target # backwards compatibility from 0.6
@deployment_target = Pod::Version.create(version)
end
end end
def name def name
@symbolic_name @symbolic_name
end end
def deployment_target= (version)
@deployment_target = Pod::Version.create(version)
end
def ==(other_platform_or_symbolic_name) def ==(other_platform_or_symbolic_name)
if other_platform_or_symbolic_name.is_a?(Symbol) if other_platform_or_symbolic_name.is_a?(Symbol)
@symbolic_name == other_platform_or_symbolic_name @symbolic_name == other_platform_or_symbolic_name
else else
self == (other_platform_or_symbolic_name.name) self.name == (other_platform_or_symbolic_name.name) && self.deployment_target == other_platform_or_symbolic_name.deployment_target
end end
end end
...@@ -51,12 +58,6 @@ module Pod ...@@ -51,12 +58,6 @@ module Pod
name.nil? name.nil?
end end
def deployment_target
if (options && opt = options[:deployment_target])
Pod::Version.new(opt)
end
end
def requires_legacy_ios_archs? def requires_legacy_ios_archs?
return unless deployment_target return unless deployment_target
(name == :ios) && (deployment_target < Pod::Version.new("4.3")) (name == :ios) && (deployment_target < Pod::Version.new("4.3"))
......
...@@ -84,8 +84,8 @@ module Pod ...@@ -84,8 +84,8 @@ module Pod
end end
def validate_platform!(spec, target) def validate_platform!(spec, target)
unless target.platform.support?(spec.platform) unless spec.platforms.any? { |platform| target.platform.support?(platform) }
raise Informative, "[!] The platform required by the target `#{target.name}' `#{target.platform}' does not match that of #{spec} `#{spec.platform}'".red raise Informative, "[!] The platform of the target `#{target.name}' (#{target.platform}) is not compatible with `#{spec}' which has a minimun requirement of #{spec.platforms.join(' - ')}.".red
end end
end end
end end
......
...@@ -34,6 +34,7 @@ module Pod ...@@ -34,6 +34,7 @@ module Pod
@define_for_platforms = [:osx, :ios] @define_for_platforms = [:osx, :ios]
@clean_paths, @subspecs = [], [] @clean_paths, @subspecs = [], []
@dependencies, @source_files, @resources = { :ios => [], :osx => [] }, { :ios => [], :osx => [] }, { :ios => [], :osx => [] } @dependencies, @source_files, @resources = { :ios => [], :osx => [] }, { :ios => [], :osx => [] }, { :ios => [], :osx => [] }
@deployment_target = {}
@platform = Platform.new(nil) @platform = Platform.new(nil)
@xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new } @xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new }
@compiler_flags = { :ios => '', :osx => '' } @compiler_flags = { :ios => '', :osx => '' }
...@@ -114,17 +115,14 @@ module Pod ...@@ -114,17 +115,14 @@ module Pod
end end
def platform=(platform) def platform=(platform)
if platform.class == Array @platform = Platform.new(*platform)
name = platform[0]
options = platform[1]
else
name = platform
options = nil
end
@platform = Platform.new(name, options)
end end
attr_reader :platform attr_reader :platform
def platforms
@platform.nil? ? @define_for_platforms.map { |platfrom| Platform.new(platfrom, @deployment_target[platfrom]) } : [platform]
end
def requires_arc=(requires_arc) def requires_arc=(requires_arc)
self.compiler_flags = '-fobjc-arc' if requires_arc self.compiler_flags = '-fobjc-arc' if requires_arc
@requires_arc = requires_arc @requires_arc = requires_arc
...@@ -157,7 +155,7 @@ module Pod ...@@ -157,7 +155,7 @@ module Pod
@specification, @platform = specification, platform @specification, @platform = specification, platform
end end
%w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= dependency }.each do |method| %w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= deployment_target= dependency }.each do |method|
define_method(method) do |args| define_method(method) do |args|
@specification._on_platform(@platform) do @specification._on_platform(@platform) do
@specification.send(method, args) @specification.send(method, args)
...@@ -181,6 +179,11 @@ module Pod ...@@ -181,6 +179,11 @@ module Pod
end end
attr_reader :source_files attr_reader :source_files
def deployment_target=(version)
raise Informative, "The deployment target must be defined per platform like s.ios.deployment_target = '5.0'" unless @define_for_platforms.count == 1
@deployment_target[@define_for_platforms.first] = version
end
def resources=(patterns) def resources=(patterns)
@define_for_platforms.each do |platform| @define_for_platforms.each do |platform|
@resources[platform] = pattern_list(patterns) @resources[platform] = pattern_list(patterns)
......
...@@ -18,6 +18,11 @@ describe Pod::Platform do ...@@ -18,6 +18,11 @@ describe Pod::Platform do
@platform.should == Pod::Platform.new(:ios) @platform.should == Pod::Platform.new(:ios)
end end
it "can be compared for equality with another platform with the same symbolic name and the same deployment target" do
@platform.should.not == Pod::Platform.new(:ios, '4.0')
Pod::Platform.new(:ios, '4.0').should == Pod::Platform.new(:ios, '4.0')
end
it "can be compared for equality with a matching symbolic name (backwards compatibility reasons)" do it "can be compared for equality with a matching symbolic name (backwards compatibility reasons)" do
@platform.should == :ios @platform.should == :ios
end end
...@@ -26,28 +31,31 @@ describe Pod::Platform do ...@@ -26,28 +31,31 @@ describe Pod::Platform do
@platform.to_s.should == "iOS" @platform.to_s.should == "iOS"
Pod::Platform.new(:osx).to_s.should == 'OS X' Pod::Platform.new(:osx).to_s.should == 'OS X'
Pod::Platform.new(nil).to_s.should == "iOS - OS X" Pod::Platform.new(nil).to_s.should == "iOS - OS X"
Pod::Platform.new(:ios, { :deployment_target => '5.0.0' }).to_s.should == 'iOS 5.0.0' Pod::Platform.new(:ios, '5.0.0').to_s.should == 'iOS 5.0.0'
Pod::Platform.new(:osx, { :deployment_target => '10.7' }).to_s.should == 'OS X 10.7' Pod::Platform.new(:osx, '10.7').to_s.should == 'OS X 10.7'
end
it "correctly indicates if it supports another platfrom" do
ios4 = Pod::Platform.new(:ios, { :deployment_target => '4.0.0' })
ios5 = Pod::Platform.new(:ios, { :deployment_target => '5.0.0' })
ios5.should.support?(ios4)
ios4.should.not.support?(ios5)
osx6 = Pod::Platform.new(:osx, { :deployment_target => '10.6' })
osx7 = Pod::Platform.new(:osx, { :deployment_target => '10.7' })
osx7.should.support?(osx6)
osx6.should.not.support?(osx7)
both = Pod::Platform.new(nil)
both.should.support?(ios4)
both.should.support?(osx6)
both.should.support?(nil)
end end
it "uses it's name as it's symbold version" do it "uses it's name as it's symbold version" do
@platform.to_sym.should == :ios @platform.to_sym.should == :ios
end end
it "allows to specify the deployment target on initialization" do
p = Pod::Platform.new(:ios, '4.0.0')
p.deployment_target.should == Pod::Version.new('4.0.0')
end
it "allows to specify the deployment target in a hash on initialization (backwards compatibility from 0.6)" do
p = Pod::Platform.new(:ios, { :deployment_target => '4.0.0' })
p.deployment_target.should == Pod::Version.new('4.0.0')
end
it "allows to specify the deployment target after initialization" do
p = Pod::Platform.new(:ios, '4.0.0')
p.deployment_target = '4.0.0'
p.deployment_target.should == Pod::Version.new('4.0.0')
p.deployment_target = Pod::Version.new('4.0.0')
p.deployment_target.should == Pod::Version.new('4.0.0')
end
end end
describe "Pod::Platform with a nil value" do describe "Pod::Platform with a nil value" do
...@@ -59,3 +67,35 @@ describe "Pod::Platform with a nil value" do ...@@ -59,3 +67,35 @@ describe "Pod::Platform with a nil value" do
@platform.should.be.nil @platform.should.be.nil
end end
end end
describe "Pod::Platform#support?" do
it "supports another platform is with the same operating system" do
p1 = Pod::Platform.new(:ios)
p2 = Pod::Platform.new(:ios)
p1.should.support?(p2)
p1 = Pod::Platform.new(:osx)
p2 = Pod::Platform.new(:osx)
p1.should.support?(p2)
end
it "supports a nil platform" do
p1 = Pod::Platform.new(:ios)
p1.should.support?(nil)
end
it "supports a platform with a lower or equal deployment_target" do
p1 = Pod::Platform.new(:ios, '5.0')
p2 = Pod::Platform.new(:ios, '4.0')
p1.should.support?(p1)
p1.should.support?(p2)
p2.should.not.support?(p1)
end
it "supports a platform regardless of the deployment_target if one of the two does not specify it" do
p1 = Pod::Platform.new(:ios)
p2 = Pod::Platform.new(:ios, '4.0')
p1.should.support?(p2)
p2.should.support?(p1)
end
end
...@@ -39,7 +39,7 @@ describe "Pod::Resolver" do ...@@ -39,7 +39,7 @@ describe "Pod::Resolver" do
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
end end
it "raises once any of the dependencies does not match the platform of the root spec (Podfile)" do it "raises once any of the dependencies does not match the platform of its podfile target" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest') set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest')
@resolver.cached_sets['ASIHTTPRequest'] = set @resolver.cached_sets['ASIHTTPRequest'] = set
...@@ -59,27 +59,15 @@ describe "Pod::Resolver" do ...@@ -59,27 +59,15 @@ describe "Pod::Resolver" do
lambda { @resolver.resolve }.should.raise Pod::Informative lambda { @resolver.resolve }.should.raise Pod::Informative
end end
it "does not raise if all of the dependencies have a deployment target equal or lower of the root spec (Podfile)" do it "raises once any of the dependencies does not have a deployment_target compatible with its podfile target" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest') set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest')
@resolver.cached_sets['ASIHTTPRequest'] = set @resolver.cached_sets['ASIHTTPRequest'] = set
@podfile.platform :ios, "4.0"
def set.stub_platform=(platform); @stubbed_platform = platform; end Pod::Specification.any_instance.stubs(:platforms).returns([ Pod::Platform.new(:ios, '4.0'), Pod::Platform.new(:osx, '10.7') ])
def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end
@podfile.platform :ios, { :deployment_target => "4.0.0" }
set.stub_platform = :ios, { :deployment_target => "4.0.0" }
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
end
it "raises once any of the dependencies requires a higher deployment target of the root spec (Podfile)" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest')
@resolver.cached_sets['ASIHTTPRequest'] = set
def set.stub_platform=(platform); @stubbed_platform = platform; end
def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end
@podfile.platform :ios, { :deployment_target => "4.0.0" } Pod::Specification.any_instance.stubs(:platforms).returns([ Pod::Platform.new(:ios, '5.0'), Pod::Platform.new(:osx, '10.7') ])
set.stub_platform = :ios, { :deployment_target => "5.0.0" }
lambda { @resolver.resolve }.should.raise Pod::Informative lambda { @resolver.resolve }.should.raise Pod::Informative
end end
......
...@@ -154,6 +154,19 @@ describe "A Pod::Specification, in general," do ...@@ -154,6 +154,19 @@ describe "A Pod::Specification, in general," do
@spec.platform.should == :ios @spec.platform.should == :ios
end end
it "returns the platform and the deployment target" do
@spec.platform = :ios, '4.0'
@spec.platform.should == :ios
@spec.platform.deployment_target.should == Pod::Version.new('4.0')
end
it "returns the platfroms for which the pod is supported" do
@spec.platform = :ios, '4.0'
@spec.platforms.count.should == 1
@spec.platforms.first.should == :ios
@spec.platforms.first.deployment_target.should == Pod::Version.new('4.0')
end
it "returns the license of the Pod" do it "returns the license of the Pod" do
@spec.license = { @spec.license = {
:type => 'MIT', :type => 'MIT',
...@@ -364,6 +377,8 @@ describe "A Pod::Specification, concerning its attributes that support different ...@@ -364,6 +377,8 @@ describe "A Pod::Specification, concerning its attributes that support different
s.ios.dependency 'JSONKit' s.ios.dependency 'JSONKit'
s.osx.dependency 'SSZipArchive' s.osx.dependency 'SSZipArchive'
s.ios.deployment_target = '4.0'
end end
end end
...@@ -382,6 +397,12 @@ describe "A Pod::Specification, concerning its attributes that support different ...@@ -382,6 +397,12 @@ describe "A Pod::Specification, concerning its attributes that support different
} }
end end
it "returns the list of the supported platfroms and deployment targets" do
@spec.platforms.count.should == 2
@spec.platforms.should.include? Pod::Platform.new(:osx)
@spec.platforms.should.include? Pod::Platform.new(:ios, '4.0')
end
it "returns the same list of compiler flags for each platform" do it "returns the same list of compiler flags for each platform" do
@spec.compiler_flags.should == { @spec.compiler_flags.should == {
:ios => ' -Wdeprecated-implementations -fobjc-arc', :ios => ' -Wdeprecated-implementations -fobjc-arc',
......
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