tred-fancypath 0.5.11 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1 @@
1
- == fancypath
2
-
3
- Extensions to the Pathname library to model file IO in an OO mannor.
1
+ Extensions to the Pathname library to model file IO in an OO manner.
@@ -129,7 +129,11 @@ class Fancypath < Pathname
129
129
  Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
130
130
  end
131
131
  end
132
-
132
+
133
+ def empty?
134
+ directory? ? children.size == 0 : self.size == 0
135
+ end
136
+
133
137
  def inspect
134
138
  super.sub('Pathname','Fancypath')
135
139
  end
metadata CHANGED
@@ -1,37 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tred-fancypath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myles Byrne
8
8
  - Chris Lloyd
9
- autorequire: fancypath
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-06-08 00:00:00 -07:00
13
+ date: 2009-05-16 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
17
  description: Extensions for the Pathname library.
18
- email: myles@ducknewmedia.com
18
+ email: myles@myles.id.au
19
19
  executables: []
20
20
 
21
21
  extensions: []
22
22
 
23
- extra_rdoc_files:
24
- - README.rdoc
25
- - LICENSE
23
+ extra_rdoc_files: []
24
+
26
25
  files:
27
26
  - LICENSE
28
- - README.rdoc
29
- - Rakefile
27
+ - README
30
28
  - lib/fancypath.rb
31
- - spec/fancypath_spec.rb
32
- - spec/spec_helper.rb
33
29
  has_rdoc: false
34
- homepage: http://ducknewmedia.com/fancypath
30
+ homepage: http://github.com/tred/fancypath/tree/master
35
31
  post_install_message:
36
32
  rdoc_options: []
37
33
 
@@ -51,10 +47,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
47
  version:
52
48
  requirements: []
53
49
 
54
- rubyforge_project:
50
+ rubyforge_project: fancypath
55
51
  rubygems_version: 1.2.0
56
52
  signing_key:
57
- specification_version: 3
53
+ specification_version: 2
58
54
  summary: Extensions for the Pathname library.
59
55
  test_files: []
60
56
 
data/Rakefile DELETED
@@ -1,56 +0,0 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'rubygems/specification'
4
- require 'date'
5
- require 'spec/rake/spectask'
6
-
7
- GEM = "fancypath"
8
- GEM_VERSION = "0.5.11"
9
- AUTHORS = ["Myles Byrne", "Chris Lloyd"]
10
- EMAIL = "myles@ducknewmedia.com"
11
- HOMEPAGE = "http://ducknewmedia.com/fancypath"
12
- SUMMARY = "Extensions for the Pathname library."
13
-
14
- spec = Gem::Specification.new do |s|
15
- s.name = GEM
16
- s.version = GEM_VERSION
17
- s.platform = Gem::Platform::RUBY
18
- s.has_rdoc = true
19
- s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
20
- s.summary = SUMMARY
21
- s.description = s.summary
22
- s.authors = AUTHORS
23
- s.email = EMAIL
24
- s.homepage = HOMEPAGE
25
-
26
- # Uncomment this to add a dependency
27
- # s.add_dependency "foo"
28
-
29
- s.require_path = 'lib'
30
- s.autorequire = GEM
31
- s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
32
- end
33
-
34
- task :default => :spec
35
-
36
- desc "Run specs"
37
- Spec::Rake::SpecTask.new do |t|
38
- t.spec_files = FileList['spec/**/*_spec.rb']
39
- t.spec_opts = %w(-fs --color)
40
- end
41
-
42
- Rake::GemPackageTask.new(spec) do |pkg|
43
- pkg.gem_spec = spec
44
- end
45
-
46
- desc "install the gem locally"
47
- task :install => [:package] do
48
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
49
- end
50
-
51
- desc "create a gemspec file"
52
- task :make_spec do
53
- File.open("#{GEM}.gemspec", "w") do |file|
54
- file.puts spec.to_ruby
55
- end
56
- end
@@ -1,156 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe Fancypath do
4
-
5
- before do
6
- TMP_DIR.rmtree if TMP_DIR.exist?
7
- TMP_DIR.mkpath
8
- @file = TMP_DIR.to_path/'testfile'
9
- @dir = TMP_DIR.to_path/'testdir'
10
- end
11
- after { TMP_DIR.rmtree }
12
-
13
- describe '#join', 'aliased to #/' do
14
-
15
- it('returns a Fancypath') { (@dir/'somefile').class.should == Fancypath }
16
- it('joins paths') { (@dir/'somefile').to_s.should =~ /\/somefile$/ }
17
-
18
- end
19
-
20
- describe '#parent' do
21
-
22
- it('returns parent') { @file.parent.should == TMP_DIR.to_path }
23
- it('returns Fancypath') { @file.parent.should be_instance_of(Fancypath) }
24
-
25
- end
26
-
27
- describe '#touch', 'file does not exist' do
28
-
29
- it('returns self') { @file.touch.should == @file }
30
- it('returns a Fancypath') { @file.touch.should be_instance_of(Fancypath) }
31
- it('creates file') { @file.touch.should be_file }
32
-
33
- end
34
-
35
- describe '#create', 'dir does not exist' do
36
-
37
- it('returns self') { @dir.create.should == @dir }
38
- it('returns a Fancypath') { @dir.create.should be_instance_of(Fancypath) }
39
- it('creates directory') { @dir.create.should be_directory }
40
-
41
- end
42
-
43
- describe '#remove' do
44
-
45
- it('returns self') { @file.remove.should == @file }
46
- it('returns a Fancypath') { @file.remove.should be_instance_of(Fancypath) }
47
- it('removes file') { @file.touch.remove.should_not exist }
48
- it('removes directory') { @dir.create.remove.should_not exist }
49
-
50
- end
51
-
52
- describe '#write' do
53
-
54
- it('returns self') { @file.write('').should == @file }
55
- it('returns a Fancypath') { @file.write('').should be_instance_of(Fancypath) }
56
- it('writes contents to file') { @file.write('test').read.should == 'test' }
57
-
58
- end
59
-
60
- describe '#copy' do
61
-
62
- before { @file.touch }
63
- it('returns a Fancypath') { @file.copy(TMP_DIR/'foo').should be_instance_of(Fancypath) }
64
- it('creates a new file') { @file.copy(TMP_DIR/'foo').should exist }
65
- it('keeps the original') { @file.copy(TMP_DIR/'foo'); @file.should exist }
66
- it('copies the contents') { @file.copy(TMP_DIR/'foo').read.should == @file.read }
67
-
68
- end
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
-
86
- describe '#move' do
87
-
88
- example "destination has the file contents, source does not exist" do
89
- @file.write('foo')
90
- dest = TMP_DIR/'newfile'
91
- @file.move( dest )
92
- @file.should_not exist
93
- dest.read.should == 'foo'
94
- end
95
-
96
- end
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
-
110
- describe '#select' do
111
-
112
- example 'with symbol' do
113
- @dir.create_dir
114
- %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
115
-
116
- @dir.select(:jpg).should == [@dir/'a.jpg', @dir/'b.jpg']
117
- end
118
-
119
- example 'with glob' do
120
- @dir.create_dir
121
- %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
122
-
123
- @dir.select("*.jpg").should == [@dir/'a.jpg', @dir/'b.jpg']
124
- end
125
-
126
- example 'with regex' do
127
- @dir.create_dir
128
- %W(a.jpg b.jpg c.gif 1.jpg).each { |f| (@dir/f).touch }
129
-
130
- @dir.select(/[^\d]\.(jpg|gif)$/).should == [@dir/'a.jpg', @dir/'b.jpg', @dir/'c.gif']
131
- end
132
-
133
- example 'with multiple args' do
134
- @dir.create_dir
135
- %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
136
-
137
- @dir.select(:jpg, '*.gif').should == [@dir/'a.jpg', @dir/'b.jpg', @dir/'c.gif']
138
- end
139
-
140
- # todo: with block
141
-
142
- end
143
-
144
- end #/Fancypath
145
-
146
- describe "String#to_path" do
147
-
148
- it('returns a Fancypath') { 'test'.to_path.should be_instance_of(Fancypath) }
149
-
150
- end
151
-
152
- describe "Pathname#to_path" do
153
-
154
- it('returns a Fancypath') { Fancypath.new('/').to_path.should be_instance_of(Fancypath) }
155
-
156
- end
@@ -1,6 +0,0 @@
1
- $TESTING=true
2
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
-
4
- require 'fancypath'
5
-
6
- TMP_DIR = __FILE__.to_path.dirname/'..'/'tmp'/'fancypath'