chrislloyd-fancypath 0.5.5 → 0.5.6

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.5"
8
+ GEM_VERSION = "0.5.6"
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
@@ -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
@@ -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.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-02 00:00:00 -08:00
13
+ date: 2009-02-13 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16