fast 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,7 @@ module Fast
11
11
  # Returns a Fast::Dir list with all items in the directory, except ".." and "."
12
12
  def list path = nil, &block
13
13
  @path = normalize path unless path.nil?
14
+ self.clear unless self.empty?
14
15
  ::Dir.foreach @path do |entry|
15
16
  unless entry == "." or entry == ".."
16
17
  self << entry
@@ -24,6 +25,7 @@ module Fast
24
25
  # (at least yet)
25
26
  def files path = nil, &block
26
27
  @path = normalize path if path
28
+ self.clear unless self.empty?
27
29
  ::Dir.foreach @path do |entry|
28
30
  unless ::File.directory? "#{@path}/#{entry}"
29
31
  self << entry
@@ -37,6 +39,7 @@ module Fast
37
39
  # and excluding points
38
40
  def dirs path = nil, &block
39
41
  @path = normalize path if path
42
+ self.clear unless self.empty?
40
43
  ::Dir.foreach @path do |entry|
41
44
  if ::File.directory? "#{@path}/#{entry}" and entry != "." and entry != ".."
42
45
  self << entry
@@ -1,3 +1,3 @@
1
1
  module Fast
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -81,6 +81,47 @@ describe Fast::Dir do
81
81
  ::File.unlink "demo/alice.txt"
82
82
  ::Dir.unlink "demo"
83
83
  end
84
+
85
+ context "the method is called in an instance of Fast::Dir" do
86
+ it "should return the files only" do
87
+ ::File.should_not be_directory "demo"
88
+ Fast::File.new.touch "demo/alice.txt"
89
+ Fast::File.new.touch "demo/betty.txt"
90
+ Fast::File.new.touch "demo/chris.txt"
91
+ Fast::Dir.new.create! "demo/subdir"
92
+
93
+ the_dir = Fast::Dir.new :demo
94
+ the_dir.files.should include "alice.txt"
95
+ the_dir.files.should include "betty.txt"
96
+ the_dir.files.should include "chris.txt"
97
+ the_dir.files.should_not include "subdir"
98
+ the_dir.files.should_not include ".."
99
+ the_dir.files.should_not include "."
100
+
101
+ Fast::Dir.new.delete! :demo
102
+ end
103
+ end
104
+
105
+ context "the method is called after #list has been called on this instance" do
106
+ it "should return the files only" do
107
+ ::File.should_not be_directory "demo"
108
+ Fast::File.new.touch "demo/alice.txt"
109
+ Fast::File.new.touch "demo/betty.txt"
110
+ Fast::File.new.touch "demo/chris.txt"
111
+ Fast::Dir.new.create! "demo/subdir"
112
+
113
+ the_dir = Fast::Dir.new :demo
114
+ the_dir.list
115
+ the_dir.files.should include "alice.txt"
116
+ the_dir.files.should include "betty.txt"
117
+ the_dir.files.should include "chris.txt"
118
+ the_dir.files.should_not include "subdir"
119
+ the_dir.files.should_not include ".."
120
+ the_dir.files.should_not include "."
121
+
122
+ Fast::Dir.new.delete! :demo
123
+ end
124
+ end
84
125
  end
85
126
 
86
127
  describe "#dirs" do
@@ -111,6 +152,47 @@ describe Fast::Dir do
111
152
  ::File.unlink "demo/alice.txt"
112
153
  ::Dir.unlink "demo"
113
154
  end
155
+
156
+ context "the method is called in an instance of Fast::Dir" do
157
+ it "should return the dirs only" do
158
+ ::File.should_not be_directory "demo"
159
+ Fast::File.new.touch "demo/alice.txt"
160
+ Fast::File.new.touch "demo/betty.txt"
161
+ Fast::File.new.touch "demo/chris.txt"
162
+ Fast::Dir.new.create! "demo/subdir"
163
+
164
+ the_dir = Fast::Dir.new :demo
165
+ the_dir.dirs.should_not include "alice.txt"
166
+ the_dir.dirs.should_not include "betty.txt"
167
+ the_dir.dirs.should_not include "chris.txt"
168
+ the_dir.dirs.should include "subdir"
169
+ the_dir.dirs.should_not include ".."
170
+ the_dir.dirs.should_not include "."
171
+
172
+ Fast::Dir.new.delete! :demo
173
+ end
174
+ end
175
+
176
+ context "the method is called after #list has been called on this instance" do
177
+ it "should return the dirs only" do
178
+ ::File.should_not be_directory "demo"
179
+ Fast::File.new.touch "demo/alice.txt"
180
+ Fast::File.new.touch "demo/betty.txt"
181
+ Fast::File.new.touch "demo/chris.txt"
182
+ Fast::Dir.new.create! "demo/subdir"
183
+
184
+ the_dir = Fast::Dir.new :demo
185
+ the_dir.list
186
+ the_dir.dirs.should_not include "alice.txt"
187
+ the_dir.dirs.should_not include "betty.txt"
188
+ the_dir.dirs.should_not include "chris.txt"
189
+ the_dir.dirs.should include "subdir"
190
+ the_dir.dirs.should_not include ".."
191
+ the_dir.dirs.should_not include "."
192
+
193
+ Fast::Dir.new.delete! :demo
194
+ end
195
+ end
114
196
  end
115
197
 
116
198
  shared_examples_for "any dir creation" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-18 00:00:00.000000000 Z
12
+ date: 2012-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metafun
16
- requirement: &76004770 !ruby/object:Gem::Requirement
16
+ requirement: &83229840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *76004770
24
+ version_requirements: *83229840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &76004410 !ruby/object:Gem::Requirement
27
+ requirement: &83229540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *76004410
35
+ version_requirements: *83229540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: zucker
38
- requirement: &76004040 !ruby/object:Gem::Requirement
38
+ requirement: &83229210 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *76004040
46
+ version_requirements: *83229210
47
47
  description: DSL for file system interaction
48
48
  email:
49
49
  - xavierviacanel@gmail.com