expansions 0.4.27 → 0.4.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c31c96a824786fe149f6ba77e3110dd6f827764c
4
- data.tar.gz: 96972e66f591c73890eed6139ce1c662a68fa32a
3
+ metadata.gz: 87468e00cac831515aeba5b44eb8c18c8189218a
4
+ data.tar.gz: a7eaba07c50412bbad98b1c4a853f107d718418e
5
5
  SHA512:
6
- metadata.gz: 7b1b8ea1fa2ca46dd2468d4191b26576debba6160d6290468cbc1b504360dcf3a83aa94dc9e81a6c2db131f0acd0664e6116262800d48728990a0b69f797a351
7
- data.tar.gz: ee31480cd882aa87f7de0bc39e1e7de787d62d5a356f7186f2c50cf6019db9c41dece2d0cd625b021be73b936780aaa35398a72bdd4e7ce415bfcaddbb0771a9
6
+ metadata.gz: d4b137831b0d40eb964982e239ae5352ff758d0f782fc26867cc45d1ef462f17f42343f2654ec111431ad0f078d0489fb4e685dafddce94dec4defa94af475f7
7
+ data.tar.gz: 1113cb698c7dbfe4b909e87d4f5ccadeb653f887c1d424606dfeda824a3b73156378fbc4f9b9f1e7ba34ad805ed59b73482fbd1be7a2e57919272cc554d92bae
@@ -59,8 +59,10 @@ module Expansions
59
59
  hash_process(target, files_to_merge, merge_proc, &block)
60
60
  end
61
61
 
62
- def look_for_templates_in(path)
63
- globber.call(path).process_all_items_using(TemplateVisitor.instance)
62
+ def look_for_templates_in(path, options=Hash.new(nil))
63
+ exlusion = options.fetch(:exclude, -> (file) { false })
64
+
65
+ globber.call(path, exlusion).process_all_items_using(TemplateVisitor.instance)
64
66
  end
65
67
 
66
68
  def cleanup(&block)
@@ -5,9 +5,9 @@ module Expansions
5
5
  Expansions::Expansion.instance.instance_eval(&block)
6
6
  end
7
7
 
8
- def glob(path)
8
+ def glob(path, exclude=->(file) { false })
9
9
  items = Dir.glob(path, File::FNM_DOTMATCH)
10
- items.each{|item| yield item if block_given?}
10
+ items.each{|item| yield item if block_given? && !exclude.call(item)}
11
11
  return items
12
12
  end
13
13
 
@@ -1,3 +1,3 @@
1
1
  module Expansions
2
- VERSION = "0.4.27"
2
+ VERSION = "0.4.28"
3
3
  end
@@ -69,6 +69,7 @@ module Expansions
69
69
  @items+=1
70
70
  end
71
71
  end
72
+
72
73
  context "when a set of templates is specified" do
73
74
  let(:path){"**/*"}
74
75
  let(:template_visitor){FakeVisitor.new}
@@ -77,18 +78,37 @@ module Expansions
77
78
  @files = %w[1 2 3 4]
78
79
  Kernel.stub(:glob).with(path).and_return(@files)
79
80
  @sut = Expansion.new
80
- @sut.globber = lambda{|the_path|
81
+ @sut.globber = lambda{|the_path, exclusion|
81
82
  the_path.should == path
82
- return @files
83
+ files = []
84
+ @files.each do |file|
85
+ files << file unless exclusion.call(file)
86
+ end
87
+ return files
83
88
  }
84
89
  end
85
- before (:each) do
86
- @sut.look_for_templates_in(path)
90
+
91
+ context 'and a filter is not provided' do
92
+ before (:each) do
93
+ @sut.look_for_templates_in(path)
94
+ end
95
+
96
+ it "should process each of the loaded templates using the template visitor" do
97
+ template_visitor.items.should == 4
98
+ end
87
99
  end
88
100
 
89
- it "should process each of the loaded templates using the template visitor" do
90
- template_visitor.items.should == 4
101
+ context 'and a filter is provided' do
102
+ before (:each) do
103
+ @sut.look_for_templates_in(path, exclude: -> (file) { /1/ =~ file })
104
+ end
105
+
106
+ it 'should only process the templates that were not filtered' do
107
+ template_visitor.items.should == 3
108
+ end
91
109
  end
110
+
111
+
92
112
  end
93
113
 
94
114
  context "when a before is specified" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expansions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.27
4
+ version: 0.4.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Develop With Passion®
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard