expansions 0.4.27 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/expansions/expansion.rb +4 -2
- data/lib/expansions/expansions.rb +2 -2
- data/lib/expansions/version.rb +1 -1
- data/spec/specs/expansion_spec.rb +26 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87468e00cac831515aeba5b44eb8c18c8189218a
|
|
4
|
+
data.tar.gz: a7eaba07c50412bbad98b1c4a853f107d718418e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4b137831b0d40eb964982e239ae5352ff758d0f782fc26867cc45d1ef462f17f42343f2654ec111431ad0f078d0489fb4e685dafddce94dec4defa94af475f7
|
|
7
|
+
data.tar.gz: 1113cb698c7dbfe4b909e87d4f5ccadeb653f887c1d424606dfeda824a3b73156378fbc4f9b9f1e7ba34ad805ed59b73482fbd1be7a2e57919272cc554d92bae
|
data/lib/expansions/expansion.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
|
data/lib/expansions/version.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: guard
|