Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Commit

Permalink
Add an availability to exclude files.
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Oct 18, 2015
1 parent 40dd51c commit 4d926b0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/cocoaseeds/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] ||= []
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/cocoaseeds/seed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class Seed
#
attr_accessor :files

# @return [Array<String>] the source file patterns which will be excluded
#
attr_accessor :exclude_files

# @return [String] lockfile-formatted string
#
# @example JLToast (1.2.2)
Expand Down
24 changes: 24 additions & 0 deletions test/test_configue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 4d926b0

Please sign in to comment.