chrislloyd-fancypath 0.2.0 → 0.3.0

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.2.0"
8
+ GEM_VERSION = "0.3.0"
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
@@ -1,20 +1,22 @@
1
1
  require 'pathname'
2
2
 
3
3
  class Pathname
4
- def to_path
4
+
5
+ def to_fancypath
5
6
  Fancypath.new(self)
6
7
  end
7
8
 
8
- alias_method :to_fancypath, :to_path
9
+ alias_method :to_path, :to_fancypath
9
10
 
10
11
  end
11
12
 
12
13
  class String
13
- def to_path
14
+
15
+ def to_fancypath
14
16
  Fancypath.new(self)
15
17
  end
16
18
 
17
- alias_method :to_fancypath, :to_path
19
+ alias_method :to_path, :to_fancypath
18
20
 
19
21
  end
20
22
 
@@ -23,10 +25,12 @@ class Fancypath < Pathname
23
25
 
24
26
  alias_method :exists?, :exist?
25
27
  alias_method :rename_to, :rename
26
-
27
- def /(path)
28
- self.join(path).to_path
28
+
29
+ def join(path)
30
+ super(path).to_path
29
31
  end
32
+
33
+ alias_method :/, :join
30
34
 
31
35
  # make file
32
36
  def touch
@@ -40,6 +44,11 @@ class Fancypath < Pathname
40
44
  self.to_path
41
45
  end
42
46
 
47
+ def copy(dest)
48
+ FileUtils.cp(self, dest)
49
+ self
50
+ end
51
+
43
52
  # file or dir
44
53
  def remove
45
54
  directory? ? rmtree : delete if exist?
@@ -10,9 +10,9 @@ before do
10
10
  end
11
11
  after { TMP_DIR.rmtree }
12
12
 
13
- describe '#/' do
13
+ describe '#join', 'aliased to #/' do
14
14
 
15
- it('returns Fancypath') { (@dir/'somefile').class.should == Fancypath }
15
+ it('returns a Fancypath') { (@dir/'somefile').class.should == Fancypath }
16
16
  it('joins paths') { (@dir/'somefile').to_s.should =~ /\/somefile$/ }
17
17
 
18
18
  end
@@ -50,6 +50,16 @@ describe '#write' do
50
50
 
51
51
  end
52
52
 
53
+ describe '#copy' do
54
+
55
+ before { @file.touch }
56
+ it('returns a Fancypath') { @file.copy(TMP_DIR/'foo').should be_instance_of(Fancypath) }
57
+ it('creates a new file') { @file.copy(TMP_DIR/'foo').should exist }
58
+ it('keeps the original') { @file.copy(TMP_DIR/'foo'); @file.should exist }
59
+ it('copies the contents') { @file.copy(TMP_DIR/'foo').read.should == @file.read }
60
+
61
+ end
62
+
53
63
  end #/Fancypath
54
64
 
55
65
  describe "String#to_path" do
data/spec/spec_helper.rb CHANGED
@@ -3,4 +3,4 @@ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
4
  require 'fancypath'
5
5
 
6
- TMP_DIR = Pathname.new(__FILE__).dirname.join('..', 'tmp', 'fancypath')
6
+ TMP_DIR = __FILE__.to_path.dirname/'..'/'tmp'/'fancypath'
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.2.0
4
+ version: 0.3.0
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: 2008-11-15 00:00:00 -08:00
13
+ date: 2008-11-24 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16