Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow the use of the Rake FileList class for source_files, clean_path…

…s, and resources. Fixes #65.
  • Loading branch information...
commit 7d9479c1b0bf963b858c7da226433352a5351604 1 parent ece1c9f
@alloy alloy authored
View
1  Rakefile
@@ -81,6 +81,7 @@ namespace :examples do
require 'pathname'
result = []
examples = Pathname.new(File.expand_path('../examples', __FILE__))
+ return [examples + ENV['example']] if ENV['example']
examples.entries.each do |example|
next if %w{ . .. }.include?(example.basename.to_s)
example = examples + example
View
1  lib/cocoapods.rb
@@ -19,6 +19,7 @@ class Informative < StandardError
autoload :Version, 'cocoapods/version'
autoload :Pathname, 'pathname'
+ autoload :FileList, 'cocoapods/file_list'
end
module Xcodeproj
View
34 lib/cocoapods/file_list.rb
@@ -0,0 +1,34 @@
+require 'rake'
+
+# This makes Rake::FileList usable with the Specification attributes
+# source_files, clean_paths, and resources.
+
+module Rake
+ class FileList
+ def prepend_patterns(pathname)
+ @pending_add.map! { |pattern| (pathname + pattern).to_s }
+ end
+
+ 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
+
+
View
57 lib/cocoapods/specification.rb
@@ -1,34 +1,3 @@
-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
@@ -99,30 +68,18 @@ def part_of_dependency=(*name_and_version_requirements)
end
def source_files=(patterns)
- if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
- @source_files = patterns
- else
- @source_files = [patterns]
- end
+ @source_files = pattern_list(patterns)
end
attr_reader :source_files
def resources=(patterns)
- if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
- @resources = patterns
- else
- @resources = [patterns]
- end
+ @resources = pattern_list(patterns)
end
attr_reader :resources
alias_method :resource=, :resources=
def clean_paths=(patterns)
- if !patterns.is_a?(Rake::FileList) && patterns.is_a?(Array)
- @clean_paths = patterns
- else
- @clean_paths = [patterns]
- end
+ @clean_paths = pattern_list(patterns)
end
attr_reader :clean_paths
alias_method :clean_path=, :clean_paths=
@@ -222,6 +179,14 @@ def podfile?
false
end
+ def pattern_list(patterns)
+ if patterns.is_a?(Array) && (!defined?(Rake) || !patterns.is_a?(Rake::FileList))
+ patterns
+ else
+ [patterns]
+ end
+ end
+
# Returns all resource files of this pod, but relative to the
# project pods root.
def expanded_resources
2  spec/fixtures/spec-repos/master
@@ -1 +1 @@
-Subproject commit 39e348b0bfd268fe0a8606e71a07a0f9071cf7eb
+Subproject commit 56c5f468351fe0e195ee95a78160f4c18eaec40b
View
4 spec/functional/command_spec.rb
@@ -4,10 +4,6 @@
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory
- before do
- fixture('spec-repos/master') # ensure the archive is unpacked
- end
-
it "creates the local spec-repos directory and creates a clone of the `master' repo" do
command = Pod::Command.parse('setup', '--silent')
def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
View
2  spec/functional/downloader_spec.rb
@@ -37,7 +37,7 @@
:git => fixture('banana-lib'), :tag => 'v1.0'
)
downloader.download
- downloader.clean(['README'])
+ downloader.clean([@dir + 'README'])
(@dir + 'README').should.not.exist
end
end
View
2  spec/unit/specification_spec.rb
@@ -273,7 +273,7 @@ def validate(&block)
end
it "takes any object for clean_paths as long as it responds to #glob (we provide this for Rake::FileList)" do
- require 'rake'
+ Pod::FileList # autoload
@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) }
Please sign in to comment.
Something went wrong with that request. Please try again.