chrislloyd-fancypath 0.5.5 → 0.5.6
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 +5 -0
- data/spec/fancypath_spec.rb +12 -0
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/fancypath.rb
CHANGED
@@ -76,6 +76,7 @@ class Fancypath < Pathname
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def tail(bytes)
|
79
|
+
return self.read if self.size < bytes
|
79
80
|
open('r') do |f|
|
80
81
|
f.seek(-bytes, IO::SEEK_END)
|
81
82
|
f.read
|
@@ -92,6 +93,10 @@ class Fancypath < Pathname
|
|
92
93
|
to_s[/^ (.+?) (\. ([^\.]+))? $/x, 1].to_path
|
93
94
|
end
|
94
95
|
|
96
|
+
def has_extension?(ext)
|
97
|
+
!!(self.to_s =~ /\.#{ext}$/)
|
98
|
+
end
|
99
|
+
|
95
100
|
def parent
|
96
101
|
super.to_path
|
97
102
|
end
|
data/spec/fancypath_spec.rb
CHANGED
@@ -95,6 +95,18 @@ describe '#move' do
|
|
95
95
|
|
96
96
|
end
|
97
97
|
|
98
|
+
describe '#has_extension?' do
|
99
|
+
|
100
|
+
example do
|
101
|
+
Fancypath('/tmp/foo.bar').has_extension?('bar').should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
example do
|
105
|
+
Fancypath('/tmp/foo.bar').has_extension?('foo').should be_false
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
98
110
|
end #/Fancypath
|
99
111
|
|
100
112
|
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.
|
4
|
+
version: 0.5.6
|
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
|
+
date: 2009-02-13 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|