chrislloyd-fancypath 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/fancypath.rb +6 -2
- data/spec/fancypath_spec.rb +7 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/fancypath.rb
CHANGED
@@ -113,8 +113,12 @@ class Fancypath < Pathname
|
|
113
113
|
return args.map { |arg| select(arg) }.flatten.uniq if args.size > 1
|
114
114
|
|
115
115
|
case arg = args.first
|
116
|
-
when Symbol
|
117
|
-
|
116
|
+
when Symbol
|
117
|
+
Dir["#{self}/*.#{arg}"].map { |p| self.class.new(p) }
|
118
|
+
when Regexp
|
119
|
+
children.select { |child| child.to_s =~ arg }
|
120
|
+
else
|
121
|
+
Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
|
118
122
|
end
|
119
123
|
end
|
120
124
|
|
data/spec/fancypath_spec.rb
CHANGED
@@ -123,6 +123,13 @@ describe '#select' do
|
|
123
123
|
@dir.select("*.jpg").should == [@dir/'a.jpg', @dir/'b.jpg']
|
124
124
|
end
|
125
125
|
|
126
|
+
example 'with regex' do
|
127
|
+
@dir.create_dir
|
128
|
+
%W(a.jpg b.jpg c.gif 1.jpg).each { |f| (@dir/f).touch }
|
129
|
+
|
130
|
+
@dir.select(/[^\d]\.(jpg|gif)$/).should == [@dir/'a.jpg', @dir/'b.jpg', @dir/'c.gif']
|
131
|
+
end
|
132
|
+
|
126
133
|
example 'with multiple args' do
|
127
134
|
@dir.create_dir
|
128
135
|
%W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
|
@@ -130,7 +137,6 @@ describe '#select' do
|
|
130
137
|
@dir.select(:jpg, '*.gif').should == [@dir/'a.jpg', @dir/'b.jpg', @dir/'c.gif']
|
131
138
|
end
|
132
139
|
|
133
|
-
# todo: with regex
|
134
140
|
# todo: with block
|
135
141
|
|
136
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrislloyd-fancypath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myles Byrne
|
@@ -10,7 +10,7 @@ autorequire: fancypath
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-03-
|
13
|
+
date: 2009-03-17 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|