diff --git a/lib/cocoaseeds/core.rb b/lib/cocoaseeds/core.rb index 11615bd..9e1e8ad 100644 --- a/lib/cocoaseeds/core.rb +++ b/lib/cocoaseeds/core.rb @@ -235,13 +235,18 @@ def github(repo, tag, options={}) end seed.version = tag seed.files = options[:files] || '**/*.{h,m,mm,swift}' + seed.exclude_files = options[:exclude_files] || [] elsif tag.is_a?(Hash) seed.commit = tag[:commit][0..6] seed.files = tag[:files] || '**/*.{h,m,mm,swift}' + seed.exclude_files = options[:exclude_files] || [] end if seed.files.kind_of?(String) seed.files = [seed.files] end + if seed.exclude_files.kind_of?(String) + seed.exclude_files = [seed.exclude_files] + end self.seeds[seed.name] = seed self.targets[seed.name] ||= [] self.targets[seed.name] << @current_target_name.to_s @@ -279,9 +284,14 @@ def bitbucket(repo, tag, options={}) elsif tag.is_a?(Hash) seed.commit = tag[:commit][0..6] seed.files = tag[:files] || '**/*.{h,m,mm,swift}' + seed.exclude_files = options[:exclude_files] || [] end if seed.files.kind_of?(String) seed.files = [seed.files] + seed.exclude_files = options[:exclude_files] || [] + end + if seed.exclude_files.kind_of?(String) + seed.exclude_files = [seed.exclude_files] end self.seeds[seed.name] = seed self.targets[seed.name] ||= [] @@ -320,6 +330,15 @@ def install_seeds self.source_files[name] = [] seed.files.each do |file| paths = Dir.glob(File.join(dirname, file)) + + # exclude files + seed.exclude_files.each do |exclude_file| + exclude_paths = Dir.glob(File.join(dirname, exclude_file)) + exclude_paths.each do |exclude_path| + paths.delete(exclude_path) + end + end + paths.each do |path| path = self.path_with_prefix(seed.name, path) self.source_files[name].push(path) diff --git a/lib/cocoaseeds/seed.rb b/lib/cocoaseeds/seed.rb index 9c8f47c..9507cd4 100644 --- a/lib/cocoaseeds/seed.rb +++ b/lib/cocoaseeds/seed.rb @@ -21,6 +21,10 @@ class Seed # attr_accessor :files + # @return [Array] the source file patterns which will be excluded + # + attr_accessor :exclude_files + # @return [String] lockfile-formatted string # # @example JLToast (1.2.2) diff --git a/test/test_configue.rb b/test/test_configue.rb index 25fc31f..399dc1b 100644 --- a/test/test_configue.rb +++ b/test/test_configue.rb @@ -149,6 +149,30 @@ def test_common_after_separated_target end + def test_exclude_files + seedfile %{ + github "devxoul/JLToast", "1.2.2", + :files => "JLToast/*.{h,swift}", + :exclude_files => "JLToast/JLToast.h" + } + @seed.install + + assert\ + !self.phase(:TestProj).include_filename?('JLToast.h'), + "TestProj should not have JLToast.h" + assert\ + !self.phase(:TestProjTests).include_filename?('JLToast.h'), + "TestProjTests should not have JLToast.h" + + assert\ + self.phase(:TestProj).include_filename?('JLToast.swift'), + "TestProj should have JLToast.swift" + assert\ + self.phase(:TestProjTests).include_filename?('JLToast.swift'), + "TestProjTests should have JLToast.swift" + end + + def test_remove seedfile %{ github "devxoul/JLToast", "1.2.2", :files => "JLToast/*.{h,swift}"