filepath 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,45 +69,6 @@ describe FilePathList do
69
69
  end
70
70
  end
71
71
 
72
- describe "#exclude" do
73
- let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
74
-
75
- it "excludes paths matching a Regex" do
76
- remaining = list.exclude(/bar$/)
77
-
78
- remaining.should be_a FilePathList
79
- remaining.should have(3).items
80
- remaining.each { |path| path.extension.should == 'foo' }
81
- end
82
-
83
- it "excludes all the paths for which the block returns true" do
84
- remaining = list.exclude { |path| path.extension?('bar') }
85
-
86
- remaining.should be_a FilePathList
87
- remaining.should have(3).items
88
- remaining.each { |path| path.extension.should == 'foo' }
89
- end
90
- end
91
-
92
- describe "#select" do
93
- let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
94
-
95
- it "keeps paths matching a Regex" do
96
- remaining = list.select(/bar$/)
97
-
98
- remaining.should be_a FilePathList
99
- remaining.should have(2).items
100
- remaining.each { |path| path.extension.should == 'bar' }
101
- end
102
-
103
- it "keeps all the paths for which the block returns true" do
104
- remaining = list.select { |ph| ph.extension?('bar') }
105
-
106
- remaining.should have(2).items
107
- remaining.each { |ph| ph.extension.should == 'bar' }
108
- end
109
- end
110
-
111
72
  describe "#<<" do
112
73
  it "adds a new to path to a existing FilePathList" do
113
74
  list1 = FilePathList.new(%w{a/b /c/d})
@@ -230,6 +191,80 @@ describe FilePathList do
230
191
  list.should_not eq(%w{a/a b/b c/c})
231
192
  end
232
193
  end
194
+
195
+ describe FilePathList::ArrayMethods do
196
+ let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
197
+
198
+ describe "#all?" do
199
+ it "checks whether a block applies to a list" do
200
+ ok = list.all? { |path| path.extension? }
201
+ ok.should be_true
202
+ end
203
+ end
204
+
205
+ describe "#any?" do
206
+ it "check whether a block does not apply to any path" do
207
+ ok = list.any? { |path| path.basename == "a.foo" }
208
+ ok.should be_true
209
+ end
210
+ end
211
+
212
+ describe "#none?" do
213
+ it "check whether a block does not apply to any path" do
214
+ ok = list.none? { |path| path.absolute? }
215
+ ok.should be_true
216
+ end
217
+ end
218
+ end
219
+
220
+ describe FilePathList::EntriesMethods do
221
+ let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
222
+
223
+ describe "#select" do
224
+ it "keeps paths matching a Regex" do
225
+ remaining = list.select(/bar$/)
226
+
227
+ remaining.should be_a FilePathList
228
+ remaining.should have(2).items
229
+ remaining.each { |path| path.extension.should == 'bar' }
230
+ end
231
+
232
+ it "keeps all the paths for which the block returns true" do
233
+ remaining = list.select { |ph| ph.extension?('bar') }
234
+
235
+ remaining.should have(2).items
236
+ remaining.each { |ph| ph.extension.should == 'bar' }
237
+ end
238
+ end
239
+
240
+ describe "#exclude" do
241
+ it "excludes paths matching a Regex" do
242
+ remaining = list.exclude(/bar$/)
243
+
244
+ remaining.should be_a FilePathList
245
+ remaining.should have(3).items
246
+ remaining.each { |path| path.extension.should == 'foo' }
247
+ end
248
+
249
+ it "excludes all the paths for which the block returns true" do
250
+ remaining = list.exclude { |path| path.extension?('bar') }
251
+
252
+ remaining.should be_a FilePathList
253
+ remaining.should have(3).items
254
+ remaining.each { |path| path.extension.should == 'foo' }
255
+ end
256
+ end
257
+
258
+ describe "#map" do
259
+ it "applies a block to each path" do
260
+ mapped = list.map { |path| path.remove_extension }
261
+
262
+ mapped.should be_a FilePathList
263
+ mapped.should have(list.size).items
264
+ mapped.each { |path| path.extension?.should be_false }
265
+ end
266
+ end
267
+ end
233
268
  end
234
269
 
235
270
 
File without changes
File without changes
data/spec/fixtures/f1 ADDED
File without changes
data/spec/tasks.rb CHANGED
@@ -16,6 +16,9 @@ FIXTURES_FAKE_ENTRIES = [
16
16
  'd3',
17
17
  'f1',
18
18
  'dx',
19
+ 'p1',
20
+ 'p2',
21
+ 's1',
19
22
  ].map { |entry| File.join(FIXTURES_DIR, *Array(entry)) }
20
23
 
21
24
  CLEAN.concat FIXTURES_FAKE_ENTRIES
@@ -34,6 +37,15 @@ namespace :spec do
34
37
  ln_s '/dev/null', t.name
35
38
  end
36
39
 
40
+ rule %r{/p[0-9]+$} do |t|
41
+ system "mkfifo #{t.name}"
42
+ end
43
+
44
+ rule %r{/s[0-9]+$} do |t|
45
+ require 'socket'
46
+ UNIXServer.new(t.name)
47
+ end
48
+
37
49
  desc "Generate fake dirs and files"
38
50
  task :gen => FIXTURES_FAKE_ENTRIES
39
51
  end
metadata CHANGED
@@ -1,48 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: filepath
3
- version: !ruby/object:Gem::Version
4
- version: '0.4'
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ version: "0.5"
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Gioele Barabucci
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-01-25 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-07-31 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
15
20
  name: bones-rspec
16
- requirement: &19274420 !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 13
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 1
21
32
  version: 2.0.1
22
33
  type: :development
23
- prerelease: false
24
- version_requirements: *19274420
25
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
26
36
  name: bones
27
- requirement: &19273040 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 3.7.3
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 39
44
+ segments:
45
+ - 3
46
+ - 8
47
+ - 0
48
+ version: 3.8.0
33
49
  type: :development
34
- prerelease: false
35
- version_requirements: *19273040
36
- description: ! 'filepath is a small library that helps dealing with files, directories
37
- and
38
-
39
- paths in general; a modern replacement for the standard Pathname.'
50
+ version_requirements: *id002
51
+ description: |-
52
+ filepath is a small library that helps dealing with files, directories and
53
+ paths in general; a modern replacement for the standard Pathname.
40
54
  email: gioele@svario.it
41
55
  executables: []
56
+
42
57
  extensions: []
58
+
43
59
  extra_rdoc_files: []
44
- files:
45
- - .gitignore
60
+
61
+ files:
62
+ - .yardoc/checksums
63
+ - .yardoc/object_types
64
+ - .yardoc/objects/root.dat
65
+ - .yardoc/proxy_types
46
66
  - .yardopts
47
67
  - README.md
48
68
  - Rakefile
@@ -54,33 +74,44 @@ files:
54
74
  - lib/filepath/filepathlist.rb
55
75
  - spec/filepath_spec.rb
56
76
  - spec/filepathlist_spec.rb
77
+ - spec/fixtures/d1/f11
78
+ - spec/fixtures/d1/f12
79
+ - spec/fixtures/f1
57
80
  - spec/spec_helper.rb
58
81
  - spec/tasks.rb
59
82
  homepage: http://github.com/gioele/filepath
60
83
  licenses: []
84
+
61
85
  post_install_message:
62
- rdoc_options:
86
+ rdoc_options:
63
87
  - --main
64
88
  - README.md
65
- require_paths:
89
+ require_paths:
66
90
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
91
+ required_ruby_version: !ruby/object:Gem::Requirement
68
92
  none: false
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
73
- required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
101
  none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
79
109
  requirements: []
110
+
80
111
  rubyforge_project: filepath
81
- rubygems_version: 1.8.12
112
+ rubygems_version: 1.8.24
82
113
  signing_key:
83
114
  specification_version: 3
84
- summary: filepath is a small library that helps dealing with files, directories and
85
- paths in general; a modern replacement for the standard Pathname.
115
+ summary: filepath is a small library that helps dealing with files, directories and paths in general; a modern replacement for the standard Pathname.
86
116
  test_files: []
117
+
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- /announcement.txt
2
- /coverage/
3
- /doc/
4
- /pkg/
5
- /.yardoc/
6
- /spec/fixtures/