chrislloyd-fancypath 0.5.8 → 0.5.9

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.
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.8"
8
+ GEM_VERSION = "0.5.9"
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
@@ -35,12 +35,12 @@ class Fancypath < Pathname
35
35
  # make file
36
36
  def touch
37
37
  FileUtils.touch self.to_s
38
- self.to_path
38
+ self
39
39
  end
40
40
 
41
41
  def create_dir
42
42
  mkpath unless exist?
43
- self.to_path
43
+ self
44
44
  end
45
45
 
46
46
  alias_method :create, :create_dir
@@ -55,14 +55,14 @@ class Fancypath < Pathname
55
55
  # file or dir
56
56
  def remove
57
57
  directory? ? rmtree : delete if exist?
58
- self.to_path
58
+ self
59
59
  end
60
60
 
61
61
  alias_method :rm, :remove
62
62
  def write(contents, mode='wb')
63
63
  dirname.create
64
64
  open(mode) { |f| f.write contents }
65
- self.to_path
65
+ self
66
66
  end
67
67
 
68
68
  def append(contents)
@@ -109,8 +109,10 @@ class Fancypath < Pathname
109
109
  end
110
110
 
111
111
  # only takes sym atm
112
- def select(arg)
113
- case arg
112
+ def select(*args)
113
+ return args.map { |arg| select(arg) }.flatten.uniq if args.size > 1
114
+
115
+ case arg = args.first
114
116
  when Symbol ; Dir["#{self}/*.#{arg}"].map { |p| self.class.new(p) }
115
117
  else ; Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
116
118
  end
@@ -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 multiple args' do
127
+ @dir.create_dir
128
+ %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
129
+
130
+ @dir.select(:jpg, '*.gif').should == [@dir/'a.jpg', @dir/'b.jpg', @dir/'c.gif']
131
+ end
132
+
126
133
  # todo: with regex
127
134
  # todo: with block
128
135
 
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.8
4
+ version: 0.5.9
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-20 00:00:00 -08:00
13
+ date: 2009-03-07 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16