chrislloyd-fancypath 0.5.3 → 0.5.4
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 +10 -2
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/fancypath.rb
CHANGED
@@ -50,12 +50,15 @@ class Fancypath < Pathname
|
|
50
50
|
self
|
51
51
|
end
|
52
52
|
|
53
|
+
alias_method :cp, :copy
|
54
|
+
|
53
55
|
# file or dir
|
54
56
|
def remove
|
55
57
|
directory? ? rmtree : delete if exist?
|
56
58
|
self.to_path
|
57
59
|
end
|
58
60
|
|
61
|
+
alias_method :rm, :remove
|
59
62
|
def write(contents, mode='wb')
|
60
63
|
dirname.create
|
61
64
|
open(mode) { |f| f.write contents }
|
@@ -71,10 +74,15 @@ class Fancypath < Pathname
|
|
71
74
|
self.rename(dest)
|
72
75
|
dest.to_path
|
73
76
|
end
|
77
|
+
|
78
|
+
alias_method :mv, :move
|
74
79
|
|
75
80
|
def set_extension(ext)
|
76
|
-
|
77
|
-
|
81
|
+
"#{without_extension}.#{ext}".to_path
|
82
|
+
end
|
83
|
+
|
84
|
+
def without_extension
|
85
|
+
to_s[/^ (.+?) (\. ([^\.]+))? $/x, 1].to_path
|
78
86
|
end
|
79
87
|
|
80
88
|
def parent
|