Commit ece1c9fd authored by Eloy Duran's avatar Eloy Duran

The `source_files`, `resources`, and `clean_paths` attributes can take…

The `source_files`, `resources`, and `clean_paths` attributes can take Rake::FileList instances too.
parent dcdc3af2
......@@ -3,7 +3,7 @@ platform :ios
dependency 'AFNetworking'
# From a spec repo
#dependency 'SSToolkit'
dependency 'SSToolkit'
# Directly from the Pod’s repo
#dependency 'SSToolkit', :git => 'https://github.com/samsoffes/sstoolkit.git'
......@@ -16,19 +16,19 @@ dependency 'AFNetworking'
#dependency 'SSToolkit', :podspec => 'https://raw.github.com/gist/1353347/ef1800da9c5f5d267a642b8d3950b41174f2a6d7/SSToolkit-0.1.1.podspec'
# If no podspec is available anywhere, you can define one right in your Podfile
dependency do |s|
s.name = 'SSToolkit'
s.version = '0.1.3'
s.platform = :ios
s.source = { :git => 'https://github.com/samsoffes/sstoolkit.git', :commit => '2adcd0f81740d6b0cd4589af98790eee3bd1ae7b' }
s.resources = 'Resources'
s.source_files = 'SSToolkit/**/*.{h,m}'
s.frameworks = 'QuartzCore', 'CoreGraphics'
#dependency do |s|
#s.name = 'SSToolkit'
#s.version = '0.1.3'
#s.platform = :ios
#s.source = { :git => 'https://github.com/samsoffes/sstoolkit.git', :commit => '2adcd0f81740d6b0cd4589af98790eee3bd1ae7b' }
#s.resources = 'Resources/SSToolkit.bundle'
#s.source_files = 'SSToolkit/**/*.{h,m}'
#s.frameworks = 'QuartzCore', 'CoreGraphics'
def s.post_install(target)
prefix_header = config.project_pods_root + target.prefix_header_filename
prefix_header.open('a') do |file|
file.puts(%{#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif})
end
end
end
#def s.post_install(target)
#prefix_header = config.project_pods_root + target.prefix_header_filename
#prefix_header.open('a') do |file|
#file.puts(%{#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif})
#end
#end
#end
......@@ -2,8 +2,8 @@ PODS:
- AFNetworking (0.7.0):
- JSONKit
- JSONKit (1.4)
- SSToolkit (0.1.3)
- SSToolkit (0.1.2)
DEPENDENCIES:
- AFNetworking
- SSToolkit (defined in Podfile)
- SSToolkit
Subproject commit e2ab8c76e891241612535acd114eb82d6be5815e
Subproject commit ca3fe8f63cdaddbdf6a465e6352c7ca6501ee164
......@@ -54,11 +54,8 @@ module Pod
def clean(clean_paths = [])
(@pod_root + '.git').rmtree
clean_paths.each do |pattern|
pattern = @pod_root + pattern
pattern.glob.each do |path|
path.rmtree
end
clean_paths.each do |path|
path.rmtree
end if clean_paths
end
end
......
require 'rake'
module Rake
class FileList
def prepend_patterns(pathname)
@pending_add.map! { |pattern| (pathname + pattern).to_s }
end
# This makes Rake::FileList usable with source_files and clean_paths.
def directory?
false
end
def glob
to_a.map { |path| Pathname.new(path) }
end
end
end
class Pathname
alias_method :_original_sum, :+
def +(other)
if other.is_a?(Rake::FileList)
other.prepend_patterns(self)
other
else
_original_sum(other)
end
end
end
module Pod
extend Config::Mixin
......@@ -21,7 +52,7 @@ module Pod
attr_accessor :defined_in_file
def initialize
@dependencies = []
@dependencies, @resources, @clean_paths = [], [], []
@xcconfig = Xcodeproj::Config.new
yield self if block_given?
end
......@@ -67,21 +98,34 @@ module Pod
@part_of = dependency(*name_and_version_requirements)
end
def source_files=(*patterns)
@source_files = patterns.flatten
def source_files=(patterns)
if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
@source_files = patterns
else
@source_files = [patterns]
end
end
attr_reader :source_files
def resources=(*patterns)
@resources = patterns.flatten
def resources=(patterns)
if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
@resources = patterns
else
@resources = [patterns]
end
end
attr_reader :resources
alias_method :resource=, :resources=
def clean_paths=(*patterns)
@clean_paths = patterns.flatten.map { |p| Pathname.new(p) }
def clean_paths=(patterns)
if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
@clean_paths = patterns
else
@clean_paths = [patterns]
end
end
attr_reader :clean_paths
alias_method :clean_path=, :clean_paths=
def xcconfig=(hash)
@xcconfig.merge!(hash)
......@@ -182,9 +226,8 @@ module Pod
# project pods root.
def expanded_resources
files = []
[*resources].each do |pattern|
resources.each do |pattern|
pattern = pod_destroot + pattern
pattern = pattern + '*' if pattern.directory?
pattern.glob.each do |file|
files << file.relative_path_from(config.project_pods_root)
end
......@@ -192,11 +235,27 @@ module Pod
files
end
# Returns full paths to clean for this pod.
def expanded_clean_paths
files = []
clean_paths.each do |pattern|
pattern = pod_destroot + pattern
pattern.glob.each do |file|
files << file
end
end
files
end
# Returns all source files of this pod including header files,
# but relative to the project pods root.
#
# If the pattern is the path to a directory, the pattern will
# automatically glob for c, c++, Objective-C, and Objective-C++
# files.
def expanded_source_files
files = []
[*source_files].each do |pattern|
source_files.each do |pattern|
pattern = pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file|
......@@ -320,7 +379,7 @@ module Pod
def download!
downloader = Downloader.for_source(pod_destroot, source)
downloader.download
downloader.clean(clean_paths) if config.clean
downloader.clean(expanded_clean_paths) if config.clean
end
# This is a convenience method which gets called after all pods have been
......
......@@ -140,7 +140,6 @@ else
end.should == %w{ supported supported }
end
if false
# TODO add a simple source file which uses the compiled lib to check that it really really works
it "should activate required pods and create a working static library xcode project" do
spec = Pod::Podfile.new do
......@@ -328,4 +327,3 @@ if false
end
end
end
......@@ -266,4 +266,16 @@ describe "A Pod::Specification, in general," do
@spec.license = 'MIT'
@spec.license.should == 'MIT'
end
it "takes a list of paths to clean" do
@spec.clean_paths = 'Demo', 'Doc'
@spec.clean_paths.should == %w{ Demo Doc }
end
it "takes any object for clean_paths as long as it responds to #glob (we provide this for Rake::FileList)" do
require 'rake'
@spec.clean_paths = FileList['*'].exclude('Rakefile')
list = ROOT + @spec.clean_paths.first
list.glob.should == FileList[(ROOT + '*').to_s].exclude('Rakefile').map { |path| Pathname.new(path) }
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