chrislloyd-fancypath 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "fancypath"
8
- GEM_VERSION = "0.5.6"
8
+ GEM_VERSION = "0.5.7"
9
9
  AUTHORS = ["Myles Byrne", "Chris Lloyd"]
10
10
  EMAIL = "myles@ducknewmedia.com"
11
11
  HOMEPAGE = "http://ducknewmedia.com/fancypath"
data/lib/fancypath.rb CHANGED
@@ -107,6 +107,14 @@ class Fancypath < Pathname
107
107
  super.reject { |c| c.basename.to_s =~ /^\./ }
108
108
  end
109
109
 
110
+ # only takes sym atm
111
+ def select(arg)
112
+ case arg
113
+ when Symbol ; Dir["#{self}/*.#{arg}"].map { |p| self.class.new(p) }
114
+ else ; Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
115
+ end
116
+ end
117
+
110
118
  def inspect
111
119
  super.sub('Pathname','Fancypath')
112
120
  end
@@ -107,6 +107,27 @@ describe '#has_extension?' do
107
107
 
108
108
  end
109
109
 
110
+ describe '#select' do
111
+
112
+ example 'with symbol' do
113
+ @dir.create_dir
114
+ %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
115
+
116
+ @dir.select(:jpg).should == [@dir/'a.jpg', @dir/'b.jpg']
117
+ end
118
+
119
+ example 'with glob' do
120
+ @dir.create_dir
121
+ %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
122
+
123
+ @dir.select("*.jpg").should == [@dir/'a.jpg', @dir/'b.jpg']
124
+ end
125
+
126
+ # todo: with regex
127
+ # todo: with block
128
+
129
+ end
130
+
110
131
  end #/Fancypath
111
132
 
112
133
  describe "String#to_path" do
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.6
4
+ version: 0.5.7
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-02-13 00:00:00 -08:00
13
+ date: 2009-02-17 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16