chrislloyd-fancypath 0.2.0 → 0.3.0
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 +1 -1
- data/lib/fancypath.rb +16 -7
- data/spec/fancypath_spec.rb +12 -2
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/fancypath.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
3
|
class Pathname
|
4
|
-
|
4
|
+
|
5
|
+
def to_fancypath
|
5
6
|
Fancypath.new(self)
|
6
7
|
end
|
7
8
|
|
8
|
-
alias_method :
|
9
|
+
alias_method :to_path, :to_fancypath
|
9
10
|
|
10
11
|
end
|
11
12
|
|
12
13
|
class String
|
13
|
-
|
14
|
+
|
15
|
+
def to_fancypath
|
14
16
|
Fancypath.new(self)
|
15
17
|
end
|
16
18
|
|
17
|
-
alias_method :
|
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
|
28
|
-
|
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?
|
data/spec/fancypath_spec.rb
CHANGED
@@ -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
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.
|
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-
|
13
|
+
date: 2008-11-24 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|