chrislloyd-fancypath 0.5.1 → 0.5.2

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.5.1"
8
+ GEM_VERSION = "0.5.2"
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
@@ -67,6 +67,11 @@ class Fancypath < Pathname
67
67
  self
68
68
  end
69
69
 
70
+ def set_extension(ext)
71
+ base = self.to_s[/^ (.+?) (\. ([^\.]+))? $/x, 1]
72
+ self.class.new(base + '.' + ext)
73
+ end
74
+
70
75
  def parent
71
76
  super.to_path
72
77
  end
@@ -67,6 +67,22 @@ describe '#copy' do
67
67
 
68
68
  end
69
69
 
70
+ describe '#set_extension' do
71
+
72
+ example "file without extension" do
73
+ Fancypath('/tmp/foo').set_extension('rb').should == Fancypath('/tmp/foo.rb')
74
+ end
75
+
76
+ example "single extension" do
77
+ Fancypath('/tmp/foo.py').set_extension('rb').should == Fancypath('/tmp/foo.rb')
78
+ end
79
+
80
+ example "multi extension" do
81
+ Fancypath('/tmp/foo.py.z').set_extension('rb').should == Fancypath('/tmp/foo.py.rb')
82
+ end
83
+
84
+ end
85
+
70
86
  end #/Fancypath
71
87
 
72
88
  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.1
4
+ version: 0.5.2
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-12-05 00:00:00 -08:00
13
+ date: 2009-02-02 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16